Set Up A WordPress VPS With Centos & Apache

Lets learn how to set up a VPS with Apache & PHP & install WordPress in it.

(i) Choose Centos 6 32 bit as your operating system (OS) from your VPS’ control panel;

(ii) Update Centos with the command

yum update

(iii) Install apache with the command

yum install httpd

(if you run into a “Yum thread.error: can’t start new thread” check the solution here)

(iv) Start Apache & Configure it to run as soon as the VPS starts

/etc/init.d/httpd start
/sbin/chkconfig --levels 235 httpd on

(v) Install MySQL database

yum install mysql-server

(vi) Start MySQL and configure it to start when the VPS starts

/etc/init.d/mysqld start
/sbin/chkconfig --levels 235 mysqld on

(vii) Configure MySQL by changing the password and other options

mysql_secure_installation

(select yes for all default options)

(viii) Create a new database for the WordPress installation

mysql -u root -p

(you will be prompted for the password)

create database wordpress;
quit

(ix) Install PHP with the command

yum install php php-pear

You can tweak the configuration file by accessing it at /etc/php.ini. However, for now you can leave it at its’ default values.

(x) Add support for MySQL in PHP with the command

yum install php-mysql

(xi) Download wordpress tar file with the command

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

(xii) Unzip the WordPress tar file. It will itself unload the files onto a directory called “wordpress”:

tar xzf latest.tar.gz

(xiii) Go to the wordpress directory:

cd wordpress

(xiv) Copy all the files from the wordpress directory to the directory of your site which is accessible to the public (this is the root of the site – /var/www/html/)

cp -R * /var/www/html/ 

(xv) Restart Apache with the command

/etc/init.d/httpd reload

(On some VPS’ you may need to reboot the VPS from the control panel – otherwise you will only see a blank page)

(xvi) Begin WordPress Installation:

Go to your IP address (as a domain hasn’t been set up yet). You will be greeted by a wordpress page prompting for information on your mysql database, password etc. Just fill in the information and your website will be ready to go.

Occasionally, the installer will be unable to create a configuration file. If that happens, just copy the pre that wordpress shows you, create a file called wp-config.php and paste the pre in it.

You can add more wordpress installations in different folders following the same procedure.

Change WordPress Permalinks:

For SEO purposes, you must change the permalinks to show the title of the post in the url. This is usually done through Settings > Permalinks.
However, this requires mod_rewrite rules to be inserted in the .htaccess file. So, just create a .htaccess file and add the following pre in it.


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

Make sure the .htaccess file is writable by chmoding it to 644 or higher. Now your permalinks will work.

If you are satisfied with the way things have worked out, you can install a control panel like Webmin or Kloxo and configure your domain. Then you can secure your VPS by disabling root access and creating a sudo user and changing the default port. You can also also install a CSF firewall. You can also install a vsftpd server to permit WordPress to download & install plugins.

Leave a Reply

Your email address will not be published. Required fields are marked *