Here’s a quick tutorial on installing WordPress on CentOS servers. If you’re reading this post, then you probably know a thing or two about WordPress.

Now, if you want to run a great blog or website, most webmasters across the web would recommend using WordPress CMS.

WordPress is probably the most popular opensource CMS system allows anyone to manage a professional looking website or blog with ease.

This brief tutorial shows you how to install and use WordPress on a CentOS server. WordPress runs on many Linux distributions, from Ubuntu to Fedora and CentOS.

To get started with installing WordPress on CentOS, the first thing you’ll want to verify is your access level to the server.

To install required packages to support WordPress requires that you have root or administrator access to the server. If you do, then continue below to install these packages.

 

  • First, install Apache2 web server.

To run WordPress, you must install a web server.. now the most popular webserver in used today is Apache2. To install Apache2 in order to support WordPress, run the commands below

sudo yum -y install httpd

After installing Apache2, run the commands below to stop, start and enable Apache2 to automatically startup everytime you boot up your server or restart

sudo systemctl stop httpd
sudo systemctl start httpd
sudo systemctl enable httpd

 

  • Second, install Mariadb database server

WordPress also depends on a database server to operate. For WordPress to function, you must install a database server… now the most popular database server online today is MySQL database server. However, MySQL isn’t available in the latest version of CentOS’ repositories.

CentOS is moving away from MySQL in favor of Mariadb. So, to simplify the process, install Mariadb instead.

To install Mariadb database server run the commands below.

sudo yum -y install mariadb-server

After installing the database server, run the commands below to stop, start and enable it to automatically start up everytime you restart your server.

sudo systemctl stop mariadb
sudo systemctl start mariadb
sudo systemctl enable mariadb

Another thing to do right after installing Mariadb database server is to configure it with a password. To do that, run the commands below.

sudo mysql_secure_installation

Next, follow the guide below to answer the prompts until you’re done.

  • Enter current password for root (enter for none): press Enter
  • Set root password? Y
    • New password: Type new root password
    • Re-enter new password: Confirm the password
  • Remove anonymous users? Y
  • Disallow root login remotely? Y
  • Remove test database and access to it? Y
  • Reload privilege tables now? Y

 

  • Third, install PHP modules

WordPress depends on PHP modules to function. Without PHP and its modules, WordPress won’t function. To install PHP, run the commands below.

sudo yum -y install php php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel php-mysql

After installing Apache2, MariaDB and PHP modules, your server is now ready to run WordPress.

The next things to do are create WordPress database, download WordPress content and configure WordPress settings.

To create WordPress database, follow these steps:

Run the commands below to logon to MariaDB database server.

mysql -u root -p

Then run the commands below to create a new database called wpdatabase.

CREATE DATABASE wpdatabase;

Next, run the commands below to create a WordPress database user called wpuser with a password.

CREATE USER [email protected]st IDENTIFIED BY 'user_password_here';

Finally, great the new user rights and privileges to manage the newly created database.

GRANT ALL PRIVILEGES ON wpdatabase.* TO [email protected];

Flush and exit.

FLUSH PRIVILEGES;
exit

After that, go and download WordPress content from online and extract it.. then copy it over to Apache2 default root directory.

WordPress content can be downloaded using the commands below.

cd /tmp/ && wget http://wordpress.org/latest.zip

Next, extract the content and copy it to the /var/www/html directory.

unzip latest.zip
sudo cp -rf wordpress/* /var/www/html/

Next, change the permissions and ownership of the WordPress content folders.

chown -R apache:apache /var/www/html
chmod -R 755 /var/www/html

Next, create a copy of wp-config-sample.php and neame it wp-config.php.

sudo cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php

Then edit the wp-config.php file and enter the database name, database username and user password you created earlier.

vi /var/www/html/wp-config.php

// ** MySQL settings – You can get this info from your web host ** //

/** The name of the database for WordPress */
define(‘DB_NAME’, ‘wpdatabase‘);

/** MySQL database username */
define(‘DB_USER’, ‘wpuser‘);

/** MySQL database password */
define(‘DB_PASSWORD’, ‘databse user password‘);

Save the file.

Finally, enable HTTP traffic through the firewall.

firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload

Restart Apache2, then open your browser and browse to your server. You should see WordPress configuration page.

wordpress ubuntu 14.10

 

That’s it!