Home >Backend Development >PHP Tutorial >Running tomcat + apache simultaneously on linux server

Running tomcat + apache simultaneously on linux server

WBOY
WBOYOriginal
2016-07-29 09:11:141183browse

Solve the conflict between apache listening on port 80 and nginx!

1: Install tomcat + jdk, listen to port 8080

2, install php running environment and nginx;

3: Modify nginx configuration file

vi /etc/nginx/nginx.conf

    include /etc/nginx/conf.d/*.conf;
    server {
        listen       80;
        server_name  www.91zjr.com 91zjr.com;
        error_page 404 = http://www.91zjr.com/index.html;
        access_log  /var/log/nginx/www.91zjr.com.access.log;

                 location / {
                        proxy_pass http://localhost:8080;
                        proxy_redirect  off;
                        proxy_set_header Host $host;
                        proxy_set_header X-Real-IP $remote_addr;
                        proxy_set_header X-Forwarded-For $http_x_forwarded_for;
                 }
    }
    server {
        listen       80;
        server_name  bbs.91zjr.com;

        access_log  /var/log/nginx/bbs.91zjr.com.access.log;
                proxy_set_header Host $http_host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        location ~ \.php$ {
                proxy_pass http://127.0.0.1:88;
        }
        location / {
                try_files $uri @apache;
        }
        location @apache {
                 proxy_pass http://127.0.0.1:88;
        }
    }

4: Modify the apache configuration file

vi /etc/httpd/conf/httpd.conf

Listen 88
NameVirtualHost *:88
<VirtualHost *:88>
        ServerName bbs.91zjr.com
        DocumentRoot /web/apps/bbs
        ErrorLog logs/bbs.91zjr.com-error_log
        CustomLog logs/bbs.91zjr.com-access_log combined
<IfModule mod_deflate.c>
DeflateCompressionLevel 7
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-php
AddOutputFilter DEFLATE css js html htm gif jpg png bmp php
</IfModule>
</VirtualHost>
<Directory /web/apps/bbs>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>
5: Restart nginx and httpd.

The above introduces the simultaneous running of tomcat + apache on a Linux server, including nginx configuration. I hope it will be helpful to friends who are interested in PHP tutorials.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn