1

I know, there are many questions related to this topic, but for some reason none of the other solutions worked for me. So here it goes:

When I'm accessing a subfolder in my root folder /dev/ containing PHP files, all I get is a blank white page, with no content when I look in the source.

Do you have any idea why this is happening?

Here are my configurations

/etc/php5/fpm/pool.d/www.conf

[www]                                                                                                                                                                                                                                                            
prefix = /var/log/php5-fpm/                                                                                                                                                                                                                                      
user = marian                                                                                                                                                                                                                                                    
group = marian                                                                                                                                                                                                                                                   
listen = 127.0.0.1:9000                                                                                                                                                                                                                                          
listen.backlog = 128                                                                                                                                                                                                                                             
listen.allowed_clients = 127.0.0.1                                                                                                                                                                                                                               
pm = dynamic                                                                                                                                                                                                                                                     
pm.max_children = 30                                                                                                                                                                                                                                             
pm.start_servers = 5                                                                                                                                                                                                                                             
pm.min_spare_servers = 5                                                                                                                                                                                                                                         
pm.max_spare_servers = 10                                                                                                                                                                                                                                        
pm.process_idle_timeout = 10s;                                                                                                                                                                                                                                   
pm.max_requests = 500                                                                                                                                                                                                                                            
pm.status_path = /status                                                                                                                                                                                                                                         
ping.path = /ping                                                                                                                                                                                                                                                
ping.response = pong                                                                                                                                                                                                                                             
access.log = /var/log/php5-fpm/access.log                                                                                                                                                                                                                        
access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"                                                                                                                                                                                          
slowlog = slow.log                                                                                                                                                                                                                                               
request_slowlog_timeout = 10s                                                                                                                                                                                                                                    
request_terminate_timeout = 30s                                                                                                                                                                                                                                  
rlimit_files = 131072                                                                                                                                                                                                                                            
rlimit_core = 0                                                                                                                                                                                                                                                  
chdir = /                                                                                                                                                                                                                                                        
catch_workers_output = yes                                                                                                                                                                                                                                       
env[HOSTNAME] = $HOSTNAME                                                                                                                                                                                                                                        
env[PATH] = /usr/local/bin:/usr/bin:/bin                                                                                                                                                                                                                         
env[TMP] = /tmp                                                                                                                                                                                                                                                  
env[TMPDIR] = /tmp                                                                                                                                                                                                                                               
env[TEMP] = /tmp                                                                                                                                                                                                                                                 
php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f [email protected]                                                                                                                                                                                  
php_flag[display_errors] = on                                                                                                                                                                                                                                    
php_admin_value[error_log] = /var/log/php5-fpm/error.log                                                                                                                                                                                                         
php_admin_flag[log_errors] = on

/etc/nginx/sites-available/server.com

server {                                                                                                                                                                                                                                                         
        listen 80;                                                                                                                                                                                                                                               
        root /home/marian/server.com;                                                                                                                                                                                                                           
        index index.php index.html index.htm;                                                                                                                                                                                                                    
        server_name server.com *.server.com;                                                                                                                                                                                                                   
        error_log /home/marian/server.com/error.log notice;                                                                                                                                                                                                     
        access_log /home/marian/server.com/access.log main;                                                                                                                                                                                                     
        location / {                                                                                                                                                                                                                                             
                try_files $uri $uri/ /index.php?$args;                                                                                                                                                                                                           
        }                                                                                                                                                                                                                                                        

        location ~ \.php$ {                                                                                                                                                                                                                                      
                fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;                                                                                                                                                                            
                fastcgi_param  REQUEST_URI        $request_uri;                                                                                                                                                                                                  
                fastcgi_param  DOCUMENT_URI       $document_uri;                                                                                                                                                                                                 
                fastcgi_param  DOCUMENT_ROOT      $document_root;                                                                                                                                                                                                
                fastcgi_param  SERVER_PROTOCOL    $server_protocol;                                                                                                                                                                                              
                fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;                                                                                                                                                                                                       
                fastcgi_param  SERVER_SOFTWARE    AGP;                                                                                                                                                                                                           
                fastcgi_param  REMOTE_ADDR       $remote_addr;                                                                                                                                                                                                   
                fastcgi_param  REMOTE_PORT        $remote_port;                                                                                                                                                                                                  
                fastcgi_param  SERVER_ADDR        $server_addr;                                                                                                                                                                                                  
                fastcgi_param  SERVER_PORT        $server_port;                                                                                                                                                                                                  
                fastcgi_param  SERVER_NAME        $server_name;                                                                                                                                                                                                  

                fastcgi_pass 127.0.0.1:9000;                                                                                                                                                                                                                     
                fastcgi_index  index.php;                                                                                                                                                                                                                        
                try_files $uri = /index.php?$args;                                                                                                                                                                                                               
                fastcgi_intercept_errors on;                                                                                                                                                                                                                     
        }                                                                                                                                                                                                                                                        

        location ~* \.(gif|jpg|jpeg|png|ico|wmv|3gp|avi|mpg|mpeg|mp4|flv|mp3|ogg|mid|js|css|wml|swf|woff|ttf|html|htm)$ {                                                                                                                                        
            fastcgi_hide_header Set-Cookie;                                                                                                                                                                                                                      
            gzip on;                                                                                                                                                                                                                                             
            #expires max;                                                                                                                                                                                                                                        
            #add_header Pragma public;                                                                                                                                                                                                                           
            #add_header Cache-Control "public, must-revalidate, proxy-revalidate";                                                                                                                                                                               
            #add_header Access-Control-Allow-Origin *;                                                                                                                                                                                                           
        }                                                                                                                                                                                                                                                        

        location ~ /\.ht {                                                                                                                                                                                                                                       
                deny all;                                                                                                                                                                                                                                        
        }                                                                                                                                                                                                                                                        
}

UPDATE:

The error caught in the logs is:

rewrite or internal redirection cycle while internally redirecting to "/index.php", client: <IP>, server: server.comt, request: "GET /feed/ HTTP/1.1", host: "www.server.com"

But I have no index.php in the root, just index.html and there are no errors caught in the subfolder /dev/

5
  • 1
    You have two error logs and two access logs mentioned above - you should expand your question and add any relevant content. Jun 7, 2016 at 7:58
  • I have added the error I get in the logs.
    – Marian
    Jun 7, 2016 at 8:10
  • The error log shows your request is being sent to /feed/, not /dev/. Is /dev/index.php attempting to redirect there?
    – Ryder
    Jun 7, 2016 at 10:36
  • No, it's not redirecting there.
    – Marian
    Jun 7, 2016 at 11:42
  • gzip on; on jpg, gif and other compressed format isn't desirable. Nov 20, 2018 at 23:45

1 Answer 1

1

Your try_files statement looks malformed. What's in /dev/?

When nginx receives a request, you currently have it set up to use the catch-all location / {} block. Which means if you go to

http://example.com/dev/

the webserver will try to find /dev/, /dev//, and then /dev/index.php?example_arg=0 in that order— which will be passed to the second location block.

If there is no /dev/index.php, you've explicitly told the try_files statement there to return /index.php?example_arg=0 instead— rather than a 404 or something useful.

My guess is, your top-level index.php doesn't know what to do with the arguments you've passed it and returns nothing. Hence, blank page, no foul, no error.


Post-Edit:

Troubleshooting 101

something is most likely incorrect with your php files, not the php-fpm server. I'd recommend opening a second terminal into your host, and while using

 tail -f /home/marian/server.com/access.log 

you can attempt to reach the page you're testing and identify what's going on.

2
  • Thanks, @ryder. I do have index.php in the /dev/ folder and even accessing the file directly at http://example.com/dev/index.php will still return a blank page.
    – Marian
    Jun 7, 2016 at 8:09
  • What are the PHP access log, nginx access log and error log entries for all the attempts you have made to access the site? Jun 8, 2016 at 9:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .