By Matt Porter
Hey everyone,
I’m new to Digital Ocean / VPS, and just moved from shared hosting. I’ve got a pretty decent handle over everything the last few days, but I have an odd issue I can’t solve now. I’m currently running a LEMP stack.
For whatever reason, my site.com/wordpress/wp-admin page always brings up a 404, which with my current setup redirects to site.com/oops. No other url has an issue, and I can even go to site.com/wordpress/wp-admin**.index**, but without the .index, it doesn’t work. The login by default doesn’t add index, so whenever I try to log in I get a 404.
My only guess as to what’s going on, is that I messed something up when putting Wordpress in its own directory. My setup is currently in var/www/site/public_html/wordpress/, and it’s on it’s own server block. On Shared hosting / apache, I simply had to add a bit of code to the .htaccess file, but I read with nginx I had to edit my server block within the sites-available directory. I then copied the index.php file from wordpress to the root, and added the header bit (as I’ve always done for this setup). Here’s what I found / added, is this correct?
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /var/www/anightinburlington.com/public_html;
index index.php index.html index.htm;
# Make site accessible from http://localhost/
server_name anightinburlington.com www.anightinburlington.com;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
try_files $uri /wordpress$uri/ /wordpress/index.php?q=$uri&$args;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
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!
If you’re want to serve WordPress from a subfolder, you’ll want change your Nginx configuration from:
location / {
try_files $uri /wordpress$uri/ /wordpress/index.php?q=$uri&$args;
}
to:
location /wordpress/ {
index index.php;
try_files $uri $uri/ /wordpress/index.php?q=$uri&$args;
}
Let us know how it goes!
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.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.