Installing WordPress on a Linux VPS

WordPress blogging software

Having setup my Linux VPS server ( see previous blog ) it’s time to install some web applications.

I wanted to install a blog so I could recount my experiances with a Linux VPS server. WordPress was chosen as it is open source and had very good reviews.

WordPress needs PHP and mysql – both of which were installed already.

Note current versions of WordPress require a later version of PHP than that shipped by default with Centos 5, If you are using Centos 5  update php to version 5.3 see here

First setup Apache so it will use PHP files

vi /etc/httpd/conf/httpd.conf and search for DirectoryIndex

Add index.php index.php3 index.pl index.htm index.cgi

( they are not all needed for WordPress but as I’m going to add other software I put them in )

Restart apache :-

service httpd restart

Create the database

As this is the first application I’m installing that uses mysql there a few steps needed to get msql up and running.

chkconfig  mysqld on

/etc/init.d/mysqld start

mysqladmin -u root password ‘apassword’

‘apassword’ is the password you want to set for the mysql root user

mysqladmin -u root -p -h localhost password ‘apassword’

Now create a database and a user for the database

mysql  -u root -p

create database wordpress ;

grant all privileges on wordpress.* to “wordpressadmin”@”localhost” identified by “passwd” ;

flush privileges ;

exit

passwd” is the password you want the wordpressadmin user to have. You don’t have to call the database wordpress or the user wordpressadmin.

Get the latest WordPress version :-

cd /root

wget http://wordpress.org/latest.tar.gz

cd /var/www/html

tar xvfz /root/latest.tar.gz

Now for the setup and install

cd wordpress

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

vi wp-config.php

change DB_NAME , DB_USER, DB_PASSWORD    to the values you used above in mysql.

Assuming you have your site enabled for SSL then add the following to force all login and admin sessions to be over SSL ( https )

define('FORCE_SSL_ADMIN', true);

Point your browser to https://yourhostname/wordpress/wp-config.php

Fill in the blog name  and an email address ( you can change these later ) then click install.

If successful you will get a password for the admin user displayed – make a note of this and login as user admin with that password.

Click on the Settings link at the left hand side and fill in the Blog Title , Tag Line , Worpress Address URL ( http://yourdomain/wordpress ) , Blog Address ( http://yourdomain/wordpress ).

Check and change any of the other settings such as date format as you want then save the changes.

Next setup your profile – click Users and Edit the admin user, fill in your first and last names ( these are not made public ) , a nick name  , select from the drop-down box the name you want to appear as and  an email address.

Finally change your password , then click on Update Profile

Now you are ready to blog. Click on Posts at the left hand side – you will see the is already one post which you can either edit or delete. Once you have created your post hit the Publish or Update Post button at the right hand side.

There are loads of different themes and plugins available for WordPress – give them a go.

Linux VPS server – the first steps

Pay your money and get your Linux VPS server

Having decided on Tagadab as my Linux VPS hosting company it was time to get the credit card out and get things  rolling. Once the payment was made I received an email thanking me for my order and they are configuring it and will let me know by email when it complete. A mere six minutes later the email arrived saying it was complete and a link to the control panel login.

Once logged in on the control panel I was able to see the IP address given and the root password.

Then it was a quick ssh from my desktop and I was in. I setup a non privileged user and changed root’s password.

As I had no existing domain name it was out with the credit card again to get a domain name. I used Tagadab to get the domain but you could use anyone.

While I was waiting for the Domain name stuff to be setup it was on with some preparation work.

First I disabled selinux – selinux is an excellent idea but I have had problems in the past with working out why things won’t work and after checking things over and over it was selinux stopping things. On Centos you can use the system-config-securitylevel command to disable selinux and also enable ports on the firewall. I set selinux to disabled , security level enabled and ticked the boxes to enable ssh , http, https and smtp. Reboot the server so selinux is disabled.

Check for updates to Centos :-

yum check-update

Then update if necessary :-

yum update

Using chkconfig –list I was able to see what was set to run on the server. httpd was running , as I wanted to install some web software like WordPress , I wanted to restrict access to the web server. As I was paranoid about plain text password I wanted https up and running first. A quick check showed modssl was installed but nothing was running on port 443.

The following was necessary to get https going :-

  1. Create your certificate ( this assumes like me you don’t want to or need to pay for a signed certificate ).
  2. genkey   –days 1825  yoursite.com           obviously use the name of your site and follow the instructions on the screen. The –days says how long the certificate is valid for.
  3. vi /etc/httpd/conf.d/ssl.conf  and change :-

SSLCACertificateFile /etc/pki/tls/certs/yousitename.com.cert

SSLCACertificateKeyFile /etc/pki/tls/private/yoursitename.com.key

  1. Restart Apache :-  service httpd restart

If you have problems check in /var/log/httpd/ssl_error_log

Check https access using your browser – as it is a self signed certificate you will have to add an exception to allow your browser to stop moaning and connect!

Now we want to restrict access to the web server while we install and configure some web applications.

  1. Create a username and password to be used for accessing the web server :-

htpasswd -c /etc/apache.passwds     username

Note /etc/apache.passwds can be any filename , username is the username you want to login to the web site with and does not have to be a real Linux username. It will prompt you for a password.

  1. vi /etc/httpd/conf/httpd.conf  and find the <Directory “/var/www/html”>  section and add

AuthType Basic
AuthName “By Invitation Only”
AuthUserFile /etc/apache.passwds
Require user username

Where /etc/apache.passwds and username are those you setup above.

Restart apache –          service httpd restart

Now check with your browser when you access your server you will be prompted for a username and password.

Setting the domain name

Log in to your front panel and select Domains. Click on the domain you have purchased and the add the following A records using the IP address of your server as the content:-

@

www

mail

Then add an MX record for email with mail.yourdomain as the content . e.g. if your domain is example.com the content would be mail.example.com

@

It takes a while for the records to be properagted to the Internet but eventually you will be able to use names rather than IP adresses.

Edit Apache configuration :-

vi /etc/httpd/conf/httpd.conf and search for ServerName

Set this to www.yourdomain:80

e.g. if your domain is example.com it would be www.example.com:80

Restart Apache :-

service httpd restart

The version of PHP shipped with Centos 5 is 5.1.6 which is quite old and many new versions of PHP applications require a newer version see my instructions for updating PHP to 5.3 on Centos 5.

In the next blog I will show installing WordPress blogging software

The search for a web hosting plan

The web hosting plan I wanted had to give me full control.
It had to be Centos Linux and allow me to install what software I wanted.
A dedicated server would be ideal but I could not justify the cost so I looked at VPS ( Virtual Private Servers ). These give you pretty much full control and are fairly reasonable.

The Search

A Google search for Linux VPS servers brings up a huge choice of hosting companies and plans.

So how to choose ?

I suggest getting a VPS with a minimum of 512MB of memory if you want host web apps that use a Mysql backend – WordPress for example.

If you want  to use your own IPtables firewall rules  and I suggest you do – then ensure that the hypervisor supports this – if in doubt email the hosting company before buying a plan.

Some VPS plans had easy to use front panels where you can just click to install software packages but I’m quite happy to install and configure things manually.

Most plans offer a choice of Linux versions – I was after Centos which is hugely popular for self hosting so there were lots of companies and plans to chose from.

Cost was of course a big decider. The fact I was willing to do manual installs without a fancy front panel meant I could look at the cheaper no frills plans.

In the end I decided to get a VPS server from Tagadab

They are very reasonable and I had my VPS  available in 10mins.

 

Uses for a Web site

I’ve been looking a getting a we presence for ages and I’ve finally got around to doing it.

There are several things I want to do :-

  1. Host my own blog
  2. Setup a “to-do” manager
  3. Have a password manager
  4. My own Wiki
  5. A depository for the shell scripts I write ( maybe version controlled )
  6. Bookmark manager accessible from anywhere
  7. Learn managing a website by managing by managing a web site!

OK you can do all of the above on your own PC at home or use some hosted applications but I want control of my data  – hence my search for a hosting plan.