Compare VPS Hosting and Dedicated Server

ComfortVPS is here to help you find the right hosting, Save Time and Save Money!
Focus on cheap Windows VPS Hosting and Linux VPS Hosting Since 2012, and Dedicated Server NOW
How to custom config a Nginx domain? Tutorial of Nginx website custom configuration file

How to custom config a Nginx domain? This is a tutorial of Nginx website custom configuration file for ComfortVPS Nginx+PHP+MySql Installation Service

Nginx configuration file location:

  1. Nginx main config file located at /etc/nginx/nginx.conf, You do not need edit this file in most cases.
  2. Default configuration file for all domains located at /etc/nginx/conf.d/default.conf, You do not need edit this file in most cases.
  3. Extend config file for all domains which included in default.conf located at /etc/nginx/conf.d/my_domain
    You can add some futures (eg, if domain=test.com then rewrite ) by edit this config file, already have little example code in it
  4. Custom private domain example configuration file: /etc/nginx/conf.d/example.com.conf
    You can copy this example.com.conf to yourdomain.com.conf, then edit it for custom special needs. eg, rewrite, proxy

How to custom config a Nginx domain?

Let's say you want custom a conifg file for website www.comfortvps.com

Step 1: SSH login with root, cd /etc/nginx/conf.d/; cp example.com.conf comfortvps.com.conf;

Step 2: vi comfortvps.com.conf, modify it to meet your needs

Setp 3: test your Nginx config file before restart it. service nginx configtest

Step 4: restart or reload Nginx, service nginx reload or service nginx restart

Reviews and Comments