Is it possible to install another wordpress on droplet?

July 18, 2016 1.2k views
WordPress One-Click Install Apps

Hi,

I was wondering if I can install another wordpress site on the same droplet after the first "one-click" install (ubuntu + wp). And how to do it the easiest way.

2 Answers
ryanpq MOD July 18, 2016
Accepted Answer

It is. Here are the steps to accomplish this.

1. Create a second Database.

Connect to your droplet via ssh and use your current MySQL root password (this can be found in the MOTD displayed when you first log in via ssh and is also in /etc/motd.tail).

mysql -uroot -p

Enter your MySQL root password and then...

create database wordpress2;
CREATE USER wordpressuser2@localhost IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress2.* TO wordpressuser2@localhost;
FLUSH PRIVILEGES;
exit;

You now have a new database and a user that can access it. Hold onto that information as you will need it in the last step to complete your setup.

2. Make a new web root directory

Next you'll need to create a directory for the new site and place WordPress' files in that location.

mkdir /var/www/wordpress2;
wget https://wordpress.org/latest.tar.gz -O /tmp/wordpress.tar.gz;
tar -zxf /tmp/wordpress.tar.gz  -C /tmp;
mv -f /tmp/wordpress/* /var/www/wordpress2;
chown -Rf www-data.www-data /var/www/wordpress2;

Once we've run these commands we will have a copy of the latest version of WordPress downloaded into our /var/www/wordpress2 directory and owned by www-data.

3. Create a new VirtualHost in Apache

Next we'll need to set Apache up to serve our new site when it's domain is requested. Before we do that however, the configuration file created by the one-click will need a quick update. Open the file /etc/apache2/sites-enabled/000-default.conf and make the adjustments shown in red using your existing site's domain name in place of example.org.

<VirtualHost *:80>
        ServerAdmin webmaster@example.org
        ServerName example.org
        ServerAlias www.example.org
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Save those changes. Now create a file called /etc/apache2/sites-enabled/yoursite.conf and make it look like this (where example2.org is replaced with your new site's domain name):

<VirtualHost *:80>
        ServerAdmin webmaster@example2.org
        ServerName example2.org
        ServerAlias www.example2.org
        DocumentRoot /var/www/html

        <Directory /var/www/html/>
            Options Indexes FollowSymLinks
            AllowOverride All
            Require all granted
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Once these changes are made, restart Apache with the command:

service apache2 restart

4. Set up DNS

Now you can point your new domain name to your droplet. This guide will assist you in creating DNS records.

5. Complete setup

Now we can set up the new WordPress installation. Open a web browser and browse to your new site's domain name. You should be prompted to continue the setup of your new WordPress site. Use the database details you set up in step one above.

That's it. You now have two separate WordPress sites running on your droplet.

by Etel Sverdlov
This article walks you through setting up the DNS for your site. The tutorial includes steps to set up an A records, point your nameservers, and provides some information about MX records.
  • Wow! This is amazing, thanks Ryan! :)

  • Hey Ryanpq,
    I'm new to the DO community! I followed your steps to setup another wordpress on the same server, but when i'm visitng the second website, it is redirecting to the first one.I mean when i visit mysite2.com then it redirects me to mysite1.com. I would be glad if you could probably help me out with this and tell me what to correct!

    Thanks in advance!

    • When you have multiple virtualhosts defined Apache will first look for a match to the ServerName and ServerAlias fields. If a match is not found, apache will default to showing whichever virtualhost is loaded first (this is usually the one that is alphabetically first by filename).

      If you're having this issue the first thing to check is the ServerName and ServerAlias fields and make sure you restarted Apache after your changes.

      • Thanks. It worked!

      • hi ryanpq - I'm running into the same issue as sid431. I've checked the ServerName and Server Alias fields on both the /etc/apache2/sites-enable/000-default.conf and /etc/apache2/sites-enable/<wordpress2>.conf and they match the instructions you provided above. When I visit wordpress2 it redirects to the original wordpress1 instance.

        Can you provide any guidance on what errors we should look out for in the ServerName and ServerAlias fields? Below are my settings below for your reference

        wordpress 1(resolves)
        /etc/apache2/sites-enabled/000-default.conf
        <VirtualHost *:80>
        ServerAdmin webmaster@leagueoto.com
        ServerName leagueoto.com
        ServerAlias www.leagueoto.com
        DocumentRoot /var/www/html

            <Directory /var/www/html/>
                Options FollowSymLinks
                AllowOverride All
                Require all granted
            </Directory>
        
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
        

        </VirtualHost>

        wordpress2 (redirects to wordpress1)
        /etc/apache2/sites-enabled/d1p.co
        ServerAdmin webmaster@d1p.co
        ServerName d1p.co
        ServerAlias www.d1p.co
        DocumentRoot /var/www/html

            <Directory /var/www/html/> 
                Options FollowSymLinks
                AllowOverride All
                Require all granted
            </Directory>
        
            ErrorLog ${APACHE_LOG_DIR}/error.log
            CustomLog ${APACHE_LOG_DIR}/access.log combined
        

        </VirtualHost>

        Thanks!

Hey Ryanpq,
I'm new to the DO community! I followed your steps to setup another wordpress on the same server, but when i'm visitng the second website, it is redirecting to the first one. I would be glad if you could probably help me out with this.

Thanks in advance!

Have another answer? Share your knowledge.