Unable to get Wordpress to work on Apache Virtual Hosts

November 13, 2018 2.6k views
Apache WordPress Quickstart Initial Server Setup Ubuntu 18.04

I’m new to servers and Linux in general so pardon me if this is a stupid question.

I’ve been trying to host multiple Wordpress installations on a single droplet. Specifically, I want to host multiple sub-domains. Such as, www.example.com and blog.example.com. I own the domain, and I have setup A records in the DigitalOcean DNS for each of the subdomains.

Apparently Apache Virtual Hosts should let me set up multiple websites on a single server. I followed the DigitalOcean guides on setting up the Virtual Hosts to the letter, but I keep running into a certain error. That is, after I install the virtual hosts, the permalinks don’t seem to work. The website works fine as long as I keep the permalinks in the default format. But the moment I try to change to a custom permalink structure, the whole Wordpress breaks. I can still login, but all posts throw a 404 error. I’m also unable to ‘hide backend’ by changing the URL of the /wp-admin page.

I have checked the .htaccess file as well as the Apache sites-enabled/example.com.conf files to make sure everything is correct. I’m 90% sure I did this right. But I might have missed something.

I’ve attempted to setup the server twice now using the Wordpress One-click installation. I’ve attempted it again, starting from Ubuntu 18.04 and manually installing the LAMP stack, but I ran into the exact same issue. I can’t provide a website link right now because I wiped the server and did without the Virtual Hosts for now, so my website is working (albeit without any subdomains). But if it’s needed I can open a new Droplet and replicate the issue.

If anyone has any idea what is going on, I would love some help. Thanks!

TL;DR - Tried to set up Apache Virtual Hosts for subdomains, but the permalinks don’t work.

3 Answers

I managed to solve the issue. I followed a non-DigitalOcean guide. The main difference was that the new website files were stored in the /var/www/html/example.com instead of /var/www/example.com/public_html. I also didn’t have to play around with .htaccess files either.

I am not sure what caused it to work, but it works now. If anyone can explain the difference, though, that would be nice.

I tried to link the guide here, but my reply was rejected as spam. I’d say just google it.

thanks, i’m also new on this site

I actually found the specific reason why it didn’t work.

If following the digitalocean LAMP stack guide (I haven’t tested the one-click application), after installation, run the command:

sudo nano /etc/apache2/apache2.conf

Look for the section that says:

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>

and change the AllowOverride line to:

AllowOverride All

That solved my issue completely. Hope it helps for you too.

Have another answer? Share your knowledge.