Address the core problem: the use of a 80-port, simultaneous access java + php runtime environment based on domain name or subdomain
1. Download nginx
Download the official website link: http://nginx.org/en/download.html next to me nginx / Windows-1.16.0
nginx-1.16.0.zip download link below: https://pan.baidu.com/s/1IqL1g7134Qd4Cjoq1d4lBQ
After the download, unzip, unzip the following
2.nginx use
There are many ways to start nginx
(1) Double-click directly extract the folder in the nginx.exe , double-click a black pop flash, proved successful start
(2) Open the cmd command window, switch to the extracted directory nginx , enter the command nginx.exe or Start nginx , carriage return;
Common commands are as follows:
1. Quick Stop on or off: nginx -s STOP
2. Normal stop or off: nginx -s quit
3. Modify Profile reload command: Nginx -s reload
Check whether nginx started successfully:
cmd command window, enter the command: tasklist / fi "imagename EQ nginx.exe" appeared the following results illustrate successful start
3.nginx proxy settings
① use to modify configuration files
..\nginx-1.16.0\conf\nginx.conf
Java
code show as below:
upstream java{
server 127.0.0.1:8080 weight=1;
}
server {
listen 80;
server_name www.java.com;
location / {
proxy_pass http://java;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
PHP
code show as below:
upstream php{
server 127.0.0.1:808 weight=1;
}
server {
listen 80;
server_name www.php.com;
location / {
proxy_pass http://php;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
②Tomcat : ..\apache-tomcat-7.0.64\conf\server.xml
The default port is 8080
③Apache: ..\Apache24\conf\httpd.conf
Listen 80 改 Listen 808
④Hosts : C:\Windows\System32\drivers\etc\HOSTS
增加两行数据
127.0.0.1 www.java.com
127.0.0.1 www.php.com
重新启动Tomcat/Apache/nginx
最后访问:
www.java.com 会进入 8080端口的Tomcat 环境
www.php.com 会进入 808 端口的 Apache 环境