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

        

  • 相关阅读:
    Python paramik
    JavaScript和DOM
    HTML和CSS
    salt基本使用之二(2)
    nginx+php与apache+php性能对比
    varnish状态引擎2
    varnish状态引擎1
    varnish简介
    使用memcached实现tomcat集群session共享
    php安装redis扩展连接redis服务器
  • 原文地址:https://www.cnblogs.com/pzk7788/p/10334392.html
Copyright © 2011-2022 走看看