Rumah >pembangunan bahagian belakang >tutorial php >linux服务器上同时运行tomcat + apache
解决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教程有兴趣的朋友有所帮助。