Nginx + Tomcat (Java) + Apache (PHP) shared 80 port

The core problem to be solved is: Use a port 80 to access the java + php runtime environment at the same time according to the domain name or subdomain name

1. Download nginx

Official website download link: http://nginx.org/en/download.html Next I will use nginx/Windows-1.16.0

nginx-1.16.0.zip The download link is as follows: https://pan.baidu.com/s/1IqL1g7134Qd4Cjoq1d4lBQ

After downloading, decompress, and decompress as follows

p>

Share pictures

2. Use of nginx< /strong>

There are many ways to start nginx

(1) Directly double-click nginx.exe in the unzipped folder , After double-clicking, a black pop-up window flashed past, proving that the startup was successful

(2) Open the cmd command window, switch to the nginx decompression directory, and enter the command nginx.exe or start nginx and press Enter;

Common commands As follows:

1. Quick stop or shutdown: nginx -s stop

2. Normally stop or close: nginx -s quit

p>

3. Configuration file modification and reload command: nginx -s reload

p>

Check if nginx is started successfully:

Enter the command in the cmd command window: tasklist /fi “imagename eq nginx.exe” The following result shows that the startup is successful

Share pictures

3.nginx proxy settings< /strong>

①Modify the configuration file to be used

..\nginx-1.16.0\conf\nginx.conf

Java

Share pictures

The code is as follows:

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-Real-IP $remote_addr;

proxy_set_header X-Forward_Forward_Forward_Forward_Forward_Forward_Forward_Forward_For x-proxy /span>

}

}

PHP

Share a picture

The code is as follows:< /p>

upstream php{

server 127.0.0.1:808 weight=1;

}

server {

listen 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;

set_header X proxy_ Forwarded-For $proxy_add_x_forwarded_for;

}

< p>

②Tomcat: ..\apache-tomcat-7.0.64\conf\server.xml

The default port is 8080

< p>③Apache: ..\Apache24\conf\httpd.conf

Listen 80 Change to Listen 808

④Hosts: C:\Windows\System32\drivers\etc\HOSTS

Add two rows of data

127.0.0.1 www.java.com

127.0.0.1 www.php.com

RestartTomcat/Apache/nginx

< strong>

Last visit:

www.java.com Will enter8080PortTomcat Environment

www.php.com will enter 808 Port Apache strong>Environment

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 4620 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.