How to build a Linux Server and Install WordPress
30 January 2009 in LinuxI recently finished migrating my blog to WordPress on a new server I built. I figured I would put up a how to document for anyone else who would like to try it. In this we will be using Ubuntu 8.10 Server.
First thing you need to do is to download Ubuntu Server which you can get from here. Once you get it downloaded, burn it to a CD. I use cdburn.exe from the Microsoft Resource Kit Tools which you can get here. Once you install that, run cdburn d: ubuntu.iso where d is the letter of your burner and ubuntu is the location and name of your ISO.
Now, toss the cd you just made into your new machine and boot to it. Answer all the questions accordingly. When it gets to the screen with the packages, I only install SSH. Also, make sure that you configure it for Static IP and remember what that IP is.
Now, when the box reboots you should be able to SSH to it so you can throw it in the DataCenter (closet) and you shouldn’t need to touch it again. You can also finish the installation from the console if you would like. From here on out we will asume yo u have an SSH session to the box but console is just the same.
Installing Lamp
Now that the server is up and running, you need to install some services on it. First thing we want to do is make sure that all your repositories are up to date. sudo apt-get update will do just that. Now we need to download and install Apache, PHP, and MySQL. We can do all of that with one command
sudo apt-get install apache2 mysql-server php5 libapache2-mod-php5 php5-xsl php5-gd php-pear libapache2-mod-auth-mysql php5-mysql
After these finish downloading and installing, we need to configure php.ini. For this we will use Vi but if your perfer nano, or gedit, feel free to use what you are confortable with.
sudo vi /etc/php5/apache2/php.ini
You need to find the line that says ” ;extension=mysql.so\.so/g” An easy way to do this is to type /mysql.so in Vi. This will parse threw the hole file and find anything matching “mysql.so” Once you find it, move the cursor to the “;” and press “x” to delete that caracter. Now press “ESC” and then type “ZZ” to save. Once that is done, you need to restart apache for the new changes to take effect. You can do that by typing sudo /etc/init.d/apache2 restart.
Create a DB in MySQL
Next we need to create a new Database for WordPress. In this part we will be doing this from the command line. There are other methods that I will go over later but for now just the command line. We want to keep the box as slim as possible right? First we need to connect to MySQL.
mysql -u “username” -p
Now that you are logged into MySQL you can create the DB. Note, all commands in MySQL must end with “;”
CREATE DATABASE databasename;
Next you need to create a user to access that DB. You dont want to ever use your Root DB password so this will be uniqe to each DB connection. Note, all the quotes should be single and make sure they are in all the spots in my example. (thanks Shawn)
GRANT ALL PRIVILEGES ON databasename.* TO ‘bloguser’@'hostname’ IDENTIFIED BY ‘type password here’;
EXIT
Configure apache
Next you will probably want to configure virtual sites. I did at least because I wanted the option of hosting more sites later. Apache 2 uses whats called sites-available. The first thing you will want to do is copy the default site to your own site. sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/myawesomeblog
Now you need to edit the new site to point to the new location for your blog.
sudo vi /etc/apache2/sites-available/myawesomeblog
You need to change the “Document Root” & Directory” path to the new path for example /home/awesomebloguser/public_html/ Now, save the file like you did before.Now in order for the new site to work, you need to enable it. sudo a2dissite default will disable the old site. sudo a2ensite myawesomeblog will enable the new site. You can also do these in one line sudo a2dissite default && sudo a2ensite myawesomeblog
Now just resart apache and you are ready to go. sudo /etc/init.d/apache2 restart
Install WordPress
By this point I am sure you are winded. The last 2 minutes have been excruciating but we are almost done and ready for you to start blogging. All we have left to do is to install WordPress. First things first you need to download it to your box. Start by going to your home directory for your site from the sites-available config you did in apache.
cd /home/myawesomeblog/public_html (if you are installing it on a sub folder make sure to download it there)
Once you are there type the following command to download the newest build of WordPress
wget http://wordpress.org/latest.tar.gz
Once you have it downloaded we need to extract it.
tar -xzvf latest.tar.gz
Now that you have WordPress extracted you have one more thing to do. You need to tell wordpress where the DB is and how to connect. First thing you need to do is rename or copy wp-config-sample. sudo cp /home/myawesomeblog/public_html/wp-config-sample.php /home/myawesomeblog/public_html/wp-config.php
Next you need to edit this file sudo vi /home/myawesomeblog/public_html/wp-config.php You will see a line that has databasename in single quotes. Change that to the name you created earlier for your database. Also do the same in the username and password fields. Save that file and the hard part should be done. Open your browser and browse to your new servers IP http://myawesomeblog.com/ You should be prompted with the wordpress installation page and you are ready to go!!! Good luck and enjoy blogging.
1 Comment to How to build a Linux Server and Install WordPress
Leave a comment
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Nov | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
I’m putting your instructions to use right now! I did find a sweet little utility for burning ISOs for all those Vista users (like me) out there. Go check this out: http://isorecorder.alexfeinman.com/Vista.htm
I’ll report back my results with the server.