By memolee
System information: LAMP installed on Ubuntu 18.04
I have two WordPress websites on Digital Ocean droplet, let’s say domain1 and domain2. I set up 2 virtual hosts. My domain2 located on /var/www/domain2 works fine but
domain1 is redirecting to /var/www/html instead of /var/www/domain1. Besides this, when I copy all files of domain1 to /var/www/html for testing purposes and hit to domain1, it’s giving white screen of death. **Additionally: ** When I put a basic index.html file, it shows properly. But still, it shows the index.html file of /var/www/html
Let’s encrypt already installed for both domains.
Here the contents of relevant files:
/etc/apache2/sites-available/domain1.conf :
UseCanonicalName On
<VirtualHost *:80>
ServerAdmin domain1@gmail.com
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/domain1
<Directory /var/www/domain1/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain1.com [OR]
RewriteCond %{SERVER_NAME} =www.domain1.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
/etc/apache2/sites-available/domain2.conf :
UseCanonicalName On
<VirtualHost *:80>
ServerAdmin domain2@gmail.com
ServerName domain2.co
ServerAlias www.domain2.com
DocumentRoot /var/www/domain2
<Directory /var/www/domain2/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =domain2.com [OR]
RewriteCond %{SERVER_NAME} =www.domain2.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>
There is a -le-ssl.conf file for domain2 (coming from let’s encrypt). Strangely there is no this kind of file for domain1. I copied and renamed and configured for domain1 but still no luck.
/etc/apache2/sites-available/domain2-le-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerAdmin domain2@gmail.com
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/domain2
<Directory /var/www/domain2/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/domain2/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain2/privkey.pem
</VirtualHost>
</IfModule>
Finally, .htaccess file which is the same for both of websites :
.htaccess:
# BEGIN WordPress
# The directives (lines) between `BEGIN WordPress` and `END WordPress` are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
I did these if you ask :
Edit: Also, when I google http://my.ip.address it redirects to https://domain1.com with white screen.
Looking forward to your answers!
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 there,
You could follow the steps from this video on how to host multiple WordPress websites on the same server with Apache Virtual Hosts:
Essentially, what needs to happen is:
wget command:wget wordpress.org/latest.zip
unzip latest.zip
/var/www/ folder:mv wordpress /var/www/your_site.com
chown -R www-data:www-data /var/www/your_site.com
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/your_site.conf
sudo a2ensite
sudo apachectl -t
Syntax OK reload Apache:sudo systemctl reload apache2
mysql
Then run the following queries:
CREATE DATABASE wp_site;
CREATE USER 'wp_site'@'%' IDENTIFIED BY 'use_secure_password_here';
GRANT ALL PRIVILEGES ON wp_site.* TO 'wp_site'@'%' WITH GREANT OPTION;
Hope that this helps. Regards, Bobby
This comment has been deleted
There are several missconfigurations. Is this still an active issue? If so I will move to my desktop and give you a hand.
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.