How To Install WordPress On CentOS 7 With LAMP (Tutorial)
WordPress + LAMP is the classic web hosting setup.
Sure, there are other software stack options for hosting WordPress (some of our team is partial to LEMP). But in terms of wide implementation and usage for websites across the globe, nothing compares to WordPress with LAMP.
So today we'll show you how to get serve your website to the world by installing WordPress on CentOS 7 using a LAMP stack.
Only $89/yr for 32GB RAM and
320GB 480GB NVMe and free backups for LIFE!
Celebrating our 9 year anniversary! Capacity is limited and some deals will sell out. Get yours before they are gone!
Want to install WordPress but not on CentOs?
👉Click here for our WordPress + Ubunbu 18.04 tutorial
👉Click here for our WordPress + Debian 9 tutorial
WordPress is a powerhouse—over 34% of all websites online today use it—that’s over 22 million websites.
And for sites using a CMS (content management system), it towers over the competition with 60% of the market share.
Meanwhile, Apache (a key piece of the LAMP stack) is the world’s most popular web server.
So, you can see why having the WordPress/LAMP installation in your pocket is key for any developer or anyone looking to host their own blog or website.
In this tutorial, I will show you how to install WordPress with LAMP on Centos 7.
Before we get started, you'll need to have the following set up:
- An instance of CentOS 7
- SSH access to the server
- User with sudo privileges.
- A good internet connection
With all the prerequisites in place, let’s dive in!
The latest version of WordPress requires PHP 7.3 or later, so you'll need to install the Remi repository first.
To achieve this, execute the command:
$ sudo yum -y install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
By default, CentOS 7 ships with PHP 5.4 which is no longer supported by developers and isn't compatible with the latest WordPress version (WordPress 5.2.2). So you'll need to disable PHP 5.4 using the yum config manager which is provided by the yum-utils tool.
To do this, first, install
$ sudo yum install yum-utils
Next, disable PHP 5.4.
$ sudo yum-config-manager --disable remi-php54
And now enable PHP 7.3 as shown.
$ sudo yum-config-manager --enable remi-php73
To verify that you have PHP 7.3 installed in your system, run the following command.
$ php -v
Since WordPress is both a front-end and back-end system and most of the administration will be done via browser, you need to install a LAMP stack to handle all that. LAMP is an acronym for Linux, Apache, MySQL, and PHP.
For this guide, I will use MariaDB which is a fork of MYSQL and provides superior performance.
To install the LAMP stack execute the command below.
$ sudo yum install httpd mariadb mariadb-server php php-common php-mysql php-gd php-xml php-mbstring php-mcrypt
With all the components installed, let’s start the Apache webserver.
$ sudo systemctl start httpd
To enable Apache on boot, run
$ sudo systemctl enable httpd
Next, you need to start the MariaDB database server. Run the command
$ sudo systemctl start mariadb
Again, to enable it on boot, run
$ sudo systemctl enable mariadb
By default, MariaDB does not provide protection against anonymous users. Therefore, we need to manually harden the security of the MariaDB server by running the following command.
$ sudo mysql_secure_installation
Answer all the questions with the security of the database server in mind. Be sure to disallow anonymous login and remote root login, and remove the test database. Finally, flush privileges for the changes to take effect.
With MariaDB installed and secured, it's time to create a database to accommodate WordPress files during & after the installation.
Log in to the database server.
$ sudo mysql -u root -p
Create a database for WordPress.
CREATE DATABASE wordpressdb;
Query OK, 1 row affected (0.00 sec)
Next, create a user that will be associated with the WordPress database
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongPassword!';
Query OK, 0 rows affected (0.00 sec)
Next, grant all permissions to the user on the database
GRANT ALL ON wordpressdb.* TO 'wordpress_user'@'localhost';
Query OK, 0 rows affected (0.00 sec)
Finally, flush the privileges to save all the changes.
Query OK, 0 rows affected (0.00 sec)
To exit from the database server, run
To apply the changes, restart the MariaDB server by running the following command.
$ sudo systemctl restart mariadb
With the WordPress database already created, proceed and download the WordPress tarball from WordPress repository as shown.
$ cd /tmp && sudo wget http://wordpress.org/latest.tar.gz
This downloads the WordPress tarball in the /tmp directory
Next, extract the WordPress tarball file a shown.
$ sudo tar -xvf latest.tar.gz
This extracts the tarball into a folder labeled wordpress. This contains all the WordPress files that will be essential as we move along.Move the ‘WordPress’ folder to the Webroot directory /var/www/html a shown
$ sudo mv wordpress /var/www/html/
At this point, you need to change permissions of the WordPress folder to user ‘Apache’ as shown
$ sudo chown -R apache:apache /var/www/html/wordpress
Also, be sure to change file permissions as shown below
$ sudo chmod -R 755 /var/www/html/wordpress
Next, you need to create the upload directory manually as shown.
$ sudo mkdir -p /var/www/html/wordpress/wp-content/uploads
We need to give the Apache webserver rite permissions to the newly created uploads folder. This will enable Apache to create directories and files.
Issue the command below to accomplish this
$ chown -R :apache /var/www/html/wordpress/wp-content/uploads
Next, navigate to the WordPress directory.
$ cd /var/www/html/wordpress/
Proceed and rename the wp-config-sample.php to wp-config.php as shown:
$ mv wp-config-sample.php wp-config.php
Open the newly renamed file using your favorite text editor. I will be using the default editor Vim.
$ sudo vim wp-config.php
Scroll and locate the database settings as shown
Fill out the database details accordingly as defined when creating the WordPress database in Step 3 above.
In our case, the details are shown.
Save and exit the text editor.
At this point, you’ve finished all the server configurations for your WordPress installation.
The final step is to complete the installation via a web browser.
To do this, launch your web browser and browser your server’s IP address or domain name
The first page will prompt you to select the language.
Click on your preferred language and hit the ‘Continue’ button.
In the next step fill in the additional information required such as ‘Site Name’, ‘Username’ , ‘Password’, and ‘Email address’.
Once you’ve filled in all the required fields, click on ‘Install WordPress’
If all went well, you will be directed to a "Success" page. Click the "Login" button to head to your login page.
Fill in your credentials to log in and you'll head to the world-famous WordPress dashboard that you see here:
It's as simple as that-- if you've made it this far then, you’ve installed WordPress with LAMP on CentOS 7.
So, now you’re ready to get to work designing your new blog or website and creating some killer content for your visitors.
If you are just getting started with WordPress, the good news is that there are TONS of free resources for learning and customization. If you were able to install LAMP on your server and execute the WordPress setup, then WordPress itself should be a piece of cake!
If you finished this tutorial then you obviously already have a server…
But if you’d like to slash your hosting bill while boosting your performance stats, then you should consider the Performance VPS from SSD Nodes.
The Performance VPS features NVMe storage, which is like strapping a rocket engine to your CMS. Load media-heavy webpages up to 10x faster than with standard SSD drives.
And with high-resource plans, you can easily host multiple websites and scale your growth affordably.
You can get started for as little as $9.99/month for an 8GB RAM VPS.