Installing WordPress on a Rackspace Linux Cloud Server

Assuming you’ve already “spun-up” a Linux cloud server of your choice, the first thing to do is update the system. I’m using CentOS because it’s free and binary compatible with Red Hat Enterprise Linux (RHEL).

SSH onto your box with the below command, replacing the IP address with that of your server. You will need to accept the key when prompted.

Gentoo-20121221 ~ #

ssh root@120.201.75.117

The authenticity of host '120.201.75.117 (120.201.75.117)' can't be established.
RSA key fingerprint is d3:18:87:29:fe:05:4d:13:ee:75:76:g8:c0:d8:1z:81.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '120.201.75.117' (RSA) to the list of known hosts.
root@120.201.75.117's password:
[root@hagman ~]#

Then update the system and reboot if needed.

[root@hagman ~]# yum check-update
[root@hagman ~]# yum update
[root@hagman ~]# reboot

Install the required software:

  • The Apache web server
  • MySQL database server
  • PHP

Fortunately this can be done with one command.

[root@hagman ~]# yum install mysql-server httpd php php-mysql

Make sure that php-common is also pulled in as a dependency before confirming the installation. If unsure, you can run:

[root@hagman ~]#

rpm -qa | grep php

php-common-5.3.3-22.el6.x86_64
php-pdo-5.3.3-22.el6.x86_64
php-mysql-5.3.3-22.el6.x86_64
php-cli-5.3.3-22.el6.x86_64
php-5.3.3-22.el6.x86_64

Configuring MySQL

Here we start the MySQL server process, secure it, and then connect to the database and prepare it for the WordPress installation. Lastly we add the service to the default run-level. We validate that all services start on boot towards the end of this document, when we reboot to test the WordPress installation for the final time.

The below command will start the service.

[root@hagman ~]# service mysqld start

Now we secure MySQL.

[root@hagman ~]#

mysql_secure_installation

Enter current password for root (enter for none):
Set root password? [Y/n]: Y
Remove anonymous users? [Y/n]: Y
Disallow root login remotely? [Y/n]: Y
Remove test database and access to it? [Y/n]: Y
Reload privilege tables now? [Y/n]: Y

All done! If you've completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

[root@hagman ~]#

Now we create a database for WordPress to use. First we need to create a system user to grant with privileges on the database.

[root@hagman ~]# useradd wordpress-db-usr
[root@hagman ~]# passwd wordpress-db-usr
[root@hagman ~]# mysql -p
Enter password: root_mysql_password

Once successfully logged in as the root database user, create the database and grant privileges. Pay close attention to the characters used, “`“, instead of “” most of the time.

mysql> CREATE DATABASE `wp-db`;
mysql> GRANT ALL PRIVILEGES ON `wp-db`.* TO `wp-db-usr`@localhost IDENTIFIED BY 'wp_user_db_passwd';
mysql> FLUSH PRIVILEGES;
mysql> EXIT

Lastly we add the MySQL daemon to the boot process.

[root@hagman ~]# service mysqld status
mysqld (pid 4073) is running...
[root@hagman ~]# chkconfig mysqld --list
mysqld 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@hagman ~]# chkconfig mysqld on

[root@hagman ~]# chkconfig mysqld --list
mysqld 0:off 1:off

2:on 3:on 4:on 5:on

 6:off
[root@hagman ~]#

Configure Apache

Now we need to start Apache but to avoid seeing a warning message like the one below, we need to first set the ServerName directive in the httpd.conf.

[root@hagman ~]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using 2001:4800:7814:0:9948:8a2e:ff05:172f for ServerName

To set the directive, open up the Apache configuration file with a text editor.

[root@hagman ~]# service httpd status
httpd is stopped
[root@hagman ~]# nano /etc/httpd/conf/httpd.conf

Uncomment out the ServerName directive to look like this:

ServerName localhost

Now start (or restart if already running) the Apache service.

[root@hagman ~]# service httpd start
Starting httpd: [ OK ]

Now lets add Apaches httpd process to the default run-level.

[root@hagman ~]# chkconfig httpd --list
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[root@hagman ~]# chkconfig httpd on

[root@hagman ~]# chkconfig httpd --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[root@hagman ~]#

Install WordPress and Configure Apache

If you plan on creating multiple vhost sites, create a separate directory to hold the WordPress files. The below commands do just that. We also download the latest version of WordPress, extract it, clean up a little and then the last line just removes the (hopefully empty) folder called wordpress.

[root@hagman ~]# mkdir /var/www/html/pikedom-wp
[root@hagman pikedom-wp]# cd /var/www/html/pikedom-wp
[root@hagman pikedom-wp]# wget http://wordpress.org/latest.tar.gz
[root@hagman pikedom-wp]# tar -xzvf latest.tar.gz
[root@hagman pikedom-wp]# rm -v latest.tar.gz
[root@hagman pikedom-wp]# mv -v wordpress/* .
[root@hagman pikedom-wp]# rmdir -v wordpress/

We also need to change the permissions so that apache has both owner and group access rights over the whole site.

[root@hagman pikedom-wp]# chown -Rv apache:apache /var/www/html/pikedom-wp

Here we create a WordPress configuration file from the supplier sample. We also remove the read permission for other.

[root@hagman pikedom-wp]# cp wp-config-sample.php wp-config.php
[root@hagman pikedom-wp]# chmod -v o-r wp-config.php
[root@hagman pikedom-wp]# nano wp-config.php

I changed the below parts.

define('DB_NAME', 'wp-db');
define('DB_USER', 'ifiwerepm-db-usr');
define('DB_PASSWORD', 'wp_user_db_passwd');
define('DB_HOST', 'localhost');

define('AUTH_KEY',         'BhewLNMhybYW[LaGOwHup&rqc;ZDtD6TTrjL;tkPo4LrYglmpS' );
define('SECURE_AUTH_KEY',  'q:rA7YIJaFljQCypOsbnLz{nOdBwmxO8PB;biyt?uYEOhQUfaL' );
define('LOGGED_IN_KEY',    'JKNZK:onwheckZfsljyX[xeQ6aLJHc]hz-hJSBA4woMBQxRuzT' );
define('NONCE_KEY',        'TpoRX?XbN$ZpFrGryr"kiCiF6QbZgFjVDRaC/xPgl6UozabJwn' );
define('AUTH_SALT',        'HtXyIleIlTt2EnVuyqwZgG-khhI{NtHVBT9wf.fY?CrXefBJqo' );
define('SECURE_AUTH_SALT', 'BHlKtVFPLlOF(sqcy'R{zSFDTmhCio4vg6Wa%rgfIShtOhskfX' );
define('LOGGED_IN_SALT',   '7jSeHszKlCluRzW@=qkyAaqD_dDFd*gFplguHBNtqBABVVu1rV' );
define('NONCE_SALT',       'TqnfxC7TPae6UhfzA>ZuwAmbHDnNiYteLCI}ziJazbJHxDqN:w' );

$table_prefix  = 'pikedom_';

Now we create an Apache configuration file for the site.

nano /etc/httpd/conf.d/pikedom-wp.conf

Create something like this. Save and exit.

ServerAdmin test@test
DocumentRoot /var/www/html/pikedom-wp
ServerName www.pikedom.com

# Logging
ErrorLog /var/log/httpd/wordpress-error-log
CustomLog /var/log/httpd/wordpress-access-log common

Note, the email address, test@test gets included in any error messages sent to the client. Official documentation recommends that you create an email address for that specific purpose. www-admin@yourdomain.com for example.

Reboot and Check Services

Now reboot to check that everything still works.

shutdown -r now

From another computer, try to access the site by entering the IP address in a web browser.

http://120.201.75.117/wp-admin/install.php

If all went well, you should see a page similar to the below.

pic

All you need to do now is configure your DNS settings so that others can find your site by typing the domain name instead of the IP address.

If you do not get the response you were expecting, make sure that Apache and MySQL are still running. If not, you need to make sure the services are starting at boot.