Question

Installing two instances of wordpress on the same vps

Posted November 7, 2016 3.2k views
Linux BasicsUbuntuApacheWordPress

Was using the instructions from this page. Now the problem is here. I used the 1 click install for the first instance of WordPress. Now I went into mysql and created a new database. I’m using the same user “root”

1 - I’ve downloaded and put the WordPress files in /var/www/secondarysite
2 - I’ve copied the default vhost file and made a file called secondary.conf
3 - I’ve edited the secondary.conf with this:

<VirtualHost *:80>
    ServerAdmin email@email.com
    ServerName mysecondarywebsite.com
    ServerAlias www.mysecondarywebsite.com

    DocumentRoot /var/www/secondarysite
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/secondarysite>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Order allow,deny
        allow from all
    </Directory>    
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

4 - I’ve enabled the virtual host file sudo a2ensite secondary.conf
5 - I’ve restarted apache2 service sudo service apache2 reload
6 - I’ve went into the /var/www/secondarysite/wp-config.php and changed it to use the correct database, dbuser, dbpassword.

But the page is not coming up it’s redirecting to my primary domain primarydomain.com

1 comment

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

It is possible to turn your site into a multi site install and then use the Domain Mapping Plugin. This is the easy method, you just need to follow the instructions. Your users can use the same account on both sites. Depending on your setup, multi-sites can result in a major pain in the ass. However, for most people it’s just fine.

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