I setup a WordPress multisite on Ubuntu 20.04 using Apache and I’m having trouble getting a domain pointing to the right website. I have a static html website running as well and my directory tree is as follows:

/var/www/
  site1 
  wordpress-multisite // site2 & site3

I have 3 domains with DigitalOcean: site1.com, site2.com, and site3.com. All 3 point to the droplet and site2 includes a wildcard because it’s the primary for the multisite. site1.com displays the static website which is correct. site2.com displays one of the WordPress multisite, also correct. site3.com displays the static website (site1).

I have my virtual hosts for apache2 setup within /etc/apache2/sites-available as follows:

// site1.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName site1.com
    ServerAlias www.site1.com
    DocumentRoot /var/www/site1
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =www.site1.com [OR]
RewriteCond %{SERVER_NAME} =site1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

//wordpress-multisite.conf
<VirtualHost *:80>
    ServerAdmin webmaster@localhost
    ServerName site2.com
    ServerAlias *.site2.com
    DocumentRoot /var/www/wordpress-multisite
    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =site2.com [OR]
RewriteCond %{SERVER_NAME} =www.site2.com [OR]
RewriteCond %{SERVER_NAME} =site3.com [OR]
RewriteCond %{SERVER_NAME} =www.site3.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

When this did not works I added a site3.conf and enabled it within apache with sudo a2ensite site3.conf and restarted apace, no luck.

Am I missing something with the virtual hosts? Does the Wordpress installation need to be in a html directory? It’s boggling my mind that site3.com is pointing to the wrong directory when I have it pointing to the correct one.

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.

×
Submit an Answer
2 answers

Hi @bardic,

Let’s start going over the possibilities one by one.

  • First, please confirm you have configured the proper ownership of the folder /var/www/wordpress-multisite.
    To do so, go to /var/www/ and execute

    ls -ld
    

    It should show you both your site1 and wordpress-multisite folders. Are they using the proper owernship and permissions?

  • When you try and open your website, what do you see, what error?

  • Load site2.com into your browser while at the same time following your Apache error_log

    tail -f /var/log/apache2/error_log
    

    What does it say there, are they indications of errors?

  • Last thing I can think of is to make sure the DNS of your site2 and site3 are actually pointed to your Droplet with DigitalOcean.

Regards,
KFSys

Hi,

The VirtualHost (vhost) blocks, you have already shared with us, do not catch requests for site3.com, thus, Apache uses first vhost block available, for site1.com in that case.

Let’s look at your wordpress-multisite.conf:

@bardic wrote
//wordpress-multisite.conf <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName site2.com ServerAlias *.site2.com DocumentRoot /var/www/wordpress-multisite ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined RewriteEngine on RewriteCond %{SERVER_NAME} =site2.com [OR] RewriteCond %{SERVER_NAME} =www.site2.com [OR] RewriteCond %{SERVER_NAME} =site3.com [OR] RewriteCond %{SERVER_NAME} =www.site3.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent] </VirtualHost>

This block is just for *.site2.com. Although, you extend your vhost configuration with site3.conf, there may still be something to do with your vhost blocks for SSL/TSL traffic on port 443. What I can suggest is to take a look at them.