vhost on nginx

1 min read

|| how to setup vhost on nginx + create directory for vhost
 # cd /var/www
# mkdir -p blackonsole.org/{htdocs,logs,stats}
# mkdir -p blackonsole.com/{htdocs,logs,stats}
+ create vhost conf file
 # vi /etc/nginx/conf.d/blackonsole.org.conf
server {
   listen  80;
   server_name  blackonsole.org www.blackonsole.org;

   access_log  /var/www/blackonsole.org/logs/access.log ;
   error_log	/var/www/blackonsole.org/logs/error.log ;

   location / {
       root   /var/www/blackonsole.org/htdocs;
       index  index.php index.html index.htm;

   }

   error_page   500 502 503 504  /50x.html;
   location = /50x.html {
       root   /var/www/blackonsole.org/htdocs;
   }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ .php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		root	/var/www/blackonsole.org/htdocs;
		fastcgi_param  SCRIPT_FILENAME  /var/www/blackonsole.org/htdocs$fastcgi_script_name;
		include fastcgi_params;
	}


   location ~ /.ht {
       deny  all;
   }
}
 # vi /etc/nginx/conf.d/blackonsole.com.conf
server {
   listen  80;
   server_name  blackonsole.com www.blackonsole.com;

   access_log  /var/www/blackonsole.com/logs/access.log ;
   error_log	/var/www/blackonsole.com/logs/error.log ;

   location / {
       root   /var/www/blackonsole.com/htdocs;
       index  index.php index.html index.htm;

   }

   error_page   500 502 503 504  /50x.html;
   location = /50x.html {
       root   /var/www/blackonsole.com/htdocs;
   }

  # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  location ~ .php$ {
		fastcgi_pass   127.0.0.1:9000;
		fastcgi_index  index.php;
		root	/var/www/blackonsole.com/htdocs;
		fastcgi_param  SCRIPT_FILENAME  /var/www/blackonsole.com/htdocs$fastcgi_script_name;
		include fastcgi_params;
	}

   location ~ /.ht {
       deny  all;
   }
}
+ add vhost on nginx.conf
# vi /etc/nginx/nginx.conf
### add line like this on http section:
include /etc/nginx/conf.d/*.conf;
+ restarting nginx httpd and php-fpm
 # /etc/init.d/php-fpm restart
# /etc/init.d/nginx restart

You might be interested in exploring more about web server configurations and their significance in website performance. Speaking of **virtual hosts**, you might find it insightful to read about Virtual Hosting, which details how multiple websites can share a single server. Additionally, if you’re curious about server management, check out Nginx, the web server software that powers your virtual hosts with efficiency. Lastly, understanding the role of PHP in web development might enhance your grasp of dynamic content handling on your sites.

How to fix problem with…

Facing a Git error with the 'vi' editor? Discover how to easily fix it by checking your Vim path and configuring Git to use...
Sysadmin.ID
10 sec read

Apache :: MP4 Streaming

Learn how to enable MP4 streaming in Apache with the installation of the mod_h264 streaming module, making your video content accessible and efficient. Follow...
Sysadmin.ID
18 sec read

Apache :: Flash / FLV…

Learn how to effortlessly configure Apache for FLV streaming by installing the mod_flvx module and updating your httpd.conf file. Discover the simple steps to...
Sysadmin.ID
15 sec read

2 Replies to “vhost on nginx”

  1. tu file confignya emang dua gitu y bang?
    q uda nyoba, tp listen portnya q ganti 8080. kok gak bisa d akses ya?

    1. ku pisahkan gtu..
      apakan setelah restart nginx port 8080 terbuka:
      # netstat -tlupn | grep 8080

      munkin bisa di cek error.na, untuk investigate.. 😀

      semoga bisa membantu..

Leave a Reply

Your email address will not be published. Required fields are marked *