Install WordPress on localhost Linux machine with LAMP to create a powerful and dynamic website. This guide will walk you through the process of setting up a LAMP stack (Linux, Apache, MySQL/MariaDB, PHP) on an Enterprise Linux server, including RHEL, CentOS, Rocky Linux, and Alma Linux. You’ll learn how to configure both HTTP (port 80) and HTTPS (port 443) for your site. Whether you’re a beginner or an experienced user, the instructions are designed to be easy to follow. Let’s get started on building your WordPress site!

Table of Contents
- Prerequisites to install wordpress
- Step 1: Update Your Server to Install WordPress
- Step 2: Install Apache to Install WordPress
- Step 3: Install MySQL or MariaDB to Install WordPress
- Step 4: Install PHP
- Step 5: Create a MariaDB Database and User for WordPress
- Step 6: Download and install WordPress
- Step 7: Configure Apache to install WordPress
- Step 8: Install SSL Certificate
- Step 9: Configure Apache for HTTPS
- Step 10: Complete the WordPress Installation Through the Web Interface
- Step 11: Secure Your WordPress Installation
- Conclusion
Prerequisites to install wordpress
- A Enterprise Linux server (RHEL, CentOS, Rocky Linux, Alma Linux 8 or 9)
- A non-root user with sudo privileges
- Basic knowledge of terminal commands
- Domain name (optional but recommended)
Step 1: Update Your Server to Install WordPress
Before installing any software, it’s crucial to update your server to ensure that you have the latest security patches and software versions. This step helps maintain the stability and security of your system.
sudo dnf update
Step 2: Install Apache to Install WordPress
After updating your server, the next crucial step is to install Apache, which is a popular web server software that will host your WordPress site. Apache is known for its reliability and performance, making it an excellent choice for running WordPress.
To install Apache, follow these steps:
sudo dnf install httpd
Enable Apache to start on boot and start it now:
sudo systemctl enable httpd
sudo systemctl start httpd
Step 3: Install MySQL or MariaDB to Install WordPress
WordPress relies on a database management system to store and manage its data, including posts, pages, comments, and user information. MySQL and MariaDB are the two most commonly used database systems for WordPress. MariaDB is a fork of MySQL and is often preferred for its performance improvements and additional features.
Installing MariaDB
sudo dnf install mariadb-server
Enable MariaDB to start on boot and start it now:
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure the MariaDB installation:
sudo mysql_secure_installation
During the secure installation, you’ll be prompted to set a root password and make several security choices. Follow the on-screen instructions. You can check this article for detail installation and configuration of mariadb
Installing MySQL
If you prefer to install MySQL instead of MariaDB, you can use the following commands:
sudo yum install mysql-server
Enable mysql to start on boot and start it now:
sudo systemctl enable mysqld
sudo systemctl start mysqld
Secure the MariaDB installation:
sudo mysql_secure_installation
Similar to MariaDB, this command will help you secure your MySQL installation.
Step 4: Install PHP
WordPress is built with PHP. Install PHP along with some common modules:
sudo dnf install php php-mysqlnd php-fpm php-json php-cli php-curl php-gd php-xml php-mbstring php-zip
Step 5: Create a MariaDB Database and User for WordPress
Log into MariaDB:
sudo mysql -u root -p
Create a database for WordPress:
CREATE DATABASE wordpress;
Create a new MariaDB user and grant them privileges on the WordPress database:
CREATE USER 'wordpressuser'@'localhost' IDENTIFIED BY 'password';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wordpressuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Replace 'password'
with a strong password of your choice.
You can follow the same steps for MySQL to create a user and grant permissions.
Step 6: Download and install WordPress
Navigate to the /tmp directory and download the latest version of WordPress by following below steps. If you wish to install a specific version of WordPress, you can find it on the official WordPress website.
cd /tmp
wget https://wordpress.org/latest.tar.gz
Extract the downloaded file:
tar -xvzf latest.tar.gz
Move the WordPress files to the Apache root directory:
sudo mkdir /var/www/html/techarticles.in
sudo mv wordpress/* /var/www/html/techarticles.in
Set the proper permissions:
sudo chown -R apache:apache /var/www/html/techarticles.in
sudo chmod -R 755 /var/www/html/techarticles.in
Step 7: Configure Apache to install WordPress
Create a new Apache configuration file for your WordPress site:
sudo vi /etc/httpd/conf.d/magnetbyte.com.conf
Add the following configuration to the file:
<VirtualHost *:80>
ServerAdmin [email protected]
DocumentRoot /var/www/html/magnetbyte.com
ServerName magnetbyte.in
ServerAlias www.magnetbyte.com
<Directory /var/www/html/magnetbyte.com/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/magnetbyte.com-error.log
CustomLog /var/log/httpd/magnetbyte.com-access.log combined
</VirtualHost>
Replace magnetbyte.com
with your domain name.
Enable the Apache rewrite module:
dnf install mod_rewrite
Restart Apache to apply the changes:
sudo systemctl restart httpd
Step 8: Install SSL Certificate
To secure your WordPress site with HTTPS, install an SSL certificate. You can use Let’s Encrypt for a free SSL certificate:
Install Certbot:
sudo dnf install certbot python3-certbot-apache
Obtain and install the SSL certificate:bashCopy code
sudo certbot --apache
Follow the prompts to complete the SSL installation. Certbot will automatically configure Apache to use the SSL certificate.
Step 9: Configure Apache for HTTPS
Ensure your Apache configuration includes the HTTPS virtual host. Edit the wordpress.conf
file:
sudo vi /etc/httpd/conf.d/magnetbyte.com.conf
Add the following HTTPS configuration block:
<VirtualHost *:443>
ServerAdmin [email protected]
DocumentRoot /var/www/html/magnetbyte.com
ServerName magnetbyte.com
ServerAlias www.magnetbyte.com
<Directory /var/www/html/magnetbyte.com/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/magnetbyte.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/magnetbyte.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/magnetbyte.com/chain.pem
ErrorLog /var/log/httpd/magnetbyte.com-error.log
CustomLog /var/log/httpd/magnetbyte.com-access.log combined
</VirtualHost>
Restart Apache to apply the changes:
sudo systemctl restart httpd
Step 10: Complete the WordPress Installation Through the Web Interface
Open your web browser and navigate to http://your_domain_or_IP
or https://your_domain_or_IP
. You should see the WordPress installation page.
Select your language and click “Continue.”
On the next page, enter the database details you created earlier:
- Database Name:
wordpress
- Username:
wordpressuser
- Password: The password you set
- Database Host:
localhost
- Table Prefix:
wp_
(you can change this if you want to run multiple WordPress installations in one database)
Click “Submit” and then “Run the installation.”
Fill in the site information:
- Site Title
- Username
- Password
- Your Email
Click “Install WordPress.”
Step 11: Secure Your WordPress Installation
To enhance the security of your WordPress installation, consider the following steps:
- Regularly Update WordPress, Themes, and Plugins: Ensure you always have the latest security patches.
- Change the Default Login URL: Use a plugin to change the default
/wp-admin
login URL. - Limit Login Attempts: Protect against brute force attacks by limiting the number of login attempts.
Conclusion
In this guide, we have outlined the complete process to configure WordPress in just 11 steps. From installing the necessary components like Apache, MySQL (or MariaDB), and PHP, to creating an Apache virtual host and securing your site with SSL, each step is crucial for setting up a robust and secure WordPress environment.