How to Install WordPress on a New CentOS / RedHat Linux VPS

In this tutorial I will explain how to install WordPress on a fresh new VPS with CentOS / RedHat Linux OS. So, I have a fresh VPS with CentOS 6 installed. My first step will be to update CentOS and install LAMP

Step 1: Update Machine

Our first step should be to update the VPS. Login to your server via SSH and as root. Run following command to update your VPS.

yum update

Step 2: Install Apache

Run following commands to install Apache on your VPS.

yum install httpd
service httpd start

A more detailed tutorial is here: How to install Apache on a Linux Server

Step 3: Install MySQL

yum install mysql-server
service mysqld start
/usr/bin/mysql_secure_installation

MySQL server will ask MySQL server root password. Since you just installed mysql, there is no MySQL root password. So, just press enter. Create MySQL root password and complete the installation.

Please refer here for complete step by step installation: How To Install MySQL on a CentOS Server

Step 4: Install PHP

After installing Apache and MySQL, we will install PHP. Run following commands

yum install php php-mysql
service httpd restart

A more detailed tutorial for installing PHP is here: How To Install PHP on a CentOS server

Step 5: Auto start Apache and MySQL on reboot

chkconfig httpd on
chkconfig mysqld on

Step 6: Create a database for wordpress

mysql -u root -p

Enter your MySQL root password. Now we will create a database name wp1

CREATE DATABASE wp1;

Create a database user ravi

CREATE USER ravi@localhost;

Set the password for the MySQL user ravi. I am using abc123 as password. You can use different password. Please use a strong password.

SET PASSWORD FOR ravi@localhost= PASSWORD("abc123");

Grant privileges to user ravi to database wp1

GRANT ALL PRIVILEGES ON wp1.* TO ravi@localhost IDENTIFIED BY 'abc123';

refresh MySQL

FLUSH PRIVILEGES;

Exit MySQL

exit

Step 7: Configure Apache for WordPress Permalink

We will now enable mod_rewrite Apache module. Open Apache configuration file in nano editor.

nano /etc/httpd/conf/httpd.conf

Search following line in this file.

LoadModule rewrite_module modules/mod_rewrite.so

Make sure there is no # sign in the beginning of this line. If there is # sign in the beginning of this line, just delete # sign.

In section <Directory “/var/www/html”> find

AllowOverride none

Change this to:

AllowOverride All

Save this file: Press Ctrl + O buttons on keyboard.
Exit nano editor: Press Ctrl + X buttons on keyboard.

service httpd restart

Step 8: Download WordPress

Download and extract WordPress files.

cd /var/www/html/
wget http://wordpress.org/latest.tar.gz
tar -xzvf latest.tar.gz
mv wordpress/* .
chown -R apache:apache /var/www/html/

Step 7: Install WordPress

Open your website URL in browser. It will show you WordPress installation page.

There doesn’t seem to be a wp-config.php file. I need this before we can get started.

Need more help? We got it.

You can create a wp-config.php file through a web interface, but this doesn’t work for all server setups. The safest way is to manually create the file.
Create a Configuration File

Click Create a Configuration File button. Installation will ask the database name, database username and password. Enter the database details that we created in step 6 and complete the installation.

Done!!!
You have now successfully installed WordPress on your VPS / server.

Our Top Rated Host

Related Posts