< A, reference >
Here to configure 2 sites (2 domain names) For example, n sites can increase the adjustment, assuming:
IP Address: 202.55.1.100
Domain 1 example1.com placed in/www/example1
The basic ideas and steps for configuring Nginx virtual hosting are as follows:
Place this site example1.com in a directory that Nginx can access/www/
Create a Nginx profile example1.com.conf for each site and place the configuration file in/etc/nginx/vhosts/
And then add a sentence in/etc/nginx.conf. Include the configuration file created by step 2 (with *)
Restart Nginx
Specific process
The following is a specific configuration process:
1. Create the vhosts directory under/etc/nginx
Mkdir/etc/nginx/vhosts
2, in the/etc/nginx/vhosts/to create a name for the example1.com.conf file, the following content in handcuffs
server {
Listen 80;
server_name example1.com www. example1.com;
#access_log/www/access_ Example1.log Main;
Location/{
root/www/example1.com;
Index index.php index.html index.htm;
}
Error_page 502 503 504/50x.html;
Location =/50x.html {
root/usr/share/nginx/html;
}
# 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;
Fastcgi_param script_filename/www/example1.com/$fastcgi _script_name;
Include Fastcgi_params;
}
Location ~/\.ht {
Deny all;
}
}
3. Open/etc/nginix.conf File
Put the following sentence in the last line of the nginx.conf file to introduce the vhosts file you just made
include/usr/local/etc/nginx/vhosts/*;
5, restart Nginx
/etc/init.d/nginx restart
or Kill-hup ' Cat/var/run/nginx.pid ' cat followed by the nginx process PID If you do not know the location of the Nginx.pid file can be found with the Find/-name nginx.pid command
or installed with the Yum source package Nginx can directly service Nginx restart
</Reference >
< II, my example >
---------vhosts/led.conf
server {
Listen 80;
server_namewww.led.com
Index index.html index.htm index.php;
root/usr/local/vhost/led;
#charset Koi8-r;
#access_log Logs/host.access.log Main;
Location/{
Root/usr/local/vhost/led;
Index index.html index.htmindex.php;
}
#error_page 404/404.html;
# REDIRECT Server error pages to the static page/50x.html
#
Error_page 502 503 504/50x.html;
Location =/50x.html {
root HTML;
}
# Proxy The PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# Proxy_pass http://127.0.0.1;
#}
Location ~. *\. (PHP|PHP5)? $
{
#fastcgi_pass Unix:/tmp/php-cgi.sock;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/scripts$fastcgi_script_name;