Setting up a self-hosted Wordpress blog
This is a how-to guide for setting up a self-hosted WordPress on your own webserver.
Having performed this process on several different operating systems I have personally found that the process is easiest on a Linux distro - in my case I used Ubuntu Gutsy Gibbon. My personal philosophy is that open source software runs best on open source systems.
As a basic overview of what we’ll be doing, we are going to go through the process of taking a standard Linux disto and turning it into a web server that will run WordPress. This will require a few phases which involve the installation and configuration of the various components.
Ultimately you will have what is known as a LAMP stack installed on your system.
As Wikipedia explains ["LAMP (software bundle)"]:
“The acronym LAMP refers to a solution stack of software, usually free and open source software, used to run dynamic Web sites or servers. The original expansion is as follows:
- Linux, referring to the operating system;
- Apache, the Web server;
- MySQL, the database management system (or database server);
- Perl, Python, and PHP, the programming languages.[1]
The combination of these technologies is used primarily to define a web server infrastructure, define a programming paradigm of developing software, and establish a software distribution package.
Though the originators of these open source programs did not design them all to work specifically with each other, the combination has become popular because of its low acquisition cost and because of the ubiquity of its components (which come bundled with most current Linux distributions). When used in combination they represent a solution stack of technologies that support application servers.”
The ingredients:
- Ubuntu Gutsy Gibbon (version 7.10)
- Apache2 (web server)
- MySQL (database server)
- PHP (programming language)
- WordPress (blogging engine)
Now there may be ways to tackle these phases through more graphical means, however I’ve personally found use of the terminal to be the fastest, and in some cases the easiest.
Step Zero: Update the list of available packages
Start by updating the list of available packages. This is done by opening a terminal window and typing ’sudo apt-get update’. You will be asked to provide a password at which point the terminal will ensure your packages are up to date.
As explained by Debian.org (”APT HOWTO“):
“The packaging system uses a private database to keep track of which packages are installed, which are not installed and which are available for installation. The
apt-getprogram uses this database to find out how to install packages requested by the user and to find out which additional packages are needed in order for a selected package to work properly.To update this list, you would use the command
apt-get update. This command looks for the package lists in the archives found in /etc/apt/sources.list; see The /etc/apt/sources.list file, Section 2.1 for more information about this file.
It’s a good idea to run this command regularly to keep yourself and your system informed about possible package updates, particularly security updates.”
Step One: Download and Configure Apache2
Once this process has been completed it’s time to download and install the Apache2 web server software. Once again open a terminal window and enter:
sudo apt-get install apache2 libapache2-mod-php5 php5-gd
You will be told that a certain number of megabytes worth of archives must be downloaded - in my case this number was 5030kB - and asked to confirm. Type “Y” and enter and the download and installation process will begin. At the end of this process you will be returned to the prompt.
By default Apache uses Port 80, which is the standard HTTP port. If you have no other web servers in your network you can proceed to the next step. Otherwise if you have another web server using Port 80 you will need to update the PORTS.CONF file and designate another port.
To do this open a terminal window and type
sudo gedit /etc/apache2/ports.conf
After confirming the SU password the file will load and you will see only a few lines of code. The first line reads Listen 80. Change this number to another port that isn’t being used by another web server, click save and then close the document.
Once this has been done you’ll need to restart the web server by entering the following command in a terminal window:
sudo /etc/init.d/apache2 restart
Providing the server restarts correctly, if you go to http://youripaddress/apache2-default/ you should see a message on screen saying “It works!”
Step Two: Install MySQL and Create New Database
Now it’s time to install mySQL, which will provide the database for your blog. Once again, open a terminal window and type:
sudo apt-get install mysql-server php5-mysql
You will be told something to the effect of ‘Need to get 34.5 MB of archives.’ and asked to confirm the action. Type “Y” and click enter.
At this stage it’s time to create a database for your blog. Open a terminal window and enter
mysql -u root -p
and you will be prompted to enter your password. If you do not already have a password you can create one by opening a terminal window and typing
mysqladmin –u root password NewRootDatabasePassword
Here ‘NewRootDatabasePassword’ should be replaced by the password you wish to use.
Having done this type mysql -u root -p, enter your password and complete the following commands.
mysql> create database yourdbname;
Query OK, 1 row affected (0.02 sec)mysql> grant create, select, insert, update, delete, drop, alter, lock tables on yourdbname.* to ‘yourdbusername’@'localhost’ identified by ‘yourpassword’;
Query OK, 0 rows affected (0.00 sec)mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)mysql> \q
Bye
Step Three: Install and Configure WordPress
Now go to Wordpress.org, download the most recent software from the download page, and copy it to a new folder in the www root (/var/www/). Personally, I download everything to my desktop as an extra step, and then copy the folder to the webroot using the following terminal command:
sudo cp -R /home/mike/Desktop/wordpress /var/www/wpsandpit
Note: the file pathing in the above command references the user “mike”; your folder pathing will be different so be sure to confirm the location and not just copy-paste the command from here.
Once you’ve done this you’re just about finished and it’s just a matter of entering the details of the database you created in Step Two above and entering them into the wp-config.php file.
To open this file open a terminal window and type
sudo gedit /var/www/yourWPfolderName/wp-config.php
If this file comes up blank it more than likely means that the file doesn’t exist. In this case it’s easiest to copy the wp-config-sample.php file, rename it as wp-config.php, and then change the details.
WordPress.org goes into more detail about editing this file here, however the basics information needed appears at the very top of the page:
define(’DB_NAME’, ‘yourDBname’); // The name of the database
define(’DB_USER’, ‘yourDBuser’); // Your MySQL username
define(’DB_PASSWORD’, ‘yourDBpassword’); // …and password
Step Four: Create Blog
The last step in the setup process is to go to http://yourIPaddress/yourwordpressfoldername, at which point you should see a page asking for your Blog Title and email address.
File in these details and click Install WordPress and you should then see a page giving you a username and password.
It is very important that you remember this information as there is no easy way to change the admin password. When you’ve written down this information click login and then enter the same admin username and password to enter the Dashboard.
NB: If for some reason when trying to access WordPress to complete this section you receive an error message saying “Your PHP installation appears to be missing the MySQL extension which is required” there is one additional step to complete.
Open a terminal window and type the following command:
sudo gedit /etc/php5/apache2/php.ini
In the document that follows do a text search for “Dynamic Extensions”. In this section add a line that says:
extension=mysql.so
Save and close the document and then restart Apache2 by typing /etc/init.d/apache2 restart, and you should find you can continue the process.
References:
- Ubuntu website
- Apache website
- MySQL website
- PHP website
- WordPress.org
- “Installing WordPress“, wordpress.org
- “Your PHP installation appears to be missing the MySQL extension which is required“, WordPress.org Forums
- “Editing wp-config.php“, wordpress.org
- “LAMP (software bundle)“, Wikipedia, accessed 21 April 2008





June 26th, 2008 at 1:51 pm
[...] View this post here: “Setting up a self-hosted WordPress Blog” [...]
August 11th, 2008 at 8:09 am
Just what i was looking for.
Thanks mate!