Complete Guide To Setting Up A VPS With WordPress (Centos) (Without Control Panel)

There are few things more satisfying than starting with an empty VPS and filling it with a fully functional WordPress website in just a few moments.

The best thing is that we will not be using any Control Panel. This means that we don’t squander away precious RAM that would otherwise be consumed by the Control Panel.

In this Guide, we will start with a VPS pre-loaded with Centos 6 (32 bit) and load it with apache, php, MySql, Phpmyadmin and WordPress.

We will also secure and harden the VPS so that hackers cannot get in.

Step I: Go to the domain registrar and point the domain to the I. P. address of your VPS

The propagation across the internet of the domain takes a little while. So, it is better to do this first.

If you are hosted with namecheap, do the following. The steps with the other name registrars will be similar.

(i) Ensure that the domain is configured to use the domain registrar’s nameservers. This way, we don’t have to host DNS servers on the VPS;


(ii) Click on the “All Host Records” in the left panel. In the box, against the entry for Host Name @, enter the IP address of the VPS in the IP address box and select “A (Address)” in the Record Type box. Against the entry for “www” under Host Name, enter the domain url in the IP address box and select “CNAME (Alias)” in the Record Type box.


(iii) Now, save your changes. Once you configure Virtual Hosts on the VPS, we can check whether the entries have been properly done or not.

Step 2: Install Apache on the VPS

The latest version of Apache can be installed with the commands:

yum update

yum install httpd

Note: Depending on your configuration it may show

Package httpd-2.2.15-29.el6.centos.i686 already installed and latest version
Nothing to do

Step 3: Configure Virtual Hosts:

This is a crucial step requiring attention to detail.

(i) First decide the directory structure of your websites. I personally prefer listing all the websites in the “home >> domains >> >> public_html” directory.

(ii) Make the requisite directory for the website with the command;

mkdir -p /home/domains/

We should also have an error log for each site and so we can create a folder called logs with the command

mkdir /home/domains/

(iii) Having created the folder, we should create an index.html file so that we can check the the domain is routing to the correct folder (optional).

nano /home/domains/

Enter the words “Hello. Testing” or anything else that catches your fancy.

(iv) make as many directories as the sites you propose to host on the VPS.

(v) There are multiple methods to set up virtual hosts. Lets look at two of them:

Method 1:

(a) Open the configuration file called httpd.conf located in the folder /etc/httpd/conf/ in nano (if you don’t have nano you can install it with the command yum install nano)

nano /etc/httpd/conf/httpd.conf

(b) If you scroll down to the bottom you will see that Section 3 deals with Virtual hosts and is self-explanatory.

### Section 3: Virtual Hosts
# VirtualHost: If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
# Please see the documentation at
# for further details before you try to setup virtual hosts.
# You may use the command line option '-S' to verify your virtual host
# configuration.

# Use name-based virtual hosting.
#NameVirtualHost *:80
# NOTE: NameVirtualHost cannot be used without a port specifier
# (e.g. :80) if mod_ssl is being used, due to the nature of the
# SSL protocol.

# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
# ServerAdmin
# DocumentRoot /www/docs/
# ServerName
# ErrorLog logs/
# CustomLog logs/ common

(c) Now the last part is what you need to modify/ add afresh by removing the hash sign and making appropriate changes as shown:

NameVirtualHost *:80

DocumentRoot /home/domains/
ErrorLog /home/domains/

You have to pay close attention to make sure the directory structure and path is correct.

(d) Reload apache with the command:

/etc/init.d/httpd reload

Common Problems:

If you make a mistake in the configuration, Port 80 gets blocked and the website will not be accessible. You can check whether the Port is open or not by going to

You can check whether you have configuration errors with the command:

apachectl -S

And you can check the error log with the command:

nano /var/log/httpd/error_log

Usually, an error in the directory path or in forgetting to create a folder etc is the cause of the problem.

Method 2:

(a) Create a file called vhost.conf with the command

nano /etc/httpd/conf.d/vhost.conf

and enter in the information relating to the site as done before

NameVirtualHost *:80

DocumentRoot /home/domains/
ErrorLog /home/domains/

You can have similar entries for multiple websites.

Check whether the virtual hosts are properly set up:

You can check whether your DNS configuration is proper by going to and

To check whether the domain has propagated to your internet provider use the CMD command to ping the domain. The IP Address will tell you whether the IP of the VPS is being shown or not.

Another technique that I use is to access the website through a proxy server like This way, even if the domain has not propagated to my local internet provider, I can access the site and check for errors.

Step 4: Install and Configure MySQL Database Server:

MySQL can be installed and started with the command:

yum install mysql-server

/etc/init.d/mysqld start

To ensure that MySQL automatically starts after every reboot add the command

/sbin/chkconfig --levels 235 mysqld on

Now, we will configure MySQL by setting up a password and creating a database for wordpress


(The steps are self-explanatory)

mysql -u root -p

create database wordpress;

Before installing WordPress, we should install PHP and that is done with the command:

yum install php php-pear

yum install php-mysql

Now we can install WordPress for the Domain:

(i) Go to the root folder to download the files there (it is best to have a specific location for downloads)

cd /root

(ii) Download the WordPress tar file:


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

tar xzf latest.tar.gz

(iii) Go to the wordpress directory:

cd wordpress

(iv) You can see what are the files there with the command


(v) Copy all the files from the wordpress directory to the public_html folder of your website (If you would like the files to be loaded onto a folder (e.g. “blog”), then create that folder first

cp -R * /home/domains/

Now, when you access your domain, you should be greeted with the WordPress “There doesn’t seem to be a wp-config.php file. I need this before we can get started”.

Note: Occasionally there is a problem which is solved by a reboot of the VPS. Also remember to delete the index.html file if you created one earlier.

When you enter the MySQL credentials, you will be greeted with a “Sorry, but I can’t write the wp-config.php file. You can create the wp-config.php manually and paste the following text into it.”

The reason for this is a permission error. You can navigate to the sites root folder and check the owner and permissions with these commands:

cd /home/domains/

ls –l

You will see that the owner and group is shown as root : root
Change the owner and group to apache with the command

chown apache:apache –R *

If it still doesn’t work, create the wp-config.php file manually with the command:

nano wp-config.php

and paste the contents of the file into it. Save and exit with the command Ctl Z and Y

Now follow the WordPress steps and in a few seconds you should have a fully functional WordPress folder.

If you have changed the owner and group to apache:apache as set out above, you will find that you are able to install and delete plugins without any further errors.

Install WordPress Plugins:

Two plugins that you must install are Quick Cache and Anti-spam.

Quick cache is the easiest to use Cache plugin. It is very effective. It serves static html files to the visitor. This ensures that the pages load fast and creates a favourable experience for the viewer. Also, it reduces the load on the server.

Anti-Spam is the most effective plugin to deter automated spammers/ spam bots. It does not use captcha. The human visitor cannot see anything when he is entering a comment. However, there is a hidden field which the spam bots see. When the bots enter the data in the hidden field, they get caught.

I can tell you from my experience of the past 1 year and more that the Anti-Spam plugin is very effective. The human visitors are happy because they don’t have to deal with unreadable captcha and the spam comments (from bots) has completely stopped.

Change WordPress Permalinks:

For SEO purposes, you must change the permalinks to show the title of the post in the url. This is 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 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.

Securing & Hardening the VPS:

(Coming Soon)

1 thought on “Complete Guide To Setting Up A VPS With WordPress (Centos) (Without Control Panel)

Leave a Reply

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