One of the first “problems” that occured when starting this blog was that we are using shared hosting and our provider only permits us to have 3 databases with our current subscription.
So we use one database for the shop and another one for the blog and the last one for our test installation of Prestashop running a clone of the Givensa site for evaluation of new features.
This leaves us without databases for a new blog. There are two main options for solving this, a WordPress Network or running two WordPress blogs in one database. In this blogpost we will concentrate on the second option and give a complete tutorial with step-by-step images on:
How to install to WordPress blogs with one database
Step 1 – Check WordPress version for the existing blog
This step is more a matter of precaution. If you are on the same main installation of WordPress like v3.x it is probably safe to download any 3.x version of WordPress in step 2. However, in order to be on the safe side, I decided to download and install the exact same version for the second blog. Since the 2 WordPress blogs will share the same database it just feels safer that both installations are exactly the same.
And you will see something like this:
Step 2 – Download a specific WordPress version
If you go to you normally only find the latest official release. What we are looking for is a specific version and these can be found by clicking Download and the choose Release Archive on the left. Then you will be presented with a list of all previous WordPress releases, like this:
Choose the version your other blog used and download it.
Step 3 – Upload the WordPress files to your server via ftp
Before we can install WordPress on our server we have to upload it. We will do this with and ftp client, in our case Filezilla which is free and can be found at the Filezilla project site.
Start Filezilla, enter the username and password you have for your hosting account and login to your ftp server.
Now the first thing we need to do is to decide if the blog should go in a subdomain like blog.givensa.com or in a subfolder like givensa.com/blog. The method you choose might have some impact on SEO and there are plenty of articles on this topic on the internet so have a look around if you are unsure. In our case we will install WordPress in a subfolder of our main site. This means that no subdomain needs to be created (which might also be restricted from the hosting provider). However we need to create a subfolder inside our httpdocs folder of the main domain.
Now you need to unpack the WordPress package we downloaded previously. Normally it is enough to just double click on the downloaded file and it should unpack automatically. When you look into the folder where the WordPress package was unpacked it will look something like this image:
The final part of this step is to upload the WordPress files to the folder we just created on our ftp server. On the left side of Filezilla, select all files in the folder where WordPress was unpacked. On the right side, make sure you have entered into the folder we just created for the new blog. In our example for this blog, it looked like this:
Great, now we have WordPress uploaded to our own webserver, well done.
Step 4 – Installing WordPress
Now all we have to do is to start our favorite web browser and go to the address of our blog. In our case it is http://learning.givensa.com. You will be presented with some very basic installation questions like in this image:
Step 5 – Changing the WordPress database prefix
Now we have reached the final and only really “technical” point of this tutorial. In order to be able to use two WordPress blogs with one database you must use different indexes for the databases. The first one will probably have wp_ as default. We will choose a unique prefix for the fields we need for the new database for this blog. This will allow us to have two WordPress blogs on the same database.
This prefix is defined in a file called wp_config.php and you find it in the root folder of your newly created blog (the folder we created in step 3 above.
You can either download this file with Filezilla and edit it locally or if your hosting provider offers you a web interface with a File Manager like Plesk, you can edit this file online through the browser.
Once you have access to the file you have to locate the field $table_prefix. Change the default value wp_ to something that you think suits your blog. I have choosen lebd_ my file will look like this image:
Step 6 – Finishing
Congratulations. You have completed a full installation of a second WordPress blog sharing database with another blog.
Now you should be able to just goto the address where you installed the blog and you will see the Hello World post.