Create and clone a WordPress site in 15 minutes

There are many posts and blogs out there about how to create and clone a WordPress site – I have used a few different methods previously.

In this post I am going to give the solution that I have found the most simple.

The only extra plug-in you are going to need is WP Clone by WP Academy as this handles all the internal name changes for your site.

This plug in requires you to have a new WordPress site set-up already, so I am first going to go through the process of creating a WordPress site from scratch.

I am also going to go through the process of how to set-up a new virtual host for your created and cloned site.

I use a GoDaddy cloud server and a GoDaddy domain, I host my WordPress instance on there so will instruct around this, but the principle will be the same for any domain service provider.

The post assumes you already have Apache, PHP and MySQL installed on your cloud server.  Another good way to set up WordPress is to use Bitnami for WordPress as this installs everything you need Apache, MySQL, PHP and a WordPress site.

Lets Begin!

Firstly I will create a new WordPress site on my current installation

Log onto your cloud server and change directory to where your applications are in my case this is a directory called ‘apps’

Make a new directory for the new website and modify permissions to the user that your FTP client uses in my case ‘bitnami’ I will call my new site ‘vanilla’

Go to https://wordpress.org/download/ and download the latest version of WordPress

Using your preferred FTP client ftp the downloaded file to your new directory on your cloud server

Unzip the file on your cloud server

I like all my WordPress files to be in the actual application directory ‘vanilla’ so I am going to move all my files from the WordPress directory into the vanilla directory and then remove the empty WordPress directory.

Create a new ‘A’ record host on your DNS provider – in my case GoDaddy

In one of your Apache configuration directories you will have an vhosts configuration file. This file should be included as part of your main Apache configuration, so check that it is called as an included file.

In the vhosts file add an entry similar to below

Now restart Apache

You need to use phpMyAdmin now to access your database – if you have not used this previously then you need to configure a tunnel via Putty.  I am not going to go into detail on these steps but your Putty tunnel settings should look similar to below

You should then be able to log into phpMyAdmin at https://127.0.0.1/phpmyadmin

Once logged in use the SQL tab to create your new WordPress database, using the below code, using your own password (remember this username and password you will need it later)

Note: 16 characters is the maximum length of a MySQL user, that is why I didn’t use the full name

You can now log onto the set-up of your site – in my case at https://vanilla.gothai.land, you will be presented with the WordPress welcome setup page below

Make sure your WordPress configuration screen looks something similar to below, replacing your password with the one when you created the database

You may get an error about wp-config.php not existing as below so we are going to create it.  Also we need to change the permissions of the WordPress directory to be the user running Apache.

Now click on ‘Run the Install’ – you will then next be prompted for your site information – I am going to use the details below, you can always change these at a later date

Click on ‘Install WordPress’ then hopefully you should receive a Success message as below

My brand new site is now accessible at https://vanilla.gothai.land/

Now we can clone our newly created site

Firstly we need to install WP Clone, login to the WordPress administrator as admin, then select ‘Add New’ from the ‘Plugins’ menu

Select ‘Install Now’ then ‘Activate’ the plug in

Next we need to copy all our web-site files to create the new site.

So logged into your cloud server via putty do the following – I am going to create a new WordPress instance called ‘sandpit’

We now need to change the permissions to be the same as the Apache owner in my case daemon

Using the same process in phpMyAdmin as you did above to create the first database you need to create a new database for the cloned site as below

Next we need to modify the wp-config.php to point to the newly created database using your password above, change to your new directory in my case ‘sandpit’ then

and change the below 3 settings

Next we need to export a full SQL script from the ‘vanilla’ (source database) modify it and import it into the ‘sandpit’ destination database.  Note: This process will change nearly everything we need but we still need to run WP Clone afterwards as there are a lot of internal changes that don’t come across using this method alone such as theme settings and more.

In phpMyAdmin export the database script, ensure that you select the source database in the left hand side database list and select the Export tab and use the default options.

Now you need to edit the downloaded file in my case ‘wordpress_van.sql’

You need to search and replace all instances of the previous website name so in my case I search for vanilla.gothai.land and replace it with sandpit.gothai.land

Save the file and then open up phpMyAdmin again and select the target database from the database list on the left hand side and then select the Import tab and choose the file that you edited.  Click Go accepting all the default options

Now we need to create a new virtual host in Apache and a new ‘A’ record host on our domain provider.

Just follow all the same steps as above when we created our initial ‘vanilla’ site. I used the following code.

For the virtual host

And for the ‘A’ record

Now restart Apache as above and our new cloned WordPress site should now be accessible on https://sandpit.gothai.land/

I always like to check I am not making changes to the original site so log onto your cloned WordPress site as admin and go to Settings -> General and modify your site title.  In my case to ‘Sandpit WordPress’ and ‘Save Changes’, you should see the name change in the top right of the screen to the new site title.

Now go back to your original site in my case https://vanilla.gothai.land and and log into the administrator page and ensure the site title in the top left is still the original name.

Your site is now almost cloned however we need to run WP Clone as some things are not picked up in this method alone such as theme settings.

You should be logged into administrator on your source WordPress instance now.  Then select WP Clone from the menu, you should see this screen

Click on create backup

Then click on ‘Copy URL’

Now log onto the administration console of your cloned site in my case ‘sandpit’ and select WP Clone from the menu, select the restore button and paste in the URL that you copied above

Select the ‘Restore from URL’ button and agree to the terms.  If everything is succesful you should see something similar to below

Congratulations you should now have a correctly cloned WordPress site running on your cloud server.

 

Paul H

IT consultant with 20+ years experience specialising in Oracle Database, Oracle Business Intelligence, Web/Mobile development, Application Express development, cloud technology and more

One thought on “Create and clone a WordPress site in 15 minutes

  1. Pingback: WordPress Create plugin Select Update Delete Loops serialize deserialize - GoThai.land

Leave a Reply

Your email address will not be published. Required fields are marked *