1

Problem

I have a small web server that hosts a small PHP page that performs a very small function. I used to host this on another machine. I move the website to a new machine with a different operating system, and now, the PHP page does not load for anyone viewing the site. It appears to be down from the outside. Other pages on the site are accessible.

What is it

  • Red Hat Enterprise Linux Server release 7.2 (Maipo)
  • nginx version: nginx/1.6.3
  • PHP 5.4.16 (fpm-fcgi)

Is it SELinux?

This was my first thought. I checked to make sure the proper context was applied to my web server. All server blocks are under /var/www/ to trick SELinux into treating them like Apache.

I tried turning off SELinux with setenforce 0 to test if this was the issue. There was no change, and I turned it back on.

php-fpm

I installed php-fpm via yum.

php.ini

I followed documentation and changed the cgi.fix_pathinfo setting to 0 in my php.ini file. It looks as follows.

cgi.fix_pathinfo=0

php-fpm.conf

As per online documentation, I made sure the /etc/php-fpm.d/*.conf directory is included with the php-fpm installation. Daemonizing is also set to false.

include=/etc/php-fpm.d/*.conf
daemonize = no

www.conf

I also followed online documentation for creating the php-fpm socket. My changes to the configuration file are as follows.

listen = /var/run/php-fpm/php-fpm.sock
listen.owner = nginx
listen.group = nginx
listen.mode = 0660

Logs

The error logs from /var/log/php-fpm/error.log has been less than helpful.

[30-Jan-2016 01:24:56] NOTICE: fpm is running, pid 29692
[30-Jan-2016 01:24:56] NOTICE: ready to handle connections
[30-Jan-2016 01:24:56] NOTICE: systemd monitor interval set to 10000ms
[30-Jan-2016 01:44:31] NOTICE: Terminating ...
[30-Jan-2016 01:44:31] NOTICE: exiting, bye-bye!
[30-Jan-2016 01:44:31] NOTICE: fpm is running, pid 30102
[30-Jan-2016 01:44:31] NOTICE: ready to handle connections
[30-Jan-2016 01:44:31] NOTICE: systemd monitor interval set to 10000ms

nginx

I also followed the nginx configuration per the same guide. Additionally, I am able to confirm that nginx is able to server PHP pages with a test page with <?php phpinfo(); ?>. Information about my PHP installation appears as expected.

My server block for the problem site is as follows.

server {
    listen       443 ssl;
    server_name  example.com;
    root         /var/www/rit.j-f.co/public_html;
    index        index.php index.html index.htm;
    access_log   /var/www/rit.j-f.co/logs/rit.j-f.co_access.log;
    error_log    /var/www/rit.j-f.co/logs/rit.j-f.co_error.log error;

    ssl                 on;
    ssl_certificate     /etc/ssl/certs/rit_j-f_co/rit_j-f_co-fullchain.pem;
    ssl_certificate_key /etc/ssl/certs/rit_j-f_co/rit_j-f_co-privkey.pem;
    ssl_protocols       TLSv1 TLSv1.1 TLSv1.2;
    ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
    ssl_prefer_server_ciphers on;

    location / {
        try_files $uri $uri/ =404;
        server_tokens off;
    }

    location ~ \.php$ {
        try_files          $uri =404;
        fastcgi_pass       unix:/var/run/php-fpm/php-fpm.sock;
        fastcgi_index      index.php;
        fastcgi_read_timeout 120;
        fastcgi_param      SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include            fastcgi_params;
    }

    error_page 404 /var/www/html/404.html;
    error_page 500 502 503 504 /var/www/html/50x.html;

    location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
        expires max;
        log_not_found off;
    }

    location ~ /\. {
        access_log off;
        log_not_found off;
        deny all;
    }
}

server {
    listen      80;
    server_name example.com;
    rewrite     ^   https://$server_name$request_uri? permanent;
}

Logs

The error logs from the server block have also been less than helpful. They only contained trivial errors about a missing page (something I was able to fix on my own).

Test Case

The site I am trying to test can be found here. You can see a working page on the same site here. The homepage uses PHP, the second page does not. The source code for the website can be found here.

Removing the following lines of PHP in the index.php makes the page look like this.

I have been doing my best to keep patient and try to find a solution on my own, but I cannot figure out where to go from here. I feel like I've tried everything obvious and the logs are not helping me. Any advice?

  • This is probably a silly question, but you have changed the server_name from example.com to your domain name right? I ask because you haven't taken out anything else that identifies your server, and it seems strange that you'd have changed that one thing and posted a link to the site. That URL never returns. Can you put a phpinfo file in to the web server root and the testing directory? – Tim Jan 30 '16 at 19:59
  • I eventually got a 404 not found error on that URL, but it took a long time to return webpagetest.org/result/… – Tim Jan 30 '16 at 20:21
  • @Tim Yeah, I did change it from the actual address. The link to the page was a less obvious nod to what the address is. Anyways, I do have a phpinfo file on the server, and you can find it here. Also, the 404 errors just started popping up for me too. I originally had it at the root domain, but I moved the PHP files to the testing/ directory, and made the root page just raw HTML. After I did that, I started getting the 404 error too. – Justin W. Flory Jan 30 '16 at 23:15
  • My best guess is the problem is with whatever PHP you're running, or a system that the PHP code depends on. Look at the application log files. – Tim Jan 31 '16 at 0:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.