WordPress is the most popular Content Management System (CMS) on the Internet. Powering over 60% of websites, the platform is a great choice for web designers and developers due to its easy-to-use tools.
To run WordPress on your server, a web server stack like the Linux, Apache, MySQL, PHP (LAMP) combination works best to host websites on your server. In this guide, you will install WordPress on a LAMP configuration CentOS 7 server.
Create a MySQL Database
With the LAMP Stack installed on your CentOS 7 server, you need to create a database that WordPress will use to create new tables necessary for the CMS functions. By default, CentOS 7 supports the MariaDB database and not the base MySQL. However, all commands and table structures remain the same because MariaDB is a free fork of MySQL.
Log into MariaDB as root and create a new WordPress database.
create database myexample;
Create a new database user and assign it a password.
CREATE USER 'user'@'localhost' IDENTIFIED BY '12345678Aa';
Now, grant the user full rights to the new WordPress database.
MariaDB [(none)]> use myexample;
MariaDB [myexample]> GRANT ALL PRIVILEGES ON myexample.* TO 'user'@'localhost';
Exit the console.
MariaDB [myexample]>EXIT
Install PHP and Extensions
On CentOS 7, PHP 5.4 is the base supported version, but WordPress requires PHP 7.4 and above to run. So, let’s install PHP 7.4 through the Remi repository.
$ sudo yum install -y http://rpms.remirepo.net/enterprise/remi-release-7.rpm
Update yum.
$ sudo yum update
Now, run the command below to install PHP 7.4 and all necessary extensions.
$ sudo yum --enablerepo=remi-php74 install php php-bz2 php-mysql php-curl php-gd php-intl php-common php-mbstring php-xml
After installation is complete, restart Apache to enable PHP and extensions for hosted websites.
$ sudo systemctl restart httpd
Install WordPress
To install WordPress, you need to download the latest tar achieve from WordPress.org using wget.
Install wget
$ sudo yum install wget
Use wget to download the latest WordPress version.
$ wget http://WordPress.org/latest.tar.gz
Unzip the downloaded WordPress tar archive.
$ sudo tar -xzvf latest.tar.gz
Now, move the extracted file contents to /var/www/html
.
$ sudo mv WordPress/* /var/www/html/
Next, change ownership of the html directory to the web server user and its associated group for full read, write, execute permissions.
$ sudo chown -R apache.apache /var/www/html/
Configure WordPress
Visit your public server IP or associated domain name to start the WordPress web installer in a web browser.
http://YOUR_SERVER_IP OR http://YOUR_DOMAIN_NAME
You will be presented a Welcome to WordPress page, click Lets go
to start the installation process.
Next, enter your database name, username, and associated password to connect WordPress and the database server.
Once a connection is established, enter your preferred website title, administrator username, password, and email address to configure your WordPress installation.
Success, WordPress will be installed on your server. Now, click login to enter your administrator username and password to proceed with building your first website.
Congratulations, once WordPress is up and running on your web server, you can build and design dynamic websites on the worlds most popular content management system (CMS).