How To Install WordPress On CentOS 7 Linux
How To Install WordPress On CentOS 7 Linux
CentOS Linux is a community – supported distribution derived from sources freely provided to the public by Red Hat for Red Hat Enterprise Linux (RHEL). As such, CentOS Linux aims to be functionally compatible with RHEL. The CentOS Project mainly changes packages to remove upstream vendor branding and artwork. CentOS Linux is no-cost and free to redistribute. Each CentOS version is maintained for up to 10 years (by means of security updates — the duration of the support interval by Red Hat has varied over time with respect to Sources released). A new CentOS version is released approximately every 2 years and each CentOS version is periodically updated (roughly every 6 months) to support newer hardware. This results in a secure, low-maintenance, reliable, predictable and reproducible Linux environment.
What is WordPress?
WordPress is an open source website creation tool or content management system (CMS) based on PHP and MySQL. Matt Mullenweg and Mike Little programmed WordPress back on 2003. This is the most easiest static (can be developed for dynamic also) website content management system (or CMS) that exists.
WordPress is a free and license under GPLv2 (or later) from the Free Software Foundation. According to a survey report, WordPress was used by more than 23.3% of the top 10 million websites. WordPress is one of the most popular blogging system used on the Web.
- Different free & paid themes for different different UI & UX
- Plugins for different services & functionalities
- Mobiles (Responsive views)
- Multi-user & multi-blogging
To know more about WordPress, . To download latest WordPress from here.
To install WordPress, we will need these following thing that needs to be installed or available on our CentOS 7 Linux server.
- Apache or Nginx as web server
- PHP version 5.6 or greater
- MySQL / MariaDB version 5.6 or greater as database
Legacy or older version of PHP & MySQL can drive WordPress but not recommended from their official page.
Also, make sure your firewall / iptables or SELinux is not blocking any port(s) which is required over here or you don’t have any problem with proper user permission.
To disable SELinux, type the following
Let’s update the CentOS 7 Linux server first. This is a good practise to keep your server up to date. To do so, issue the below command one after another and wait till it gets updated. It will depends on your internet speed and it will take a long. So, please have patience.
sudo yum clean allsudo yum -y update
You will see something like below image once you are done with it. Depending on how old your system softwares are or which packages are needs to be updated. The below image indicates an successful update and may require to reboot system as well.
Installing Apache as web server
To install Apache on your CentOS 7, issue the below command on your terminal.
sudo yum -y install httpd
This will download and install Apache as a web server on the system.
Let’s start Apache by issuing the below command.
sudo systemctl start httpd
Set Apache at start or booting time so after every reboot, it get started automatically without manual start.
sudo systemctl enable httpd
To test apache issue the below command.
sudo systemctl status httpd
This will show the status of Apache for you.
Or you can open a web browser and type “localhost” without the double quote in to the address bar. You will see something like this.
It indicates that our web server up and running ?
You may need to enable mod_rewrite module as well. Just open the file located on /etc/httpd/conf/httpd.conf by your faviourute file editor and change the following line
We are done with Apache.
Installing MySQL / MariaDB
To install MySQL / MariaDB on to your system, issue the below command.
sudo yum install mariadb-server mariadb
This will download and install MySQL / MariaDB on to the system.
To start the MariaDB server, issue the below command.
sudo systemctl start mariadb
Now, we need to set the password for the “root” user of MySQL / MariaDB. Let’s do it by typing the following and this is must for security reason.
You will see something like this. Hit Y to continue and type a complex password and remember it.
After setting the root password, you will see something like below image.
Now, you will get few prompts on your terminal with Y/N options.
Hit Y for the prompt “Remove anonymous users?”
Hit Y for the prompt “Disallow root login remotely?”
Hit Y for the prompt “Remove test database and access to it?”
Hit Y for the prompt “Reload privilege tables now?”
After finishing all the prompts, you will see something like below.
We are done with MySQL / MariaDB.
To install PHP, open a terminal and issue the below command.
sudo yum -y install php php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl
This will download and install PHP on your CentOS 7 system along with some others PHP modules which are required for WordPress.
To install phpMyAdmin, issue the below command in the terminal.
sudo yum -y install epel-release
And then issue the below command again.
sudo yum -y install phpmyadmin
After installing PHP, we need to restart the Apache or other web server in order to work with PHP. Type the following to do so.
sudo systemctl restart httpd.service
To test whether you can access phpMyAdmin or not, open any web browser and type the following in the address bar.
You will see something like this.
We are done installing PHP.
Download the latest WordPress from here. Or use the below command to download it.
sudo wget https://wordpress.org/latest.zip
After downloading the zip archive file, let’s unzip it by typing the below command on the terminal.
sudo unzip latest.zip
After successful unzipping, you will see a folder named “wordpress”. Now, copy this “wordpress” folder to the /var/www/html folder path by doing the following.
sudo cp -avr wordpress /var/www/html
Now, move to the /var/www/html folder and issue the below two commands.
sudo chmod -R 775 wordpresssudo chown apache:apache wordpress
Now, type the following in your web browser address bar.
You will see the below image. Click “Let’s go!” for continue.
After clicking “Let’s go!” button, you will see something like this.
Now, we need to create a database with a name whatever you wish for installing WordPress.
Let’s create the database then. To do so, open the web browser and type the following.
Then it will ask for a user name & password. Type “root” as user name and the password that you had set earlier while installing MySQL/ MariaDB. I hope that you can remember that. Once you are logged in, you will see something like this.
Now click New from the left top corner marked as red in the following image.
After clicking New, you will see this. Type a database name and click “Create” button. Here, I am typing iftekher for my database name. You can type whatever you wish.
We are done creating our database for installing WordPress.
Now move back to the WordPress installation.
Type the database name as iftekher (As I set iftekher as my database name), user name as root, root password and leave database host and table prefix as it is. It should look like below image. Click submit button to continue.
After this, you will see a similar image like below and you need to click “Run the install” button.
Then, you will see a welcome screen just like below asking for your WordPress site title, user name, password which are related to your WordPress site. Type your the site title, type admin as user name and choose a hard password and enter your email address and click “Install WordPress”.
Then you will get a message that WordPress has been successfully installed on your CentOS7.
Now, type the following in your web browser address bar and you will see something like this.
So we are done with installing WordPress on our CentOS 7 Linux server.