Solved Joomla3 and nginx

Hello,

I am trying to setup joomla3 with nginx in a jail. I keep getting an error in nginx log
Code:
 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

I have verified that php-fpm is serving correctly with right permissions
Code:
# ls -la /var/run/php-fpm.sock
srw-rw----  1 www  www  0 Feb 18 19:36 /var/run/php-fpm.sock

Here is my nginx.conf
Code:
load_module /usr/local/libexec/nginx/ngx_mail_module.so;
load_module /usr/local/libexec/nginx/ngx_stream_module.so;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
      
    keepalive_timeout  65;
   
    server {
        listen       80;
        server_name  localhost;
              
        location / {
            root   /usr/local/www/joomla3;
            index  index.php index.html index.htm;
        }
       
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
    }
}
      
        location ~ \.php$ {
           
            fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
   }
}

Any idea what could be wrong?
 
I believe that nginx is by default working under nobody user so you have to adjust php-fpm pool settings accordingly.

My settings are as follows:

/usr/local/etc/php-fpm.conf
Code:
[global]
pid = run/php-fpm.pid
include=/usr/local/etc/php-fpm.d/*.conf

/usr/local/etc/php-fpm.d/pollname.conf
Code:
[POOLNAME]
user = USER
group = USER
listen = /var/run/$pool
listen.owner = nobody
listen.group = nobody
listen.mode = 0660
...

there's more but those are basic "permission related settings" you may look into.

Note that you need to restart php-fpm service afterwards.
 
I believe that nginx is by default working under nobody user so you have to adjust php-fpm pool settings accordingly.

On my system nginx seems to be running under user 'www'. ps shows:
Code:
root  31185  0.0  0.0   29640   5748  -  IsJ  20:23   0:00.00 nginx: master process /usr/local/sbin/nginx
www   31186  0.0  0.0   29640   6216  -  IJ   20:23   0:00.00 nginx: worker process (nginx)
root  31990  0.0  0.0   84636   7432  -  SsJ  20:29   0:00.99 php-fpm: master process (/usr/local/etc/php-fpm.conf) (php-fpm)
www   31991  0.0  0.0   84636   7440  -  IJ   20:29   0:00.00 php-fpm: pool www (php-fpm)
www   31992  0.0  0.0   84636   7440  -  IJ   20:29   0:00.00 php-fpm: pool www (php-fpm)

I have accordingly changed php-fpm.conf for www
Code:
[www]
user = www
group = www
listen = /var/run/php-fpm.sock
listen.mode = 0660
 
Solved. The following file worked:
Code:
load_module /usr/local/libexec/nginx/ngx_mail_module.so;
load_module /usr/local/libexec/nginx/ngx_stream_module.so;
user  www;
worker_processes  1;
events {
    worker_connections  1024;
}
http {
    include       mime.types;
    default_type  application/octet-stream;
    sendfile        on;
     
    keepalive_timeout  65;
   
    server {
        listen       80;
        server_name  localhost;
             
            root   /usr/local/www/joomla3;
            index  index.php index.html index.htm;
       
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   /usr/local/www/nginx-dist;
        }
     
        location ~ \.php$ {
           
            fastcgi_pass unix:/var/run/php-fpm.sock;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
}
}
 
Back
Top