首页 > 后端开发 > php教程 > linux服务器上同时运行tomcat + apache

linux服务器上同时运行tomcat + apache

WBOY
发布: 2016-07-29 09:11:14
原创
1166 人浏览过

解决apache监听80端口与nginx冲突的问题!

1:安装tomcat + jdk,监听 8080端口

2,安装php运行环境和nginx;

3:修改nginx 配置文件

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:修改apache配置文件

vi /etc/httpd/conf/httpd.conf

Listen 88
NameVirtualHost *:88
<virtualhost>
        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>
    Options FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</directory>
登录后复制
5:重启nginx 和httpd即可。

以上就介绍了linux服务器上同时运行tomcat + apache,包括了nginx 配置方面的内容,希望对PHP教程有兴趣的朋友有所帮助。

相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板