Introduction: This is a detailed page for nginx multi-site settings. It introduces PHP, related knowledge, skills, experience, and some PHP source code.
Class = 'pingjiaf' frameborder = '0' src = 'HTTP: // biancheng.dnbc?info/pingjia.php? Id = 339495 'rolling = 'no'>
The multi-site configuration of nginx is actually very similar to Apache. Suppose we already have two domain names: www.websuita.com and www.websuitb.com. The two domain names have been mapped to the server whose IP address is 192.168.1.1. Let's start:
1. Create a configuration file for our site
I did this. Create a directory dedicated to storing virtualhost under the conf directory of the nginx configuration file named vhosts_conf. You can put all the configurations of the virtual directory here. Create a configuration file named vhosts_modoupi_websuita.conf and open it. We will configure it here and write it to it:
Server {
Listen 80; # listening port number
SERVER_NAME websuita.com; # Domain Name
# Access_log logs/host. Access. Log main;
Location /{
Root X:/wnmp/www/websuita; # site path
Index default. php index. php index.html index.htm;
# Write rewrite of the site here
Rewrite ^/(\ W +) \. html $/$ 1.php;
Rewrite ^/(\ W +) $/$1/$ 2.php;
}
# Error page configuration
Error_page 404/error.html;
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
Location ~ \. Php $ {
Root X:/wnmp/www/websuita;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param script_filename $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
Location ~ /\. Ht {
Deny all;
}
}
This completes the configuration of Site A. Configure websuitb in the same way. Here I name it vhosts_modoupi_websuitb.conf and go directlyCode
Server {
Listen 80; # listening port number
SERVER_NAME websuitb.com; # Domain Name
# Access_log logs/host. Access. Log main;
Location /{
Root X:/wnmp/www/websuitb; # site path
Index default. php index. php index.html index.htm;
# Write rewrite of the site here
Rewrite ^/(\ W +) \. html $/$ 1.php;
Rewrite ^/(\ W +) $/$1/$ 2.php;
}
# Error page configuration
Error_page 404/error.html;
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
Location ~ \. Php $ {
Root X:/wnmp/www/websuitb;
Fastcgi_pass 127.0.0.1: 9000;
Fastcgi_index index. php;
Fastcgi_param script_filename $ document_root $ fastcgi_script_name;
Include fastcgi_params;
}
Location ~ /\. Ht {
Deny all;
}
}
In this way, the configuration of the two sites is OK.
2. The main configuration file of nginx contains the configuration files of the two sites.
Open the nginx. conf file in the conf directory, which is easy to do. You only need to enter the following code in the HTTP {...} section:
# Configuration files containing all Virtual Hosts
Include X:/wnmp/nginx/CONF/vhosts_conf/*. conf;
In this way, the nginx multi-site configuration is ready. How can I open a browser and test it ~
Love J2EE follow Java Michael Jackson video station JSON online tools
Http://biancheng.dnbcw.info/php/339495.html pageno: 8.