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 [email protected]

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.
[email protected]'s password:
[[email protected] ~]#

Then update the system and reboot if needed.

[[email protected] ~]# yum check-update
[[email protected] ~]# yum update
[[email protected] ~]# reboot

Install the required software:

  • The Apache web server
  • MySQL database server
  • PHP

Fortunately this can be done with one command.

[[email protected] ~]# 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:

[[email protected] ~]#

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.

[[email protected] ~]# service mysqld start

Now we secure MySQL.

[[email protected] ~]#

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!

[[email protected] ~]#

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

[[email protected] ~]# useradd wordpress-db-usr
[[email protected] ~]# passwd wordpress-db-usr
[[email protected] ~]# 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.

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

[[email protected] ~]# chkconfig mysqld on

[[email protected] ~]# chkconfig mysqld --list
mysqld 0:off 1:off

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

 6:off
[[email protected] ~]#

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.

[[email protected] ~]# 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.

[[email protected] ~]# service httpd status
httpd is stopped
[[email protected] ~]# 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.

[[email protected] ~]# service httpd start
Starting httpd: [ OK ]

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

[[email protected] ~]# chkconfig httpd --list
httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off

[[email protected] ~]# chkconfig httpd on

[[email protected] ~]# chkconfig httpd --list
httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
[[email protected] ~]#

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.

[[email protected] ~]# mkdir /var/www/html/pikedom-wp
[[email protected] pikedom-wp]# cd /var/www/html/pikedom-wp
[[email protected] pikedom-wp]# wget http://wordpress.org/latest.tar.gz
[[email protected] pikedom-wp]# tar -xzvf latest.tar.gz
[[email protected]n pikedom-wp]# rm -v latest.tar.gz
[[email protected] pikedom-wp]# mv -v wordpress/* .
[[email protected] 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.

[[email protected] 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.

[[email protected] pikedom-wp]# cp wp-config-sample.php wp-config.php
[[email protected] pikedom-wp]# chmod -v o-r wp-config.php
[[email protected] 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',   '[email protected]=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 [email protected]
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, [email protected] gets included in any error messages sent to the client. Official documentation recommends that you create an email address for that specific purpose. [email protected] 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.

Be the first to comment

Leave a Reply