zoukankan      html  css  js  c++  java
  • 安装篇七:配置 Nginx 使其支持 PHP 应用

    配置说明(NGINX-PHP)

    (让nginx  php(中间件)之间建立关系):nginx--php建立关系---fastcgi---cgi

    第一个里程: 编写nginx虚拟主机配置文件

    第二个里程:重启nginx

    第三个里程:创建测试文件

    第四个里程:打开浏览器访问:http://47.108.58.170

    第一步:编写nginx虚拟主机配置文件

    [root@TEST php-7.2.29]# vim /application/nginx/conf/nginx.conf
        server {
            listen       80;
            server_name  www.test.com;
            location / {
                root   html;
                index  index.php index.html index.htm;
            }
            #location ~* .*.(php|php5)?$ {
            #    root html;
            #    fastcgi_pass  127.0.0.1:9000;
            #    fastcgi_index index.php;
            #    include fastcgi.conf;
            #}
            location ~* .php$ {
                fastcgi_index   index.php;
                fastcgi_pass    127.0.0.1:9000;
                include         fastcgi_params;
                fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
                fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;
            }
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
        }    

    第二步:重启nginx

    [root@TEST php-7.2.29]# /application/nginx/sbin/nginx -s stop
    [root@TEST php-7.2.29]# /application/nginx/sbin/nginx -t
      nginx: the configuration file /application/nginx-1.4.0/conf/nginx.conf syntax is ok
      nginx: configuration file /application/nginx-1.4.0/conf/nginx.conf test is successful
    [root@TEST php-7.2.29]# /application/nginx/sbin/nginx

    第三步:创建测试文件

    [root@TEST php-7.2.29]# mv /application/nginx/html/index.html /application/nginx/html/index.html.bak
    [root@TEST php-7.2.29]# echo "<?php phpinfo(); ?>" >> /application/nginx/html/index.php

    第四步:打开浏览器访问

    http://47.108.58.170      <——显示PHP访问首页,代表连接配置正常
  • 相关阅读:
    10 个雷人的注释,就怕你不敢用!
    Java 14 之模式匹配,非常赞的一个新特性!
    poj 3661 Running(区间dp)
    LightOJ
    hdu 5540 Secrete Master Plan(水)
    hdu 5584 LCM Walk(数学推导公式,规律)
    hdu 5583 Kingdom of Black and White(模拟,技巧)
    hdu 5578 Friendship of Frog(multiset的应用)
    hdu 5586 Sum(dp+技巧)
    hdu 5585 Numbers
  • 原文地址:https://www.cnblogs.com/l75790/p/12804345.html
Copyright © 2011-2022 走看看