Everyone has to install WordPress at some point in there lives, especially if you call yourself a system admin or even a web-master. I think it starts with understanding the basic Linux distro that you are using. I usually stick with the basic’s Linux Mint, Ubuntu LTS and CentOS. As I spin up need instances I have to constantly go back and forth between several blogs or even install scripts to completely understand what I should and shouldn’t do.

I’d like to use this blog as a basis for my build script – this is written for my own reference. You should only use this blog post if you are skilled in Linux and understand the implications.

With that in mind, I use a CentOS 6.4 distro and install a LAMP stack on the machine for WordPress.

Steps:

  1. Spin up a new VPS – using whatever host name that you want – I prefer Digital Ocean
  2. Write down your IP
  3. Forward your domain from GoDaddy or 1and1
  4. Update the DNS record
  5. SSH & go through the install script / steps for the machine
  6. Go through the WP-Admin install process
  7. Test / Ensure that the domain is publicly accessible
  8. Done? – No, now you can do personalized customization like Theme’s and so on.
  9. Analytics!!! – I’ll write another blog about this.

How to Set up the Server

Start with a simple install of basic libraries. These include getting vim, wget, php, and mysql.

yum -y install mysql-server httpd php php-mysql unzip wget vim
yum -y update

Make sure the services are on and stay on. This means the server will upon restart turn on certain services. In the case your server goes down and needs to be rebooted or reboots by itself – it will start the httpd (apache – web server) and mysqld (mysql database) upon restart.

chkconfig httpd on
chkconfig mysqld on

Since we just installed the services – we should actually turn them on. We will initialize and start the services.

/etc/init.d/mysqld start
/etc/init.d/httpd start

We must go through the MySQL installation guide. This will prompt the user to install MySQL and configure default values – root password and prompt you to delete the existing data. Please enter yes (y) through this installation. Also remember to select a secure password, something with letters, numbers, and capitalization throughout. Ohh and this is one is important – WRITE IT DOWN SOMEWHERE…

/usr/bin/mysql_secure_installation

We go through the WordPress database installation process. Please feel to substitute ‘wordpress’, ‘wordpressuser’, and ‘password’ for something that will reflect your needs and preferences.

CREATE DATABASE wordpress;
CREATE USER wordpressuser@localhost;
SET PASSWORD FOR wordpressuser@localhost= PASSWORD("password");
GRANT ALL PRIVILEGES ON wordpress.* TO wordpressuser@localhost IDENTIFIED BY 'password';
FLUSH PRIVILEGES;
EXIT;

Next we have to change directories and actually install the latest code from WordPress.

cd /var/www/html
wget http://wordpress.org/latest.zip
unzip latest.zip
rm latest.zip
mv wordpress/* ./
rmdir wordpress/
mkdir wp-content/uploads wp-content/cache
chown apache:apache wp-content/uploads wp-content/cache

Copy the wp-config.php file and get ready to edit it.

cp wp-config-sample.php wp-config.php
vim wp-config.php

We must edit the wp-config.php file and add the details from the previous configuration of your MySQL install.

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

/** MySQL database username */
define(‘DB_USER’, ‘wordpressuser’);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘password’);

Restart HTTPD (Apache) and MySQLD (MySQL) for safe measures.

service httpd restart
service mysqld restart

Create your .htaccess doc.

cd /var/www/html/
vim .htaccess

Add this to the .htaccess doc.

RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]

Next blog will focus on file permission / security and FTP users.

All done – for now…