Welcome! Log In Create A New Profile

Advanced

Bad NGINX config for Joomla

Posted by neihn 
Bad NGINX config for Joomla
August 10, 2019 04:33PM
Hello all,

I am needing the assistance from someone smarter then me on NGINX configurations. This is my first time doing a Joomla site with NGINX (I have done a few Wordpress sites without issue). I got NGINX installed and it works fine, joomla is installed and I can access the site but I am having issues with how the site is loading

I originally used the following code:
-------------------------------------------------------------
server {
listen 80;
listen [::]:80;
root /var/www/html/joomla;
index index.php index.html index.htm;
server_name example.com www.example.com;

client_max_body_size 100M;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
-------------------------------------------------------------
This code worked great for the front end. However the administrator page of joomla would load without any CSS formatting. The attached image is not of my site but it is the same issue.

So i searched around on the internet and I found this NGINX configuration:
-------------------------------------------------------------
server {
listen 80;
server_name localhost;

root /usr/share/nginx/html/joomla;
index index.php index.html index.htm;

location / {
if ($request_uri ~ ^/(.*)\.html$) {
return 302 /$1;
}
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}

}
-------------------------------------------------------------
This code allowed the backend to load properly however the front end would load the main page however no link worked (resulted in 404 error) until I disabled SEF URL's and then it partially worked as some parts of the theme we are trying to use requires SEF URL's otherwise they don't load properly.

I tried to add the recommended code Joomla has on their document page for enabling SEF URL's in the second configuration but it I always get 1 of 3 results.

1. No Change
2. NGINX fails to start
3. When selecting SEF enabled and applying the save results in SEF reverting back to Disabled.

For a bit more info I am running this on Ubuntu with PHP 7.2 and all changes were being made to the site file in /etc/nginx/sites-available /website

Thanks for any help you can provide
Attachments:
open | download - administrator.png (38.2 KB)
Re: Bad NGINX config for Joomla
August 10, 2019 09:28PM
I think I solved my issue. I came across a post on another site from IToctopus that discussed similar issues to mine so using the first configuration file I went into php.ini and changed the cgi.fix_pathinfo=0 (what the install guide i followed said) to cgi.fix_pathinfo=1. Upon restart of php and nginx the site appears to be functioning correctly now.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 95
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready