0

I just finished setting up a centos 7 server. I have installed PHP 7 with both nginx and apache. I am switching between them on demand for testing.

When I use apache, everything runs ok.

When I use nginx, all static content also works ok.

When trying PHP, all small content works ok. When there is some large content, like the output of phpinfo() or a big SQL SELECT, the script fails without any error (browser says no data).

I checked nginx log and it says some open() to php-fpm failed because of access denied, but I do not see any error, both processes run with the same uid (apache).

Could it be some timeout issue? If not, what else? Configurations added (example.com is the server)

nginx.conf

user apache;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    index index.php index.html index.htm;
    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

    server {
        listen       80 default_server;
        # listen       [::]:80 default_server;
        server_name  examplecom www.examplecom;
        root         /var/www/example.com/;


        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
        }

        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;
        }       


        error_page 404 /404.html;
            location = /40x.html {
        }

        error_page 500 502 503 504 /50x.html;
            location = /50x.html {
        }
    }

nginx error log

2017/01/07 15:15:38 [crit] 5343#0: *60 open() "/var/lib/nginx/tmp/fastcgi/1/01/0000000011" failed (13: Permission denied) while reading upstream, client: 176.92.90.252, server: example.com, req
uest: "GET /adminer.php?sqlite=.... HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "example.com", referrer: "https://www.example.com/adminer.php?...."

php-fpm configuration unaltered (/etc/php-fpm.conf and /etc/php-fpm.d/www.conf unchanged).

Thanks.

5
  • 1
    You should really give is the full text of the error message - describing it doesn't really help. Take a look for SELinux related AVC denials in /var/log/audit/audit.log.
    – user9517
    Jan 7, 2017 at 20:26
  • 1
    Provide configuration file excerpts, log file entries etc.
    – Sven
    Jan 7, 2017 at 20:26
  • Added configuration and log Jan 7, 2017 at 20:39
  • Is selinux enabled? Anything related to it in the logs, as hanging in asked? Jan 8, 2017 at 6:43
  • @GeraldSchneider no,it is disabled. Jan 8, 2017 at 8:43

1 Answer 1

1

Since you are running your nginx as user apache, you do not have access to /var/lib/nginx/ which has 0700 access rights and is owned by user nginx.

So best would be to run nginx as user nginx again and alter access rights of your www root accordingly. Otherwise you would have to change the owner of /var/lib/nginx which could be overwritten by an update and it just feels wrong.

1
  • Thanks a lot. It was weird that it worked on small php outputs though. Jan 8, 2017 at 14:12

You must log in to answer this question.

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