WordPress remains the most popular content management system (CMS) worldwide, powering millions of websites ranging from personal blogs to enterprise-level platforms. AlmaLinux 8, a community-driven Linux distribution, offers a stable and secure environment for hosting WordPress. This guide provides a comprehensive, step-by-step walkthrough for installing WordPress on AlmaLinux 8 using the LAMP stack (Linux, Apache, MySQL/MariaDB, and PHP). By following this tutorial, you will be able to set up a fully functional WordPress site optimized for performance and security.
Prerequisites
Before beginning the installation process, ensure you have the following:
- AlmaLinux 8 server: A VPS or dedicated server running AlmaLinux 8.
- Root or sudo access: Administrative privileges are required to install and configure packages.
- Basic knowledge of Linux commands: Familiarity with the terminal will help you follow the steps smoothly.
- Domain name: Optional but recommended for production websites.
- Firewall access: Ensure ports 80 (HTTP) and 443 (HTTPS) are open.
Step 1: Update AlmaLinux 8
Keeping your server updated ensures you have the latest security patches and software versions. Run the following commands:
sudo dnf update -y
This command updates all installed packages to their latest versions.
Enable EPEL Repository
Some dependencies may require the Extra Packages for Enterprise Linux (EPEL) repository. Install it with:
sudo dnf install epel-release -y
Step 2: Install Apache Web Server
Apache is one of the most widely used web servers. Install it with:
sudo dnf install httpd -y
Enable and start Apache:
sudo systemctl enable httpd
sudo systemctl start httpd
Verify Apache is running:
sudo systemctl status httpd
Configure Firewall for Apache
Allow HTTP and HTTPS traffic:
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
Step 3: Install MariaDB Database Server
WordPress requires a database to store content and settings. MariaDB is a reliable choice. Install it with:
sudo dnf install mariadb-server mariadb -y
Enable and start MariaDB:
sudo systemctl enable mariadb
sudo systemctl start mariadb
Secure MariaDB Installation
Run the security script:
sudo mysql_secure_installation
Follow the prompts to set a root password, remove anonymous users, disable remote root login, and remove test databases.
Step 4: Install PHP
WordPress is built on PHP. Install PHP and required extensions:
sudo dnf install php php-mysqlnd php-fpm php-xml php-json php-gd php-curl php-mbstring -y
Restart Apache to load PHP:
sudo systemctl restart httpd
Verify PHP Installation
Create a test file:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
Visit http://your_server_ip/info.php to confirm PHP is working.
Step 5: Create WordPress Database
Log into MariaDB:
sudo mysql -u root -p
Create a database and user:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'strongpassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Step 6: Download and Configure WordPress
Download WordPress:
wget https://wordpress.org/latest.tar.gz
Extract files:
tar -xvzf latest.tar.gz
sudo mv wordpress/* /var/www/html/
Set Permissions
Ensure Apache can access WordPress files:
sudo chown -R apache:apache /var/www/html/
sudo chmod -R 755 /var/www/html/
Step 7: Configure Apache for WordPress
Create a virtual host configuration:
sudo nano /etc/httpd/conf.d/wordpress.conf
Add the following:
<VirtualHost *:80>
ServerAdmin admin@example.com
DocumentRoot /var/www/html/
ServerName example.com
ServerAlias www.example.com
<Directory /var/www/html/>
AllowOverride All
</Directory>
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>
Enable mod_rewrite:
sudo dnf install mod_ssl -y
sudo systemctl restart httpd
Step 8: Complete WordPress Installation
Open your browser and navigate to your server’s domain or IP. You will see the WordPress installation wizard. Enter the database name, username, and password you created earlier. Configure your site title, admin username, and password. Once completed, WordPress will be ready to use.
Pro Tips
- Use SSL certificates: Secure your site with Let’s Encrypt for HTTPS.
- Optimize PHP settings: Adjust memory limits and execution times for better performance.
- Regular backups: Automate backups to prevent data loss.
- Install caching plugins: Improve site speed with plugins like W3 Total Cache.
- Keep WordPress updated: Regularly update WordPress core, themes, and plugins.
- Use strong passwords: Protect your admin account with complex credentials.
- Monitor server logs: Regularly check logs for unusual activity.
Frequently Asked Questions
Can I use Nginx instead of Apache?
Yes, WordPress works with Nginx. However, this guide focuses on Apache for simplicity.
Is MariaDB better than MySQL for WordPress?
Both are compatible. MariaDB is often preferred for its performance and open-source nature.
How do I enable HTTPS?
Install Certbot and configure Let’s Encrypt SSL certificates for your domain.
Can I migrate an existing WordPress site?
Yes, you can export your content and import it into the new installation using plugins or manual migration.
What if I forget my WordPress admin password?
You can reset it via the WordPress login page or directly in the database using phpMyAdmin or MySQL commands.
Conclusion
Installing WordPress on AlmaLinux 8 with the LAMP stack provides a robust and secure environment for building websites. By following this step-by-step guide, you can set up a fully functional WordPress site optimized for performance, scalability, and security. With proper configuration, regular updates, and best practices, your WordPress installation will serve as a reliable foundation for any online project.








