Friday, April 8, 2011

Install Wordpress 3 on Ubuntu 10.04

I installed Wordpress on a local computer running Ubuntu 10.04 this week.  I did this because I am considering converting to Wordpress as a platform for publishing my business website.  Most of the installation and configuration was fairly easy, however I got stuck on one step which stymied me for a few hours.  So, I decided to document all of the steps I used, as none of the blogs and other websites I found had all of them in one place --- INCLUDING the installation instructions found on Wordpress' website.

Wordpress 3.1.1 Pre-requisites
  • Apache 2
  • MySQL 4.1.2 or >
  • PHP 4.3 or >
  • mod_rewrite Apache module (this is on the official Wordpress list of pre-reqs, but I did not install it and Wordpress is running fine)
The installation for Apache, MySQL, and PHP on Ubuntu 10.04 are well documented, so I have not attempted to recreate these:
STEP 1: Create Apache VirtualHost for Wordpress

user@host:$ sudo a2ensite wordpress
user@host:$ sudo /etc/init.d/apache2 restart

Where:
'wordpress' is the desired name of the VirtualHost in Apache (use whatever name you want).

STEP 2: Create MySQL Database & User for Wordpress

Create a database for Wordpress to use with the MySQL admin user.  There are numerous ways to do this (see below).  I prefer to do this via the MySQL command line.

user@host:$ mysql -u root -p
Enter password:

Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 186
Server version: 5.1.41-3ubuntu12.10 (Ubuntu)
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> CREATE DATABASE wordpress;
Query OK, 1 row affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON wordpress.* TO wp_user@localhost IDENTIFIED BY password;
Query OK, 1 row affected (0.00 sec)

mysql> FLUSH PRIVILEGES;
Query OK, 1 row affected (0.00 sec)

mysql> EXIT;
Bye
user@host:$ 

Where:
Wordpress database name = 'wordpress'
Wordpress database user name = 'wp_user'
Wordpress database user password = 'password'

Another option is to use phpMyAdmin, which provides a GUI web interface for managing MySQL servers.  phpMyAdmin requires a webserver + PHP, but both of these are also requirements for Wordpress.  phpMyAdmin can be useful if you're doing a lot of other things with MySQL.
Another option for a MySQL GUI tool is the MySQL Workbench.

STEP 3: Download and Extract Wordpress

Go to the Wordpress download area to get the latest version.  Download and extract the wordpress directory to /var/www/wordpress (the extraction should create the wordpress directory).

STEP 4: Set Permissions for Wordpress Directory

NOTE: This was the key step where I got stuck for a while.  Without setting permissions properly my web browsers did not execute the PHP files, but instead downloaded them from Apache.

Execute the following from the command line.

user@host:$ cd /var/www
user@host:$ sudo chmod -R 0644 wordpress
user@host:$ sudo chmod -R 0755 wordpress
user@host:$ sudo chown -R user:www-data wordpress

Where:
'user' is your username on your local host

STEP 5: Configure Wordpress for MySQL Database

Rename the sample wordpress config file from the command line:

user@host:$ cd /var/www/wordpress
user@host:$ mv wp-config-sample.php wp-config.php

Edit /var/www/wordpress/wp-config.php as follows:

// ** MySQL settings - You can get this info from your web host ** //

/** The name of the database for WordPress */
define('DB_NAME','wordpress');

/** MySQL database username */
define('DB_USER','wp_admin');

/** MySQL database password */
define(<'DB_PASSWORD','wp_admin');

/** MySQL hostname */
define('DB_HOST','localhost');

STEP 6: Enter Wordpress Security Keys Use the online key generator to get security keys to enter into the wp-config.php file (replace each 'put your unique phrase here' with the appropriate key).

define('AUTH_KEY','put your unique phrase here);
define('SECURE_AUTH_KEY','put your unique phrase here)';
define('LOGGED_IN_KEY','put your unique phrase here');
define('NONCE_KEY','put your unique phrase here');
define('AUTH_SALT','put your unique phrase here);
define('SECURE_AUTH_SALT','put your unique phrase here');
define('LOGGED_IN_SALT','put your unique phrase here');
define('NONCE_SALT','put your unique phrase here');

STEP 7: Run Wordpress Install Script

Open the file /var/www/wordpress/wp-admin/install.php in your web browser.  You should get something like this:


Enter your site name, an admin account username and password.  Email is not really relevant if you're installing on a local server for testing like I am, however it won't hurt to put it in.

No comments:

Post a Comment