By cletusco
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
}
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Greetings!
This can be difficult to eyeball so I’m going to try my best. I think it’s this line:
try_files $uri $uri/ /index.php?q=$uri&$args;
I believe adding the $uri to the end may be breaking it. What if it were instead:
try_files $uri $uri/ /index.php?$args;
You can find more about Nginx config for Wordpress here:
https://codex.wordpress.org/Nginx
Jarland
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Scale up as you grow — whether you're running one virtual machine or ten thousand.

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.
