蝙蝠岛资源网 Design By www.hbtsch.com
本文实例讲述了Linux服务器下Nginx与Apache共存的实现方法。分享给大家供大家参考,具体如下:
同一个端口是不能同时有两个程序监听的。所以换个思路解决同一台服务器下某些网站运行在nginx下,某些网站运行在Apache下共存。
解决思路:
将nginx作为代理服务器和web服务器使用,nginx监听80端口,Apache监听除80以外的端口,我这暂时使用8080端口。
解决方案:
- 在Linux 一经搭建好环境 先后安装了Nginx 和Apache 由于 默认端口都是:80
- 一般客户请求的服务器端口默认为80 所以Nginx作为静态页端口设置:80;Apache设置端口为:8080(在httpd.conf 文件中修改Listen:8080)
Apache下的网站:
在nginx.conf中 添加
server { listen 80; server_name www.one.ityangs.cn one.ityangs.cn; location / { proxy_pass http://127.0.0.1:8080; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } }
在httpd.conf中 添加
<virtualhost *:8080> ServerName www.one.ityangs.cn ServerAlias www.one.ityangs.cn one.ityangs.cn DocumentRoot /www/one DirectoryIndex index.php index.html <Directory /www/one> Options +Includes +FollowSymLinks -Indexes AllowOverride All Order Deny,Allow Allow from All </Directory> </virtualhost>
Nginx下的网站:
在nginx.conf中 添加
server { listen 80; server_name two.ityangs.cn www.two.ityangs.cn; root /www/two; location /{ index index.html index.htm index.php; if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } error_page 404 /var/www/html/404.html; } location ~ \.php(.*)$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info; include fastcgi_params; } }
希望本文所述对大家Linux服务器维护有所帮助。
蝙蝠岛资源网 Design By www.hbtsch.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
蝙蝠岛资源网 Design By www.hbtsch.com
暂无Linux服务器下Nginx与Apache共存的实现方法分析的评论...
更新日志
2024年07月03日
2024年07月03日
- 魔兽世界奥格瑞玛怎么去幽暗城 奥格瑞玛去幽暗城方法介绍
- 《间谍过家家日记大作战》成就攻略一览
- 完美的音乐品质-群星《红酒杯发烧酒廊情歌》2CD[WAV]
- 群星.2011《高雄国际Hi-End音响大展纪念发烧金碟》[WAV分轨]
- 康康1999-催泪[阿尔法][WAV+CUE]
- 和守望先锋太像?《星鸣特攻》开发商:我们与众不同
- 速通玩家有福了!夏季游戏速通大会正在火热进行中
- 《使命召唤》新处决动作曝光 或联动《死侍3》?
- 《陈百强出道35周年 文质翩翩》4CD[WAV+CUE][1.8GB]
- 邓丽君《思君集》3CD[WAV+CUE][1.2GB]
- 华语流行S.H.E《12CD》2001~2010[APE+CUE][3.7GB]
- 北风之望饮品怎么调配?饮品调酒配方分享
- 原画壁纸及美图第254期,无水印可自取
- 原画壁纸及美图第255期,无水印可自取
- 群星.1991-宝丽金冬日浓情【宝丽金】【WAV+CUE】