zoukankan      html  css  js  c++  java
  • Nginx 解析PHP

    配置如下:

    [root@localhost ~]$ cat /usr/local/nginx/conf/vhost/test.com.conf 
    server {
        listen 80;
        server_name www.test.com;
        index index.html index.html index.php;
        root /data/www;
    
        location ~ .php$ {
            include fastcgi_params;
            fastcgi_pass unix:/tmp/php-fcgi.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME /data/www$fastcgi_script_name;
        }
    } 

    # 关于 fastcgi_pass 配置,参考:https://segmentfault.com/q/1010000004854045
    [root@localhost ~]$ /usr/local/nginx/sbin/nginx -t            
    [root@localhost ~]$ /usr/local/nginx/sbin/nginx -s reload

    创建 php 文件:

    [root@localhost ~]$ cat /data/www/1.php
    <?php
    phpinfo();
    ?>

    测试是否解析:

    [root@localhost ~]$ curl -x 127.0.0.1:80 http://www.test.com/1.php    # 没有解析到PHP的输出情况
    <?php
    phpinfo();
    ?>
    [root@localhost ~]$ curl -x 127.0.0.1:80 http://www.test.com/1.php    # 解析到PHP的输出情况
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml"><head>
    <style type="text/css">
    body {background-color: #fff; color: #222; font-family: sans-serif;}
    ......

        

  • 相关阅读:
    记一次测试服务器被黑
    那些H5用到的技术(5)——视差滚动效果
    POJ1179 Polygon
    Cookies
    SGU167 I-country
    POJ1704
    POJ3233 Matrix Power Series
    TYVJ2002 扑克牌
    Tyvj1933绿豆蛙的归宿
    支配树学习笔记
  • 原文地址:https://www.cnblogs.com/pzk7788/p/10334392.html
Copyright © 2011-2022 走看看