Question
What can I do to fix error 404 page on nginx on Ubuntu 18.04?
I am attempting to switch from apache2 to nginx on Ubuntu 18.04 from the wordpress one click install. I have installed nginx and php-fpm. I did what I thought was a full conversion into nginx using the config files and then uninstalled apache2 but it seems I am missing something… this is my /etc/nginx/sites_available/default.conf, i’m not sure what else is immediately useful so if there is other info needed I can scrounge that up.
server {
root /var/www/html;
index index.php index.html index.htm;
server_name cameingle.com www.cameingle.com;
location / {
# try_files $uri $uri/ =404;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
listen [::]:443 ssl ipv6only=on; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/cameingle.com/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/cameingle.com/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.cameingle.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = cameingle.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
server_name cameingle.com www.cameingle.com;
return 404; # managed by Certbot
}
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×