in Unix

Make Virtual Host in Engine X (nginx)

Since last time I install php-fpm in my freebsd box I still looking way to make virtualhost. I think its not easy to make vhost in nginx but I’m wrong 🙂

Just add :

server {



will add new vhost.

Full sample from my vhost :

server {
        listen          80;

        location / {
            index index.php index.html;
            root  /usr/local/www/nginx/sandbox;
            location ~ \.php$ {
           fastcgi_index   index.php;
          fastcgi_param     SCRIPT_FILENAME
           include      fastcgi_params;


another feature that I learn too is ‘autoindex’ since my friend need to list all files and directory if no index files exists.

For more fancy index I need to recompile it with fancyindex but I’m OK with it 🙂

Full sample of nginx.conf for two vhost with autouindex on and off can be download from here.