0

I have just installed nginx and php-fpm according to this http://blog.frd.mn/install-nginx-php-fpm-mysql-and-phpmyadmin-on-os-x-mavericks-using-homebrew/ I am now visiting a php webpage and the php code is not been rendered

<?php echo 'test' ?>
2
  • What result do you get? Do the nginx error log show anything? Does something like <?php phpinfo(); ?> show anything? What does the access log for nginx show? Does view source show the actual PHP source code? Have you tried setting display_errors = 1, error_reporting = E_ALL? Commented Jul 5, 2015 at 16:12
  • It shows the actual php source code. Commented Jul 6, 2015 at 9:12

1 Answer 1

1

Your problem is related with nginx configuration not php-fpm itself.

Nginx needs to be configured to let him now what to do with each file type. 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.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/

If you want more advanced examples:

And if you are interested in a deeper learning:

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.