Welcome! Log In Create A New Profile

Advanced

PHP Inside HTML Files Not Executing

Posted by MainStreetJames 
PHP Inside HTML Files Not Executing
February 12, 2012 12:14PM
Hi,
Today's my first day with nginx. I'm running nginx 1.0.12 on CentOS 6.2.

I am able to display HTML pages, and PHP pages, but any PHP inside of an HTML page does not execute. I realize that mixing PHP inside the HTML isn't optimal use of nginx, but I need the code to work until I get a chance to separate everything.

I've tried adding the following to the vhost file for the site (copied from the '\.php$' directive), but when I do I get a 403 error when trying to display HTML files (with or without PHP inside):

location ~ \.html$ {
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass 127.0.0.1:9011;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_intercept_errors on;
}

I've also tried adding the following to the /etc/php-fpm.conf file, but it doesn't seem to make a difference:
security.limit_extensions = .php .html

I've checked the error logs in /var/log/nginx, /var/log/php-fpm & the site's log directory did, but there are no errors related to this issue.

I've tried changing the user from nginx to apache, but I still get the 403 error when the '~ \.html$' directive is in the vghost file. When I remove that directive the HTML files display properly, but the PHP inside is not executed.

Any help would be greatly appreciated.


Thanks,
MSJ
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 145
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready