HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials

HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials (http://www.howtoforge.com/forums/index.php)
-   Installation/Configuration (http://www.howtoforge.com/forums/forumdisplay.php?f=4)
-   -   ISPConfig & nginx - PHP Inside HTML Files Not Executing (http://www.howtoforge.com/forums/showthread.php?t=56156)

MainStreetJames 13th February 2012 00:39

ISPConfig & nginx - PHP Inside HTML Files Not Executing
 
Hi,
Today's my first day with ISPConfig. I'm running ISPConfig 3.0.4.2 & 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 (copied from the '\.php$' directive) to the vhost file for the site, but when I do I get a 403 error when trying to display HTML files (with or without PHP inside):

Code:

        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 site's php-fpm.d 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 did, but there are no errors related to this issue.

I've tried changing the user from nginx to apache in the site's 'Web' tab in ISPConfig, 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

falko 13th February 2012 12:30

Why don't you use the extension .php for these files instead of .html?

MainStreetJames 13th February 2012 13:08

Quote:

Originally Posted by falko (Post 273479)
Why don't you use the extension .php for these files instead of .html?

I suppose we could (which would be a lot of work changing all references to them in the site, project lists, external references, etc), but that doesn't address the server configuration issue. Most of the pages just have a few PHP variables that get expanded in place, and they'll get the PHP separated out in the future.

Since nginx is supposed to be able to handle this - and its not really a stretch to expect a web server to do this - we'd like to be able to mix PHP with HTML when necessary.

Clearly there's a setting in the current version of nginx/php-fpm that I've missed or screwed up. I doubt it's a permissions issue because the files used for testing are identical except for extension (including location, owner & group). Also, a plain HTML file (same location, owner & group) that will display properly with the default settings will generate the 403 error when the '\.html$' directive is in place.


MSJ

falko 14th February 2012 13:58

Not sure, but maybe you have to modify the mime.types file in the /etc/nginx directory.

kervin 8th May 2012 21:06

Did you ever find the solution to this problem? I'm dealing with the same issue.

The application is a CMS that was built that way, so I have to support it.

Whenever I add support for HTML I get a 500 error from my PHP scripts.

falko 9th May 2012 19:37

Do you use PHP open and close tags in your files (<?php and ?>)?

kervin 11th May 2012 20:31

Thanks. My error turned out to be related to the application itself not ISPConfig. Once that was fixed I was good to go.


All times are GMT +2. The time now is 15:23.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.