This tutorial should help you on your way to installing the latest WordPress on your Ubuntu 12.10 image. If you haven’t already got a LAMP stack setup on your server, please check out how to install LAMP on Ubuntu
- Step 1 – Download WordPress
- Step 2 – Create MySQL Database for WordPress
- Step 3 – Configure WordPress
- Step 4 – Deploy WordPress
Before we begin it’s worth making sure your install is all up to date by running these commands:
Update your package index’s:
apt-get update
Update the packages you already have installed:
apt-get upgrade
Download WordPress
Let’s create a temporary directory to download the WordPress files to:
mkdir ~/tempwp cd ~/tempwp
Then we can then download the latest version like so:
wget http://wordpress.org/latest.tar.gz
To extract the files we run:
tar xvfz latest.tar.gz
This will extract the wordpress app to ~/tempwp/wordpress/
Create MySQL Database for WordPress
WordPress uses a database to store all your blogs post, pages, comments and some of the configuration. Before we can install WordPress, we need to create a database for it along with a username and password to secure the data.
First we connect to MySQL as root user:
mysql -p -u root
It should prompt you for your root password and present a mysql>
prompt.
If it fails to connect it may mean that MySQL isn’t running. Try starting it using:
service mysql start
Once connected to MySQL we create the database:
mysql> create database wordpress;
Query OK, 1 row affected (0.00 sec)
Then we need to set a username and password for that database:
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wpusername'@'localhost' IDENTIFIED BY "password";
Query OK, 0 rows affected (0.00 sec)
Note we used 'wpusername'@'localhost'
which only allows that username to be used from the localhost.
Let’s exit the MySQL console:
mysql> quit
Bye
Now test the database works using:
mysql -u wpusername -p wordpress
After entering the password if you see the mysql>
prompt then you know you’re ready for some WordPress installation action. Exit the MySQL console again as above with quit
Configure WordPress
Now we’ve setup our database we can enter those details into the wp-config.php which will allow the WordPress installation pages to work their magic.
First we rename the sample config so it becomes the active config:
cd ~/tempwp/wordpress
mv config
mv wp-config-sample.php wp-config.php
Use your favourite editor to make the changes to the config file:
nano wp-config.php
Scroll down to the section that starts // ** MySQL settings
. You now need to edit the variables so they match the details you entered above, so in our case it would look like this:
// ** 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', 'wpusername'); /** MySQL database password */ define('DB_PASSWORD', 'password'); /** MySQL hostname */ define('DB_HOST', 'localhost');
The next section of your config contains security keys and salts. It’s important you use a long random string of characters to give your blog protection against hacking. Don’t worry, you don’t need to remember what these are. Use this page to generate some random ones for you: https://api.wordpress.org/secret-key/1.1/salt/
Once you’ve updated your keys it should look something like this:
/**#@+ * Authentication Unique Keys and Salts. * * Change these to different unique phrases! * You can generate these using the {@link https://api.wordpress.org/secret-key/1.1/salt/ WordPress.org secret-key service} * You can change these at any point in time to invalidate all existing cookies. This will force all users to have to log in again. * * @since 2.6.0 */ define('AUTH_KEY', 'Oc)jFJ(fmrRAY /KBDH6ykt-T6:-hGr<+^;`N]zw|uTtW(/!#D|`[+#yBs{#=jW!'); define('SECURE_AUTH_KEY', '?vqih2Piryq>&~]^^xE+/Bgj5u+B0Nc0{F|>t6k^84}^]w1<bh[cyn,xCMj$XD8f'); define('LOGGED_IN_KEY', 'Ew3yrkSG|M.`V3i{g+=VsOIX2zM!>A#yuk;_{0x_(rUzPfE,^bCGY~QPbd>cY)Rd'); define('NONCE_KEY', 'p;86=!-+|1dgNY-: uHA7t<<-784v+zME/DN-.Z&TaS &hpj78i!H,rZX49r-~0N'); define('AUTH_SALT', ';,Y8_|<ILrA!rs%3{h^1UWsoO)q-0qN3e%-ix5^ ZrL$1EcVD:BTA-vwaoS3J]fe'); define('SECURE_AUTH_SALT', '9I3euOYcT}zWX/!]dzZ#=QlJ_8Se/S%80+V|OAs9!}UL(GvtY8hyC:z&6j|rB|lb'); define('LOGGED_IN_SALT', ' }/RfA[8`_HaQ>e(KR{31Rv,ekpy,$r/KP2:_B1d%L$;H%cAI`MOGjHy0RYIBPl!'); define('NONCE_SALT', 'Or>||VB:G-F/5q_qWL& hQSNqaE7ZrHpiI|d0|(NvTKGWC5T>pt#uG3ljz{k-jV-'); /**#@-*/
Note: DO NOT USE THESE VALUES!!
Now save your config and we’re ready to deploy.
More info about security keys can be found here http://codex.wordpress.org/Editing_wp-config.php#Security_Keys
Deploy WordPress
We copy the files we downloaded in the tempwp directory over to the root of our web server like so:
cp -Rp ~/tempwp/wordpress/* /var/www/
Let’s check the permissions on the files:
ls -la /var/www/
check all the users and groups are www-data.
you might want to remove any index.html file that was in the /var/www dir:
rm /var/www/index.html
You should now be able to go to http://<<Your Server IP>>/ and you’ll be redirected to the installation page which should look like this:
Happy WordPressing 🙂