How to Install WordPress with LAMP on CentOS 8

Install WordPress with LAMP on CentOS 8

In this article, we will have explained the necessary steps to install and configure WordPress with LAMP on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

WordPress is the world’s leading content management system. Used by tens of millions of web pages and internet creators alike, WordPress is the backbone of most blogs, business websites, e-commerce stores, and much more. Webpage performance with WordPress is also typically one of the fastest available.

Install WordPress with LAMP on CentOS 8

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo dnf update

Step 2. Install LAMP stack on CentOS server.

It is assumed that you have already installed the LAMP stack on CentOS 8. If not, please check out the following tutorial:

Step 3.Install WordPress on the CentOS system.

WordPress is not available in the official package repository of CentOS 8. So, you must download it from the official website:

cd /var/www/html
wget -c

Then, extract the archived file:

tar -xzvf latest.tar.gz

Change the owner and set the correct permissions for these files, you need to run the following command:

sudo chown -R www-data:www-data /var/www/html/wordpress

Step 4. Create a Database for WordPress.

WordPress uses the MariaDB database to store all its data like posts, pages, users, plugins, and themes settings. Log in to your MariaDB server with the following command and enter your MariaDB root password:

mysql -u root -p

Once you’re in the MariaDB console, create a new database:

CREATE DATABASE wordpress_db;
CREATE USER [email protected] IDENTIFIED BY 'your-strong-password';
GRANT ALL PRIVILEGES ON wordpress_db.* TO [email protected];

Once the database is created, we will need to add this information to the WordPress configuration file:

cd /var/www/html/wordpress
mv wp-config-sample.php wp-config.php

Now open the wp-config.php file with your favorite text editor, for example:

// ** MySQL settings - You can get this info from your web host ** //
/** The name of the database for WordPress */
define('DB_NAME', 'wordpress_db');

/** MySQL database username */
define('DB_USER', 'wordpress_user');

/** MySQL database password */
define('DB_PASSWORD', 'your-strong-password');

/** MySQL hostname */
define('DB_HOST', 'localhost');

/** Database Charset to use in creating database tables. */
define('DB_CHARSET', 'utf8');

/** The Database Collate type. Don't change this if in doubt. */
define('DB_COLLATE', '');

Step 5. Configure Apache.

Now configure Apache server to host WordPress. Create a configuration file with an Alias to WordPress directory:

sudo nano /etc/httpd/conf.d/wordprees.conf

Now, type in the following lines of codes in the wordpress.conf file:

<VirtualHost *:80>
ServerAdmin root@localhost
DocumentRoot /var/www/html/wordpress<Directory "/var/www/html/wordpress">
Options Indexes FollowSymLinks
AllowOverride all
Require all granted</Directory>
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log common</VirtualHost>

Save the file and close it. Now, restart the Apache service to reload changes:

sudo systemctl restart httpd

Step 6. Configure Firewall.

To allow external users to access WordPress from your server, you need to open the webserver port 80:

sudo firewall-cmd --add-port=80/tcp --zone=public --permanent
sudo firewall-cmd --reload

Step 7. Accessing WordPress.

Now you can access the WordPress web install wizard in your browser by entering the domain name for your WordPress installation:


Then click Continue and type site title, Username, Password, and Your Email. Now click Install WordPress.

That’s all you need to do to install WordPress on CentOS 8. I hope you find this quick tip helpful. For further reading on WordPress with LAMP, please refer to their official knowledge base. If you have questions or suggestions, feel free to leave a comment below.