Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have installed nginx with ISPconfig. Everything works fine except some websites I have ported from apache server unfortunately have .php5 extension and I don't know how to make nginx to parse them. I have tried many solutions and variations, but still can't make it work.

I will paste my settings from files, and if someone had similar experience that want to share, I would be thankful.

Part of settings from files: /etc/php5/fpm/php.ini



server {
        listen 80 default_server;
        root /usr/share/nginx/html;
        index index.html index.php index.htm;
        location / {
                try_files $uri $uri/ /index.html;
location ~ \.php$ {
        #       fastcgi_split_path_info ^(.+\.php)(/.+)$;
        #       # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
        #       # With php5-cgi alone:
        #       fastcgi_pass;
        #       # With php5-fpm:
        #       fastcgi_pass unix:/var/run/php5-fpm.sock;
        #       fastcgi_index index.php;
        #       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #       include fastcgi_params;
                try_files $uri =404;
                fastcgi_pass unix:/var/run/php5-fpm.sock;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;

Vhost configuration file for specific domain that has error:

      location ~ \.php$ {
            try_files /58c4be432bbd2af65343c142b9ec45ec.htm @php;

        location @php {
            try_files $uri =404;
            include /etc/nginx/fastcgi_params;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            fastcgi_intercept_errors on;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;

/etc/php5/fpm/pool.d/www.conf has unCommented:

security.limit_extensions = .php .php3 .php4 .php5

And when someone access that .php5 page (website has over 500 backlinks to them) browser starting to download, like php-fpm is not parsing .php5 file: - - [26/Feb/2014:22:53:07 +0000] "GET /sitemap.php5 HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36" - - [26/Feb/2014:22:54:27 +0000] "GET /index.php5 HTTP/1.1" 200 71941 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0" - - [26/Feb/2014:22:56:43 +0000] "GET /sitemap.php5 HTTP/1.1" 200 71941 "-" "Mozilla/5.0 (Windows NT 6.3; WOW64; rv:27.0) Gecko/20100101 Firefox/27.0"

How can I setup nginx to parse .php5 pages like .php?

Thank you in advance.

share|improve this question
@MichaelHampton Hi, I have checked file permissions, ownership, limit extenstions, error/access logs, different location ~ \.(php|php5)$ directives, different nginx config setups, but nothing. I got every time errors for example 206, 304, 403 or just getting file to be downloaded (not parsed). Any idea what should I check? – Bex1977 Feb 28 '14 at 15:30
up vote 2 down vote accepted

If you make every line with:

      location ~ \.php$ {

look like:

      location ~ \.(php|php5)$ {

It should do what you want. Leave the @php lines alone (@php is an internal block). That regex could be shorter of course but it would be less clear.


In your location @php block pass to the socket instead of localhost:

      fastcgi_pass unix:/var/run/php5-fpm.sock;
share|improve this answer
I have tried the same :\ and I have even tried to copy the same \.php$ code and just to add the php5. I got this kind of errors (access denied): 2014/02/28 14:42:06 [error] 11553#0: *13 FastCGI sent in stderr: "Access to the script '/var/www/' has been denied (see security.limit_extensions)" while reading response header from upstream, client:, server:, request: "GET /sitemap.php5 HTTP/1.1", upstream: "fastcgi://", host: "", referrer: ""; – Bex1977 Feb 28 '14 at 15:24
p.s. After every change I restart php5-fpm and nginx to be sure..but still no progress – Bex1977 Feb 28 '14 at 15:25
THANK YOU @quadruplebucky!!! I am so happy :) it works now when I added fastcgi_pass unix:/var/run/php5-fpm.sock; you are king! – Bex1977 Feb 28 '14 at 16:38
the reason that works is because fastcgi_param (environment vars) don't survive "outside" (on the network) but are preserved when php-fpm accesses a local unix socket. – quadruplebucky Feb 28 '14 at 16:41
@quadruplebucky, I have same problem. I have raised a question here. can you please look once.… – Manish Sapkal Oct 30 '15 at 12:14

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.