9

I could not find an answer for this. Installed PHP5 + NGINX + PHP-FPM and can not execute php files, it get a "Oops! This link appears to be broken." error in CHROME. I do not have any valuable error log report, i do have a index.php in the root, tried creating a custom phpinfo.php file, neither worked.

I DO can load HTML files, but cant PHP.

Here is my local site config in NGINX:

server {
    listen       80;
    server_name  im;
    access_log /var/www/website/access.log;
    error_log /var/www/website/error.log;

    location / {
        root   /var/www/website;
        index  index.html index.htm index.php;
    }


    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  /var/www/website$fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
    }

}

Changed ownership of all the directory to www-data:www-data, made a 777 on the php file, nothing. Restarted nginx, FPM, nothing.

Help? :(

  • look in your error log – Mike Oct 17 '11 at 1:51
  • Already did, "I do not have any valuable error log report". It's completely empty. – Gabriel A. Zorrilla Oct 17 '11 at 1:53
  • You need more data to diagnose the problem. I would suggest starting by adding 'fastcgi_intercept_errors on;' to your config (if not in fastcgi_params) to log any FPM errors. Also add 'debug' to your error_log line to get a lot more detail (also check the main nginx error_log (possibly in /var/log)) . Your server_name directive looks unusual - not sure if you replaced it for this post or it actually is like that. As a general recommendation, move your root directive out of your location block. (Final (unlikely) suggestion: ensure your default server isn't serving the html pages you can see). – cyberx86 Oct 17 '11 at 2:18
9

it get a "Oops! This link appears to be broken." error in CHROME.

Chrome shows its own error page if the error page is less than 512 bytes.

I suspect that you have the following line in fastcgi_params:

fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

and if so, because the root directive is defined in location / will be never applied to location ~ \.php$, thus the SCRIPT_FILENAME becomes URI.

This can be solve by moving the root directive to the server level context:

server {
    listen       80;
    server_name  im;
    access_log /var/www/website/access.log;
    error_log /var/www/website/error.log;

    root   /var/www/website;

    location ~ \.php$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include fastcgi_params;
    }

}
| improve this answer | |
  • Bingo. Moved root the server block as suggested and worked. Thanks! – Gabriel A. Zorrilla Oct 17 '11 at 2:39
  • @quanta: Did the OP edit the config in his question? Because it's a hardcoded path it should still work perfectly fine when root directive is defined in location context. The only case where it wouldn't work was if he defined SCRIPT_FILENAME in his fastcgi_params file using $document_root and thus overriden his hardcoded one. – Martin Fjordvald Oct 17 '11 at 4:07
  • @MartinF: No, the OP didn't edit the config. You're right. I will edit my answer. – quanta Oct 17 '11 at 4:44
-3

In my case it was missing the php-zip package. To fix this, I ran:

yum install -y php-zip
systemctl restart php-fpm nginx
| improve this answer | |
  • 3
    Apparently, the cause for OP was for something else entirely. – Sven Feb 18 '19 at 18:03
  • That doesn't mean that someone who finds their way to this page with this issue will have the same cause as the OP, they may very well have the cause that wejdross did and find this answer useful. The question isn't specific to that cause, it's specific to that symptom, and obviously there's multiple causes for it, so people with different causes could end up here. – Synetech Oct 10 '19 at 21:32
-4
    fastcgi_pass unix:/var/run/php5-fpm.sock;
| improve this answer | |
  • 4
    Welcome to Server Fault! It looks like you may have the knowledge to provide good Answer here, but please consider reading How do I write a good Answer? in our help center and then revise and expand on your Answer. Your Commands/Code/Settings may technically be the solution but some explanation is welcome. Thanks in advance. – HBruijn Jul 10 '16 at 9:52
  • 4
    Also: even if that one line is what solves the problem, where does it go? The OP shows two locations. Does the line go in one? The other? Both? Please edit your answer to make it complete. – David Makogon Jul 10 '16 at 11:43

Your Answer

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

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