How to install WordPress on a VPS with CentOS 6

· Linux


In this article it’s assumed that you know already what WordPress is, and that you want to use it.  Here we’ll show you exactly how to install it on your own server, whether that is a Virtual Private Server or a physical one. It’s assumed that the server is already set up with CentOS 6, because that is the most popular Linux version for servers. We will create a multi-site installation so that you can have multiple web sites (each with their own domain) on this WordPress installation.

Let’s take one step back to see why we are doing this. There are a lot of options for creating a new WordPress installation. They range from creating an account at to choosing a web hosting company, via a VPS to a physical dedicated server. All of these methods are fine, and each has its specific advantages and disadvantages. Here we focus on using a VPS because it gives you a lot of flexibility and great ‘bang for the buck’. Recently the prices for OpenVZ-based VPSes have come down a lot, to the point where they are comparable to web hosting, and a lot cheaper than co-location for a real 1U server. The main downsides of the VPS option are that it requires a bit of Linux expertise to set up and that performance can vary, based on the load that other VPS users create on the same environment.

In this article we will show you exactly how to set up WordPress, to help with the Linux expertise thing. Perhaps in a future article we can also show how we picked a good VPS provider with stable performance.

How much RAM, and why CentOS 6?

When creating your VPS, the main choices are the amount of RAM you want and the Operating System image to put on it. 256 MB of RAM (with the ability to burst to 512 MB) should be enough if you want to put only a small number of sites on your WP installation. 512 MB of RAM is recommended for a larger number of sites or if you want to put other software on the VPS besides WordPress. CentOS 6 is highly recommended because it is recent, has a good update mechanism and is server-friendly. If your VPS provider doesn’t offer CentOS 6 as an option that’s definitely not a good sign and I would suggest to pick another one. Using a non-Linux OS like FreeBSD or Windows is generally not recommended – compared to Linux they only have downsides regarding cost and complexity.


If you started already to install WP but got stuck halfway it’s easiest to re-image the VPS with a fresh CentOS 6 and start from scratch, following the steps below. The requirements to start are:

  • A server running CentOS 6 on the Internet
  • Basic command-line Linux skills, including editing files with nano or vi

WordPress installation

To start register a domain that you want to use for the WP blog and create A (address) records for the domain itself (also called @) and for www.yourdomain.tld to point to the IP address of your server. If you want to host multiple domains you can register all of them at this point and for all of them create A records for the domain itself and to www now.

Then install php and mysql, create a database for WP and download and install WP itself (connect to your server as root using ssh to enter these commands):

yum install php-common php-cli php-gd php php-pdo php-mysql php-xml
yum install mysql mysql-server
chkconfig mysqld on
service mysqld start
mysqladmin -u root -p create wpress
mysql -u root -p
in mysql: GRANT ALL ON wpress.* TO 'wpress'@'%' identified by 'wpress1';
in mysql: exit
cd /var/www
tar xzf latest.tar.gz
chown -R apache.apache wordpress

N.B. it is assumed here that Selinux is disabled or not installed – you can verify this with the sestatus command – if not found don’t worry about it.

Create apache configuration files for wordpress in /etc/httpd/conf.d – see the attached examples, only modify domains in vhosts2.conf, you should not have to modify vhosts4-wp.include. This configuration will make it easy to install non-WP software later and point some domains to it.

Restart apache (service httpd restart), then access http://yourdomain/wp-admin/install.php in your browser to complete the instal, use database name wpress, database username wpress and password wpress1 as specified above, recommended to leave the admin password for wordpress blank so it will be generated, then write down / store it somewhere safe. (It will also be sent to the e-mail address that you specify).

For a single site / domain you are now done, however it’s easy to add support for multiple domains in this WP installation, and it’s best to do that now:

Multi-site WP setup

Enable WP multisite :

  • Edit /var/www/wordpress/wp-config.php, adding define(‘WP_ALLOW_MULTISITE’, true);  just above That's all, stop editing!, then refresh your WP dashboard in your browser,
  • Do the network setup under Tools using subdirectories and follow instructions (create blogs.dir, add more lines to wp-config.php, the modifications to .htaccess can be skipped because they have already been added to the httpd config file above), after installation it appears as if nothing is changed, but gives you a network admin page (http://yourdomain/wp-admin/network/) and menu items – go to the network admin dashboard.
  • Install the WordPressMU Domain Mapping plugin using instructions at, network activate it, move wp-content/plugins/wordpress-mu-domain-mapping/sunrise.php up into wp-content, add define( 'SUNRISE', 'on' ); on the line above the require_once in wp-config.php – see the attached final version of the bottom half of the file.
  • In the Settings/Domain Mapping menu entry of the network admin dashboard set the IP address to that of the server, the server cname to yourdomain, disable remote login, enable perm. redirect & user domain mapping page, disable redirect admin page & disable ‘disable primary domain check’
  • For each additional domain besides the primary one you used for installation, make sure they were added in vhosts2.conf, then in the Network Admin menu in Sites create sites for each extra domain (without differentiating www vs non-www), without dots in the subdir (domain and tld simply appended), assign all of them to the admin user
  • Also there upload and network-enable any themes you want to use
  • From the sites list go to each site dashboard individually (except the initial one) and under Tools/Domain Mapping add mappings for the domain, one for non-www and one with www, can select either of them as primary and then the others will redirect
  • Select the theme for the site, etc.


Using the steps described above, you’ve created a new multi-site WP installation on your server. Now you can start to add users, and start blogging!

Leave a Comment