Question

Multiple Wordpress sites on a single droplet / One site is working, second gives White screen of death Why?

Posted July 26, 2020 412 views
ApacheWordPressLAMP StackLet's EncryptUbuntu 18.04

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 :

  • Restart apache after configurations
  • enabled the .conf files with a2ensite
  • dissabled the 000-default.conf file with a2dissite

Edit: Also, when I google http://my.ip.address it redirects to https://domain1.com with white screen.

Looking forward to your answers!

edited by MattIPv4

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
3 answers

There are several missconfigurations. Is this still an active issue? If so I will move to my desktop and give you a hand.

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:

  • Download a new copy of WordPress with the wget command:
wget wordpress.org/latest.zip
  • After that extract the files
unzip latest.zip
  • Then move the files to the /var/www/ folder:
mv wordpress /var/www/your_site.com
  • Then set the owner of the file to the Apache2 user:
chown -R www-data:www-data /var/www/your_site.com
  • After that copy the existing Apache config:
sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/your_site.conf
  • Then enable the new site:
sudo a2ensite
  • Run a configtest:
sudo apachectl -t
  • If you get Syntax OK reload Apache:
sudo systemctl reload apache2
  • Then create a new MySQL database and username. To create the database first access MySQL:
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;
  • Finally, access the site via your web browser to finish the installation.

Hope that this helps.
Regards,
Bobby