使用php-FPM运行php脚本


Run php script with PHP-FPM

我刚刚根据这个安装了nginx和php-fpmhttp://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/我现在正在访问一个php网页,并且php代码尚未呈现

<?php echo 'test' ?>

您的问题与nginx配置有关,而不是php-fpm本身。

Nginx需要进行配置,让他现在可以处理每种文件类型。默认情况下,它将文件作为静态抛出(结果是报告时文件的原始内容(。

nginx路由将php-fpm设置为*.php文件的快速cgi服务的一个基本示例是:

nginx.conf

server {
         ....
 location ~ '.php$ {
 try_files $uri =404;
       fastcgi_pass unix:/var/run/php5-fpm/DOMAINNAME.socket;
       fastcgi_index index.php;
       include /etc/nginx/fastcgi_params;
 }
}

查看以下基本示例:https://support.rackspace.com/how-to/install-nginx-and-php-fpm-running-on-unix-file-sockets/

如果你想要更高级的例子:

  • 这个用于Symfony的nginx.conf(app.php是Symfony2引导文件(。https://gist.github.com/leon/3019026

  • 流明用例。https://gist.github.com/psgganesh/8d1790dd0c16ab5a4cde

如果你对更深入的学习感兴趣:

  • 地点的Nginx文件:http://nginx.org/en/docs/http/ngx_http_core_module.html#location