By bardic
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.
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!
Hi @bardic,
Let’s start going over the possibilities one by one.
/var/www/wordpress-multisite.
To do so, go to /var/www/ and executels -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?
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.
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.