This tutorial is running in a FreeBSD vps with IPv6 only from VDS6 with the following :
- Package Name v128
- Ram 128MB
- swap 128MB
- Disk Space 2GB
- Bandwidth 100GB
- 2 IPv6
- FreeBSD 8
- 1 CPU Core 500Mhz
- $ 0.95/month
Since the ssh is not configured after first install, we have to change the sshd_config, and reboot the vps. Go to VDSManager – Private Files, and browse to /etc/ssh/sshd_config. Uncomments Port and Listen address, and then reboot the vps.
Next, change the /etc/resolv.conf so the vps can have access to the internet via IPv6, add the Google DNS :
nameserver 2001:4860:4860::8888 nameserver 2001:4860:4860::8844
Installing Nginx
# cd /usr/ports/www/nginx # make install clean
Enable the following modules :
[X] HTTP_MODULE Enable HTTP module [X] HTTP_ADDITION_MODULE Enable http_addition module [X] HTTP_CACHE_MODULE Enable http_cache module [X] HTTP_DAV_MODULE Enable http_webdav module [X] HTTP_FLV_MODULE Enable http_flv module [X] HTTP_GEOIP_MODULE Enable http_geoip module [X] HTTP_GZIP_STATIC_MODULE Enable http_gzip_static module [X] HTTP_IMAGE_FILTER_MODULE Enable http_image_filter module [X] HTTP_PERL_MODULE Enable http_perl module [X] HTTP_RANDOM_INDEX_MODULE Enable http_random_index module [X] HTTP_REALIP_MODULE Enable http_realip module [X] HTTP_REWRITE_MODULE Enable http_rewrite module [X] HTTP_SECURE_LINK_MODULE Enable http_secure_link module [X] HTTP_SSL_MODULE Enable http_ssl module [X] HTTP_STATUS_MODULE Enable http_stub_status module [X] HTTP_SUB_MODULE Enable http_sub module [X] HTTP_XSLT_MODULE Enable http_xslt module
Enable the Nginx by editing /etc/rc.conf, and add the following :
nginx_enable="YES"
Installing another package
Before we configure and start the web server, we need to install PCRE, libtool, PHP with FPM and PHP extensions. Follow these steps:
cd /usr/ports/devel/pcre make install clean cd /usr/ports/devel/libtool make install clean cd /usr/ports/lang/php5 make install clean
During the selection module page, select FPM (FastCgi Process Manager).
cd /usr/ports/lang/php5-extensions make install clean
Since PHP-FPM is a service, we need to add this in /etc/rc.conf:
php_fpm_enable="YES"
Copying PHP.ini
By default, there is no php.ini specified. So we need to copy the php.ini which has been prepared during port installation.
cp /usr/local/etc/php/php.ini-production /usr/local/etc/php/php.ini
Start the PHP-FPM
/usr/local/etc/rc.d/php-fpm start
Now PHP5-FPM is listening at 127.0.0.1:9001, next, prepare the directory for serving the website.
Configure the Nginx.conf
# nano /usr/local/etc/nginx/nginx.conf
---------------------------------------
user nobody;
worker_processes 1;
error_log logs/error.log;
pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on;
keepalive_timeout 65;
gzip on;
# We define the virtual host here
server {
listen 192.168.60.2:80;
server_name mydomain.net www.mydomain.net;
access_log /home/mydomain/logs/access.log main;
location / {
root /home/mydomain/public_html;
index index.html index.htm index.php;
}
# Let nginx know how to handle PHP using fastcgi
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/mydomain/public_html$fastcgi_script_name;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
}
}
Now we have our webserver ready to launch :
/usr/local/etc/rc.d/nginx start /usr/local/etc/rc.d/php-fpm restart /usr/local/etc/rc.d/nginx reload