D
D
Dmitry Salodki2013-12-03 11:08:40
PHP
Dmitry Salodki, 2013-12-03 11:08:40

nginx+php-fpm (chroot). Why is no input file specified?

OS: Centos
PHP: 5.5.6
Nginx: 1.4.4
Nginx vhost conf

server {
  listen 80;
  server_name example.ltd;

    root /srv/example.ltd/www;
    index index.php;
    access_log /srv/example.ltd/logs/nginx-main.log	main;
    error_log /srv/example.ltd/logs/nginx-error.log	warn;
    
    autoindex on;
    
  location / {
    try_files $uri $uri/ /index.php;
  }
    
  location ~ \.php$ {
    
  fastcgi_pass unix:/srv/example.ltd/tmp/example.ltd.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_NAME /www$fastcgi_script_name;
        fastcgi_param PATH_INFO $fastcgi_path_info;
    fastcgi_param SERVER_NAME $host;
        fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
        include fastcgi_params;
  }
}

php fpm pool config
[example.ltd]
    listen = /srv/example.ltd/tmp/example.ltd.sock
    listen.allowed_clients = 127.0.0.1
    listen.owner = example.ltd
    listen.group = example.ltd
    listen.mode = 0660
    user = example.ltd
    group = example.ltd
    pm = dynamic
    pm.max_children = 50
    pm.start_servers = 5
    pm.min_spare_servers = 5
    pm.max_spare_servers = 35
    pm.max_requests = 50
    request_slowlog_timeout = 60
    chroot = /srv/example.ltd
    chdir = /www
    catch_workers_output = yes
    security.limit_extensions = .php .php3 .php4 .php5
    env[HOSTNAME] = example.ltd
    env[TMP] = /srv/example.ltd/tmp
    env[TMPDIR] = /srv/example.ltd/tmp
    env[TEMP] = /srv/example.ltd/tmp
    php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i [email protected]
    php_admin_value[error_log] = /srv/example.ltd/logs/php-fpm-error.log
    slowlog = /srv/example.ltd/logs/php-fpm-slow.log
    php_admin_flag[log_errors] = on
    php_flag[display_errors] = on
    php_value[session.save_handler] = files
    php_value[session.save_path] = /srv/example.ltd/sessions
    php_value[soap.wsdl_cache_dir] = /srv/example.ltd/wsdlcache
    php_admin_value[disable_functions] = dl,exec,passthru,shell_exec,system,proc_open,popen,curl_exec,curl_multi_exec
    php_admin_value[open_basedir] = /srv/example.ltd:/usr/share/nginx/html

ls -la from /srv
drwxrwx--- 8 example.ltd example.ltd 4096 Dec 2 11:57 example.ltd
ps aux | grep example.ltd
500 23102 0.0 2.7 702936 7304 ? S 13:38 0:00 php-fpm: pool example.ltd
500 23103 0.0 2.7 702936 7308 ? S 13:38 0:00 php-fpm: pool example.ltd
500 23104 0.0 2.7 702936 7304 ? S 13:38 0:00 php-fpm: pool example.ltd
500 23105 0.0 2.7 702936 7304 ? S 13:38 0:00 php-fpm: pool example.ltd
500 23106 0.0 2.7 702936 7340 ? S 13:38 0:00 php-fpm: pool example.ltd

id example.ltd
uid=500(example.ltd) gid=500(example.ltd) groups=500(example.ltd),499(nginx)

nginx id
uid=498(nginx) gid=499(nginx) groups=499(nginx),500(example.ltd)

We get an error:
Unable to open primary script: /www/index.php (No such file or directory)

I also tried the changes for the nginx virtual host found on the Internet
fastcgi_param SCRIPT_FILENAME /www$fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
    fastcgi_param SCRIPT_FILENAME www$fastcgi_script_name;

But nothing helps :(
Unable to open primary script: /index.php (No such file or directory)

nginx gives statics fine
**what am I doing wrong?**

Answer the question

In order to leave comments, you need to log in

4 answer(s)
P
papahoolio, 2013-12-03
@dimedr

According to the config, everything should work. Well, at first glance. Alternatively, I can suggest doing

strace -e trace=open, read, close, connect  -p <pid>

pid is php-fpm, which it is desirable to raise with pm = static, so that it is easier to find the process, or hang strace on each child
and you will already see what he is trying to open

W
Walt Disney, 2013-12-03
@ruFelix

Controversy:
root /srv/example.ltd/www;
fastcgi_param SCRIPT_NAME /www$fastcgi_script_name;
you should be like:
fastcgi_param SCRIPT_NAME /srv/example.ltd/www$fastcgi_script_name;

K
kenny_opennix, 2013-12-03
@kenny_opennix

in location /
must be added root /srv/example.ltd/www;
to location ~ \.php$
If it does not help, tell me what kind of cms.

A
Alexey Sundukov, 2013-12-03
@alekciy

but then there was no access to ../logs ../tmp and it was needed,

In the case of a chroot, the logs and tmp folders are created inside the chroot. Actually, this is also the idea of ​​chroot, to close in a certain directory.
If desired, you can take the logs out of bounds via nginx error_log (because it is not in the chroot) via stderr.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question