What's new

Nginx: Unable to open primary script

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

zidler

Occasional Visitor
I spent last 48 hours without sleep trying to fight it. No luck =( Please HELP!
I swear I'm gonna personally buy beer in any bar to whomever solve this.

Technically, this is a problem of PHP-fpm server.
What I got in my log is:

Code:
2017/02/13 01:25:20 [error] 4041#0: *1 FastCGI sent in stderr: "Unable to open primary script: /opt/share/www/xxx/web/index.php (No such file or directory)" while reading response header from upstream, client: 141.39.226.225, server: xxx, request: "GET /index.php HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "xxx:81"
Code:
[me@AC5300][/opt/etc]> ls /opt/share/www/xxx/web/index.php
-rwxrwxrwx    1 nobody   nobody      1.6K Feb 12 22:21 /opt/share/www/xxx/web/index.php*
Code:
[me@AC5300][/opt/etc]> ls /opt/share/www/xxx/web
drwxrwxrwx    5 nobody   nobody      4.0K Feb 13 01:12 ./
drwxrwxrwx   10 nobody   nobody      4.0K Jan 27 03:52 ../
drwxrwxrwx    2 nobody   nobody      4.0K Aug  1  2015 css/
-rwxrwxrwx    1 nobody   nobody       902 Jan 27 02:57 favicon.ico*
-rwxrwxrwx    1 nobody   nobody       713 Jan 27 02:57 htacc*
drwxrwxrwx    3 nobody   nobody      4.0K Jan 27 02:57 images/
-rwxrwxrwx    1 nobody   nobody        10 Feb 12 21:54 index.html*
-rwxrwxrwx    1 nobody   nobody      1.6K Feb 12 22:21 index.php*
drwxrwxrwx    3 nobody   nobody      4.0K Jan 27 02:57 js/
-rwxrwxrwx    1 nobody   nobody        26 Jan 27 02:57 robots.txt*
-rwxrwxrwx    1 nobody   nobody        61 Jan 27 02:57 sfDoctrinePlugin*
-rwxrwxrwx    1 nobody   nobody        32 Jan 27 02:57 sfFormExtraPlugin*
 
Last edited:
Code:
[me@AC5300][/opt/etc]> cat /opt/etc/nginx/nginx.conf

user  nobody;

worker_processes 1;



# error_log logs/error.log;

#error_log logs/error.log notice;

#error_log logs/error.log info;

#pid logs/nginx.pid;

# access_log /opt/var/log/nginx/access.log;

# error_log /opt/var/log/nginx/error.log;



events {



   worker_connections 128;

   multi_accept        on;

}





http {

   include mime.types;

   default_type text/html;



   index  index.php index.html index.htm;

   



   server_tokens off;

   sendfile on;

   tcp_nopush on;

   tcp_nodelay on;

   keepalive_timeout 10;



   types_hash_max_size 2048;

   ##

   # File Cache Settings

   ##

   open_file_cache          max=5000  inactive=20s;

   open_file_cache_valid    30s;

   open_file_cache_min_uses 2;

   open_file_cache_errors   on;





   ##

   # Gzip Settings

   ##

   # gzip_proxied expired no-cache no-store private auth;

   gzip on;

   gzip_vary on;

   gzip_min_length 10240;

   gzip_comp_level 2;

   gzip_http_version 1.1;

   # gzip_static on;

   gzip_proxied any;

   gzip_types text/plain text/css text/javascript application/json application/x-javascript text/xml application/xml application/xml+rss;

   gzip_disable "MSIE [1-6]\.";

   gzip_buffers 16 8k;





   ssl_session_cache    shared:SSL:10m;

   ssl_session_timeout  10m;

   ssl_ciphers  HIGH:!aNULL:!MD5;

   ssl_prefer_server_ciphers on;



   fastcgi_cache_path /tmp/nginx levels=1:2 keys_zone=microcache:10m max_size=1000m inactive=60m;



   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 logs/access.log main;



   charset UTF-8;





   # fastcgi_connect_timeout 300;

   # fastcgi_send_timeout 300;

   # fastcgi_read_timeout 300;

   # fastcgi_buffer_size 32k;

   # fastcgi_buffers 4 32k;

   # fastcgi_busy_buffers_size 32k;

   # fastcgi_temp_file_write_size 32k;

   # client_body_timeout 10;

   # client_header_timeout 10;

   # send_timeout 60;

   # output_buffers 1 32k;

   # postpone_output 1460;



   fastcgi_buffer_size 128k;

   fastcgi_buffers 256 16k;

   fastcgi_busy_buffers_size 256k;

   fastcgi_temp_file_write_size 256k;



   # server {

       #     listen       81;

       #     server_name  localhost;



       #     #charset koi8-r;



       #     #access_log  /opt/var/log/nginx/host.access.log;



       #     location / {

           #         root   /opt/share/nginx/html;

           #         index  index.html index.htm;

           #     }



           #     #error_page  404              /404.html;



           #     # redirect server error pages to the static page /50x.html

           #     #

           #     error_page   500 502 503 504  /50x.html;

           #     location = /50x.html {

               #         root   html;

               #     }

               # }

               server {

                   listen 81;

                   set $host_path '/opt/share/www/xxx/web';

                   root $host_path;

                   server_name xxx;



                   # access_log /var/log/nginx/site.ru-access.log;

                   # error_log /var/log/nginx/site.ru-error.log;



                   location ~ \.php$ {

                       include fastcgi_params;

                       fastcgi_intercept_errors on;

                       

                       fastcgi_pass   127.0.0.1:9000;

                       # fastcgi_pass   unix:/var/run/php5-fpm.sock; # connect to a unix domain-socket:



                       fastcgi_index  index.php;

                       # fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;

                       # fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

                       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

                   }

                   # location = /favicon.ico {

                       #     log_not_found off;

                       #     access_log off;

                       # }

                       # location = /robots.txt {

                           #     allow all;

                           #     log_not_found off;

                           #     access_log off;

                           # }

                           # location / {

                               #     # This is cool because no php is touched for static content.

                               #     # include the "?$args" part so non-default permalinks doesn't break when using query string

                               #     try_files $uri $uri/ /index.php?$args;

                               # }

                               # location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {

                                   #     expires max;

                                   #     log_not_found off;

                                   # }

                                   # #

                                   # error_page   500 502 503 504  /50x.html;

                                   # location = /50x.html {

                                       #     root   html;

                                       # }

                                   }

                               }
 
Code:
[me@AC5300][/opt/etc]> cat /opt/etc/php5-fpm.d/www.conf


[www]


;prefix = /path/to/pools/$pool



user = nobody

group = nobody



listen = 127.0.0.1:9000




listen.owner = nobody

listen.group = nobody

listen.mode = 0777



; priority = -19




pm = dynamic




pm.max_children = 5




pm.start_servers = 2



pm.min_spare_servers = 1




pm.max_spare_servers = 3


;pm.process_idle_timeout = 10s;


;pm.max_requests = 500




;pm.status_path = /status



; The ping URI to call the monitoring page of FPM. If this value is not set, no

; URI will be recognized as a ping page. This could be used to test from outside

; that FPM is alive and responding, or to

; - create a graph of FPM availability (rrd or such);

; - remove a server from a group if it is not responding (load balancing);

; - trigger alerts for the operating team (24/7).

; Note: The value must start with a leading slash (/). The value can be

;       anything, but it may not be a good idea to use the .php extension or it

;       may conflict with a real PHP file.

; Default Value: not set

;ping.path = /ping



; This directive may be used to customize the response of a ping request. The

; response is formatted as text/plain with a 200 response code.

; Default Value: pong

;ping.response = pong



; The access log file

; Default: not set

;access.log = log/$pool.access.log



; The access log format.

; The following syntax is allowed

;  %%: the '%' character

;  %C: %CPU used by the request

;      it can accept the following format:

;      - %{user}C for user CPU only

;      - %{system}C for system CPU only

;      - %{total}C  for user + system CPU (default)

;  %d: time taken to serve the request

;      it can accept the following format:

;      - %{seconds}d (default)

;      - %{miliseconds}d

;      - %{mili}d

;      - %{microseconds}d

;      - %{micro}d

;  %e: an environment variable (same as $_ENV or $_SERVER)

;      it must be associated with embraces to specify the name of the env

;      variable. Some exemples:

;      - server specifics like: %{REQUEST_METHOD}e or %{SERVER_PROTOCOL}e

;      - HTTP headers like: %{HTTP_HOST}e or %{HTTP_USER_AGENT}e

;  %f: script filename

;  %l: content-length of the request (for POST request only)

;  %m: request method

;  %M: peak of memory allocated by PHP

;      it can accept the following format:

;      - %{bytes}M (default)

;      - %{kilobytes}M

;      - %{kilo}M

;      - %{megabytes}M

;      - %{mega}M

;  %n: pool name

;  %o: ouput header

;      it must be associated with embraces to specify the name of the header:

;      - %{Content-Type}o

;      - %{X-Powered-By}o

;      - %{Transfert-Encoding}o

;      - ....

;  %p: PID of the child that serviced the request

;  %P: PID of the parent of the child that serviced the request

;  %q: the query string

;  %Q: the '?' character if query string exists

;  %r: the request URI (without the query string, see %q and %Q)

;  %R: remote IP address

;  %s: status (response code)

;  %t: server time the request was received

;      it can accept a strftime(3) format:

;      %d/%b/%Y:%H:%M:%S %z (default)

;  %T: time the log has been written (the request has finished)

;      it can accept a strftime(3) format:

;      %d/%b/%Y:%H:%M:%S %z (default)

;  %u: remote user

;

; Default: "%R - %u %t \"%m %r\" %s"

;access.format = "%R - %u %t \"%m %r%Q%q\" %s %f %{mili}d %{kilo}M %C%%"



; The log file for slow requests

; Default Value: not set

; Note: slowlog is mandatory if request_slowlog_timeout is set

;slowlog = log/$pool.log.slow



; The timeout for serving a single request after which a PHP backtrace will be

; dumped to the 'slowlog' file. A value of '0s' means 'off'.

; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)

; Default Value: 0

;request_slowlog_timeout = 0



; The timeout for serving a single request after which the worker process will

; be killed. This option should be used when the 'max_execution_time' ini option

; does not stop script execution for some reason. A value of '0' means 'off'.

; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)

; Default Value: 0

;request_terminate_timeout = 0



; Set open file descriptor rlimit.

; Default Value: system defined value

;rlimit_files = 1024



; Set max core size rlimit.

; Possible Values: 'unlimited' or an integer greater or equal to 0

; Default Value: system defined value

;rlimit_core = 0



; Chroot to this directory at the start. This value must be defined as an

; absolute path. When this value is not set, chroot is not used.

; Note: you can prefix with '$prefix' to chroot to the pool prefix or one

; of its subdirectories. If the pool prefix is not set, the global prefix

; will be used instead.

; Note: chrooting is a great security feature and should be used whenever

;       possible. However, all PHP paths will be relative to the chroot

;       (error_log, sessions.save_path, ...).

; Default Value: not set

;chroot =



; Chdir to this directory at the start.

; Note: relative path can be used.

; Default Value: current directory or / when chroot

chdir = /



; Redirect worker stdout and stderr into main error log. If not set, stdout and

; stderr will be redirected to /dev/null according to FastCGI specs.

; Note: on highloaded environement, this can cause some delay in the page

; process time (several ms).

; Default Value: no

;catch_workers_output = yes



; Limits the extensions of the main script FPM will allow to parse. This can

; prevent configuration mistakes on the web server side. You should only limit

; FPM to .php extensions to prevent malicious users to use other extensions to

; exectute php code.

; Note: set an empty value to allow all extensions.

; Default Value: .php

;security.limit_extensions = .php .php3 .php4 .php5



; Pass environment variables like LD_LIBRARY_PATH. All $VARIABLEs are taken from

; the current environment.

; Default Value: clean env

;env[HOSTNAME] = $HOSTNAME

;env[PATH] = /usr/local/bin:/usr/bin:/bin

;env[TMP] = /tmp

;env[TMPDIR] = /tmp

;env[TEMP] = /tmp



; Additional php.ini defines, specific to this pool of workers. These settings

; overwrite the values previously defined in the php.ini. The directives are the

; same as the PHP SAPI:

;   php_value/php_flag             - you can set classic ini defines which can

;                                    be overwritten from PHP call 'ini_set'.

;   php_admin_value/php_admin_flag - these directives won't be overwritten by

;                                     PHP call 'ini_set'

; For php_*flag, valid values are on, off, 1, 0, true, false, yes or no.



; Defining 'extension' will load the corresponding shared extension from

; extension_dir. Defining 'disable_functions' or 'disable_classes' will not

; overwrite previously defined php.ini values, but will append the new value

; instead.



; Note: path INI options can be relative and will be expanded with the prefix

; (pool, global or /usr)



; Default Value: nothing is defined by default except the values in php.ini and

;                specified at startup with the -d argument

;php_admin_value[sendmail_path] = /usr/sbin/sendmail -t -i -f www@my.domain.com

;php_flag[display_errors] = off

;php_admin_value[error_log] = /var/log/fpm-php.www.log

;php_admin_flag[log_errors] = on

;php_admin_value[memory_limit] = 32M
 
I've done
Code:
[me@AC5300][/opt/etc]> chown nobody:nobody -R /opt/share/www/xxx/
[me@AC5300][/opt/etc]> chmod -R 777 /opt/share/www/xxx/

Code:
[me@AC5300][/opt/etc]> namei -om  /opt/share/www/xxx/
f: /opt/share/www/xxx/
 drwxr-xr-x me     root   /
 lrwxrwxrwx me     root   opt -> tmp/opt
   drwxrwxrwx me     root   tmp
   drwxr-xr-x me     root   opt
 drwxr-xr-x me     root   share
 drwxrwxrwx me     root   www
 drwxrwxrwx nobody nobody xxx
Code:
[me@AC5300][/opt/etc]> stat /opt/share/www/xxx/web/index.php
  File: '/opt/share/www/xxx/web/index.php'
  Size: 1604          Blocks: 8          IO Block: 4096   regular file
Device: 801h/2049d    Inode: 172629      Links: 1
Access: (0777/-rwxrwxrwx)  Uid: (65534/  nobody)   Gid: (65534/  nobody)
Access: 2017-02-12 22:21:29.000000000 +0000
Modify: 2017-02-12 22:21:36.000000000 +0000
Change: 2017-02-13 01:41:48.000000000 +0000
 Birth: -

Same output in the log file. =((((
 
Similar threads
Thread starter Title Forum Replies Date
M Unable to enable Ethernet Backhaul in XT12 ASUS Wireless 2

Similar threads

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top