In this blog we will discuss about WordPress installation on Linux (Centos instance). Before that we need to understand what WordPress is ?
WordPress is a free and open-source content management system (CMS) which uses PHP and MySQL. WordPress is a freely available web tool that you can use to create beautiful websites.
It was released on May 27, 2003, by Matt Mullenweg and Mike Little. You can refer to the link given below for complete details of WordPress.
https://en.wikipedia.org/wiki/WordPress
Pre-requisites
Following are the recommended softwares required to run WordPress:
- PHP version 5.6 or greater
- MySQL version 5.6 or greater
WordPress community recommends Apache or Nginx as the most robust and featured server for running WordPress, but any server that supports PHP and MySQL can also be used.
Here, in this tutorial we will install Linux, Apache, MySQL, PHP (LAMP) stack On CentOS 6 with the above prerequisites.
Let us now understand each of them one by one.
So, what is LAMP?
LAMP stack stands for Linux, Apache, MySQL, and PHP. It.is a group of open source softwares used to run dynamic web sites and servers. This setup requires a user who has root privileges, so we need to create a sudo user first.
Creating a “sudo” User
Step1 : Login to root and add a new user
1
|
useradd acadgild
|
1
|
passwd acadgild
|
Step 2 : Provide root privileges to this user
1
|
visudo
|
Refer to the image given below to configure acadgild by providing root privileges. Add the highlighted line below root line.
Step 3 : Save it and restart the ssh services.
1
|
service sshd restart
|
LAMP Installation
Login to sudo user which we have added recently with root privileges (that’s a must)
Step 1 : Install Apache webserver-
1
|
sudo yum install httpd –y
|
Step 2 : Once intallation gets over you can start Apache and its services.
1
|
sudo service httpd start
|
Note: To check if Apache is installed, open your browser with your domain name or server’s IP address (e.g. http://192.168.198.131). The page should display a static page like below:
Installing MySQL database
MySQL is an open-source relational database management system (RDBMS) for organizing data on a server.
Follows these commands to install MySQL:
1
|
sudo yum install mysql–server –y
|
1
|
sudo service mysqld start
|
Once it is done, you should set a root MySQL password. Follow this command to set it:
1
|
sudo mysql_secure_installation
|
Note: A prompt will ask you for your current root password as you have just installed MySQL, so leave it blank by pressing enter.
Configure MySQL according to your need. If you don’t want to go through all that, then allow all the prompts ( press ‘y’ for every prompt).
Installing PHP
PHP is server-side scripting language, designed for web development. PHP is a powerful tool for making dynamic and interactive Web pages. It is also used as a general-purpose programming language.
Follow the below mentioned commands to install php:
1
|
sudo yum install php –y
|
Install php-mysql plugin into Linux server
1
|
sudo yum install php–mysql –y
|
Note: Press ‘y’ if prompt comes up.
Now LAMP stack is configured on your instance.
Next, We need to set the ‘httpd’ and ‘mysqld’ processes to run automatically every time the Linux server restarts. We don’t need to do for php because it will run automatically once Apache starts.
1
|
sudo chkconfig httpd on
|
1
|
sudo chkconfig mysqld on
|
1
|
sudo service httpd restart
|
Once you have the prerequisite software, you can start installing WordPress!
Installing WordPress
Step 1: First, download WordPress from below link:
1
|
wget http://wordpress.org/latest.tar.gz
|
Step 2: Unzip the compressed file into desired location.
1
|
tar –xvzf latest.tar.gz
|
Step 3: Creating MySQL User and database for WordPress-
Login to MySQL Shell:
1
|
mysql –u root –p
|
A prompt will ask for MySQL root password, which we have created earlier.
Now, We need a database and an user in that database.
1
|
create database wp_db;
|
Output: Query OK, 1 row affected (0.00 sec)
1
|
create user wp_user;
|
Set password to this user:
1
|
Set password for wp_user=password(“password”);
|
Now, provide all privileges to this new user.
1
|
grant all privileges on wp_db.* to wp_user identified by ‘password’;
|
Query OK, 0 rows affected (0.00 sec)