RedHat7搭建Nginx+Apache+PHP

Nginx做为前端服务器(本机IP:192.168.136.104),将访问PHP页面的动态请求转发给Apache服务器(只监听本地回环地址172.0.0.1:80)

  1. 安装Apache
    # yum -y install httpd
  2. 修改Apache默认端口为81
    # vi /etc/httpd/conf/httpd.conf
    找到"Listen 80"这行,改为 Listen 127.0.0.1:80
  3. 安装PHP
    # yum -y install php
  4. 安装PHP扩展组件(可选)
    # yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-bcmath php-mhash
  5. 设置Apache服务开机自启动
    # systemctl enable httpd
  6. 启动Apache服务
    # systemctl start httpd
  7. 添加Nginx源
    # wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
    # rpm -Uvh nginx-release-centos-7-0.el7.ngx.noarch.rpm
  8. 安装Nginx
    # yum install nginx
  9. 修改Nginx配置文件
    # vi /etc/nginx/conf.d/default.conf
    listen       192.168.136.104:;
    server_name  localhost;
    root         /var/www/html;
    index   index.html index.htm index.php;

    删除location / { ... }节点
    取消以下注释:

    location ~ \.php$ {
    proxy_pass http://127.0.0.1;
    }
  10. 设置Nginx服务开机自启动
    # systemctl enable ngnix
  11. 启动Nginx服务
    # systemctl start nginx
  12. 开通防火墙
    # firewall-cmd --permanent --add-service=http
    # firewall-cmd --reload
  13. 创建测试页面
    # vi /var/www/html/index.php
    <?php phpinfo(); ?>
  14. 测试站点
    浏览http://192.168.136.104
    RedHat7搭建Nginx+Apache+PHP
上一篇:spring的jar包的下载、说明


下一篇:Spring众多jar包的特点,及Spring jar包官网下载方法