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

        

  • 相关阅读:
    图片延迟加载方法
    mongodb常用命令
    未知尺寸元素水平垂直居中:
    nodejs学习之加密
    nodejs学习之events的使用
    nodejs学习之events
    学习Nodejs之mysql
    PHP之几道面试题
    Jquery学习插件之手风琴
    我的第一篇博客
  • 原文地址:https://www.cnblogs.com/pzk7788/p/10334392.html
Copyright © 2011-2022 走看看