简体   繁体   English

使用PHP-FPM运行php脚本

[英]Run php script with PHP-FPM

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

<?php echo 'test' ?>

Your problem is related with nginx configuration not php-fpm itself. 您的问题与nginx配置有关,而不与php-fpm有关。

Nginx needs to be configured to let him now what to do with each file type. Nginx需要配置为现在让他处理每种文件类型。 By default it is throwing files as static (the result is the raw content of the file as you report). 默认情况下,它以静态方式抛出文件(结果是您报告时文件的原始内容)。

An basic example of nginx routing to set php-fpm as fast-cgi service for *.php files would be: Nginx路由将php-fpm设置为* .php文件的fast-cgi服务的基本示例是:

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

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

If you want more advanced examples: 如果您需要更高级的示例:

And if you are interested in a deeper learning: 如果您对更深入的学习感兴趣:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM