nginx和apache的代理(nginx处理静态html,apache处理php)

文章转自:https://blog.csdn.net/weixin_43945743/article/details/84927318

nginx使用80端口 apache使用8080端口
nginx的安装 apache的安装 PHP的安装跳过

一、配置nginx

配置文件:/etc/nginx/sites-enabled/default

server {

        listen 80;
        server_name test.com;
        root /var/www/html;
        index index.nginx-debian.html index.htm index.php;
        location ~ \.php$ {
                proxy_pass      http://127.0.0.1:8080;      #apache服务端口
        }


}

二、配置apache

配置文件:/etc/apache2/ports.conf

# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 8080

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>

# vim: syntax=apache ts=4 sw=4 sts=4 sr noet

Llsten 80  -----改成------> Listen 8080

三、测试

在/var/www/html下创建php测试文件

vi /var/www/html/index.php

写入

<?php

phpinfo();

?>

重启nginx和apache

$ /usr/sbin/nginx -s reload
$ /etc/init.d/apache2 restart

打开浏览器输入:test.com/index.php即可看到php信息页面

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值