解决思路:

将nginx作为代理服务器和web服务器使用,nginx监听80端口,Apache监听除80以外的端口,我这暂时使用8080端口。

nginx.conf 位置:/etc/nginx/nginx.conf

在nginx.conf中 http {}内添加:

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

重启nginx

将apache的配置文件ports.conf 中listen的端口号改为8080;

将apache的域名配置文件中端口号改为8080

重启apache

下面的我没有测试

Nginx下的网站:

在nginx.conf中 http {}添加

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

转载自:https://blog.csdn.net/ITYang_/article/details/53907937

最新文章

  1. js常用字符串处理方法
  2. node.js + webstorm :配置开发环境
  3. 【jackson 异常】com.fasterxml.jackson.databind.JsonMappingException异常处理
  4. js web实现移动端触控
  5. Volley框架的使用
  6. 扩展Smack Message
  7. 将PDM文件导出成CHM帮助文件
  8. hbase shell中log4j重复问题
  9. Game shader or System shader is busy ::VS CSG
  10. C#委托及事件
  11. Android SDK开发包国内下载地址(转)
  12. asp.net core 今日所得
  13. bootstrap全局样式二
  14. linux 的基本操作(编写shell 脚本)
  15. notepad++添加Compare插件
  16. js 判断js函数,变量是否存在
  17. MySQL 第七篇:视图、触发器、事务、存储过程、函数
  18. 【译】第六篇 SQL Server代理深入作业步骤工作流
  19. C#用正则表达式一键Unicode转UTF8(解决LitJson中文问题)
  20. Centos7.2部署saltstack

热门文章

  1. SpringMVC与Struts不同(五)
  2. 数组Array的一些方法
  3. 【转】linux的特殊符号与正则表达式
  4. python将图片转换为Framebuffer裸数据格式(终端显示图片)【转】
  5. The videobuf2 API【转】
  6. ubuntu cron 及 crontab 自动执行任务
  7. awk对列/行进行统计求和【转】
  8. 使用Eclipse创建Web Services
  9. 轻量架构ShuffleNet V2:从理论复杂度到实用设计准则
  10. CentOS切换为iptables防火墙并进行相关配置