๐ Installing WordPress on AlmaLinux: Complete LAMP Stack Guide
Ready to launch your website or blog? ๐ Today weโll install WordPress on AlmaLinux with a complete LAMP stack (Linux, Apache, MySQL, PHP)! Whether youโre creating a personal blog, business website, or online store, this guide makes it super easy - even if youโve never done it before! ๐ฏ
๐ค Why is WordPress on AlmaLinux Important?
Running WordPress on AlmaLinux delivers amazing benefits:
- ๐ Rock-solid stability - Enterprise-grade Linux for reliable hosting
- ๐ง Complete control - Your server, your rules, no limitations
- ๐ Blazing fast performance - Optimized stack for speed
- ๐ Enhanced security - Full control over security settings
- โญ Cost-effective - No hosting fees, just your server costs
๐ฏ What You Need
Before starting your WordPress journey:
- โ AlmaLinux 8 or 9 server (fresh installation preferred)
- โ Root or sudo access to your server
- โ Domain name pointed to your server (optional but recommended)
- โ At least 1GB RAM and 10GB disk space
- โ Basic terminal knowledge (weโll guide you!)
๐ Step 1: Install Apache Web Server
Letโs start with Apache, your web server! ๐
Install and Configure Apache
# Update your system first
sudo dnf update -y
# Install Apache web server
sudo dnf install httpd -y
# Start and enable Apache to run at boot
sudo systemctl start httpd
sudo systemctl enable httpd
# Check Apache status
sudo systemctl status httpd
# You should see "active (running)" in green!
# Allow HTTP and HTTPS through firewall
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo firewall-cmd --reload
echo "โ
Apache installed successfully!"
Test Apache Installation
# Get your server's IP address
ip addr show | grep inet
# Open your browser and visit:
# http://YOUR_SERVER_IP
# You should see the Apache test page!
# Create a test page
echo "<h1>Apache is working! ๐</h1>" | sudo tee /var/www/html/test.html
# Visit http://YOUR_SERVER_IP/test.html to confirm
Pro tip: ๐ก If you canโt access Apache, check your cloud providerโs firewall settings - they might block HTTP/HTTPS by default!
๐ง Step 2: Install MySQL/MariaDB Database
WordPress needs a database to store your content:
Install MariaDB
# Install MariaDB (MySQL compatible database)
sudo dnf install mariadb-server mariadb -y
# Start and enable MariaDB
sudo systemctl start mariadb
sudo systemctl enable mariadb
# Secure your MariaDB installation
sudo mysql_secure_installation
# Follow the prompts:
# - Enter current password (press Enter for none)
# - Set root password: Y (Choose a strong password!)
# - Remove anonymous users: Y
# - Disallow root login remotely: Y
# - Remove test database: Y
# - Reload privilege tables: Y
echo "โ
MariaDB secured and ready!"
Create WordPress Database
# Log into MariaDB
sudo mysql -u root -p
# Enter the root password you just created
# Create database and user for WordPress
CREATE DATABASE wordpress_db;
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;
# Verify database creation
mysql -u wordpress_user -p -e "SHOW DATABASES;"
# You should see wordpress_db in the list!
Security note: ๐ Always use strong passwords! Replace โStrongPassword123!โ with your own secure password!
๐ Step 3: Install PHP and Required Modules
WordPress is built with PHP, so letโs install it:
Install PHP 8.0 and Extensions
# Enable EPEL and Remi repositories for PHP 8
sudo dnf install epel-release -y
sudo dnf install https://rpms.remirepo.net/enterprise/remi-release-8.rpm -y
# Reset PHP module and enable PHP 8.0
sudo dnf module reset php -y
sudo dnf module enable php:remi-8.0 -y
# Install PHP and required extensions for WordPress
sudo dnf install php php-mysqlnd php-fpm php-opcache php-gd php-xml php-mbstring php-json php-zip php-curl -y
# Check PHP version
php -v
# Should show PHP 8.0.x
# Restart Apache to load PHP
sudo systemctl restart httpd
Test PHP Installation
# Create a PHP info file
echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
# Visit http://YOUR_SERVER_IP/info.php
# You should see PHP configuration page!
# Remove the info file for security
sudo rm /var/www/html/info.php
echo "โ
PHP installed and configured!"
Configure PHP for WordPress
# Optimize PHP settings for WordPress
sudo tee /etc/php.d/wordpress.ini << 'EOF'
; WordPress Optimizations
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
max_input_time = 300
memory_limit = 256M
EOF
# Restart Apache to apply changes
sudo systemctl restart httpd
โ Step 4: Download and Install WordPress
Now for the main event - WordPress installation! ๐
Download WordPress
# Navigate to temporary directory
cd /tmp
# Download latest WordPress
wget https://wordpress.org/latest.tar.gz
# Extract WordPress archive
tar -xzvf latest.tar.gz
# Move WordPress to web root
sudo mv wordpress /var/www/html/
# Set proper ownership
sudo chown -R apache:apache /var/www/html/wordpress
# Set proper permissions
sudo chmod -R 755 /var/www/html/wordpress
# SELinux context (if SELinux is enabled)
sudo semanage fcontext -a -t httpd_sys_rw_content_t "/var/www/html/wordpress(/.*)?"
sudo restorecon -Rv /var/www/html/wordpress
echo "โ
WordPress files ready!"
Configure WordPress Database Connection
# Navigate to WordPress directory
cd /var/www/html/wordpress
# Copy sample configuration file
sudo cp wp-config-sample.php wp-config.php
# Edit configuration file
sudo nano wp-config.php
# Update these lines with your database details:
# define('DB_NAME', 'wordpress_db');
# define('DB_USER', 'wordpress_user');
# define('DB_PASSWORD', 'StrongPassword123!');
# define('DB_HOST', 'localhost');
# Generate security keys (copy the output)
curl -s https://api.wordpress.org/secret-key/1.1/salt/
# Paste the security keys in wp-config.php
# (Replace the existing dummy keys)
Configure Apache for WordPress
# Create Apache configuration for WordPress
sudo tee /etc/httpd/conf.d/wordpress.conf << 'EOF'
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html/wordpress
ServerName your-domain.com
ServerAlias www.your-domain.com
<Directory /var/www/html/wordpress/>
Options FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/httpd/wordpress_error.log
CustomLog /var/log/httpd/wordpress_access.log combined
</VirtualHost>
EOF
# Enable .htaccess for permalinks
sudo tee /var/www/html/wordpress/.htaccess << 'EOF'
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
</IfModule>
# END WordPress
EOF
# Set ownership for .htaccess
sudo chown apache:apache /var/www/html/wordpress/.htaccess
# Restart Apache
sudo systemctl restart httpd
Whatโs happening: ๐
- WordPress files are placed in the web directory
- Database connection is configured
- Apache is set up to serve WordPress
- Permalinks are enabled for SEO-friendly URLs
๐ฎ Quick Examples
Example 1: Complete WordPress Setup with SSL ๐
# Install Certbot for Let's Encrypt SSL
sudo dnf install certbot python3-certbot-apache -y
# Obtain SSL certificate (replace with your domain)
sudo certbot --apache -d your-domain.com -d www.your-domain.com
# Follow the prompts:
# - Enter email address
# - Agree to terms
# - Choose whether to redirect HTTP to HTTPS (recommended: yes)
# Auto-renewal setup
sudo systemctl enable certbot-renew.timer
sudo systemctl start certbot-renew.timer
echo "โ
WordPress with SSL ready at https://your-domain.com"
Example 2: WordPress Performance Optimization โก
# Install caching and optimization tools
sudo dnf install memcached php-pecl-memcached -y
# Start memcached
sudo systemctl start memcached
sudo systemctl enable memcached
# Configure memcached for WordPress
echo "extension=memcached.so" | sudo tee /etc/php.d/25-memcached.ini
# Enable Apache caching modules
sudo dnf install mod_cache mod_cache_disk -y
# Configure Apache caching
sudo tee /etc/httpd/conf.d/cache.conf << 'EOF'
<IfModule mod_cache_disk.c>
CacheEnable disk /
CacheRoot /var/cache/httpd
CacheDirLevels 2
CacheDirLength 1
CacheMaxFileSize 1000000
</IfModule>
EOF
# Restart services
sudo systemctl restart httpd
sudo systemctl restart php-fpm
echo "โ
Performance optimizations applied!"
Example 3: Automated WordPress Backup ๐พ
# Create backup script
sudo tee /usr/local/bin/backup-wordpress.sh << 'EOF'
#!/bin/bash
# WordPress Backup Script
BACKUP_DIR="/backup/wordpress"
DATE=$(date +%Y%m%d_%H%M%S)
SITE_DIR="/var/www/html/wordpress"
DB_NAME="wordpress_db"
DB_USER="wordpress_user"
DB_PASS="StrongPassword123!"
# Create backup directory
mkdir -p $BACKUP_DIR
# Backup database
mysqldump -u $DB_USER -p$DB_PASS $DB_NAME > $BACKUP_DIR/db_$DATE.sql
# Backup WordPress files
tar -czf $BACKUP_DIR/files_$DATE.tar.gz $SITE_DIR
# Keep only last 7 days of backups
find $BACKUP_DIR -type f -mtime +7 -delete
echo "Backup completed: $DATE"
EOF
# Make script executable
sudo chmod +x /usr/local/bin/backup-wordpress.sh
# Add to cron for daily backups
echo "0 2 * * * /usr/local/bin/backup-wordpress.sh" | sudo tee -a /etc/crontab
echo "โ
Automated daily backups configured!"
๐จ Fix Common Problems
Problem 1: Cannot Access WordPress Site โ
Symptoms:
- Browser shows โThis site canโt be reachedโ
- Connection timeout errors
Try this:
# Check if Apache is running
sudo systemctl status httpd
# Check firewall rules
sudo firewall-cmd --list-all
# Check SELinux status
getenforce
# If SELinux is enforcing, allow httpd network connect
sudo setsebool -P httpd_can_network_connect 1
# Restart Apache
sudo systemctl restart httpd
Problem 2: Database Connection Error โ
Try this:
# Test database connection
mysql -u wordpress_user -p -D wordpress_db
# If connection fails, recreate user
mysql -u root -p
DROP USER 'wordpress_user'@'localhost';
CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'StrongPassword123!';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost';
FLUSH PRIVILEGES;
# Verify wp-config.php settings
grep DB_ /var/www/html/wordpress/wp-config.php
Problem 3: File Upload Issues โ
Check these things:
# Fix permissions
sudo chown -R apache:apache /var/www/html/wordpress/wp-content
sudo chmod -R 755 /var/www/html/wordpress/wp-content
# Increase PHP limits
sudo sed -i 's/upload_max_filesize = 2M/upload_max_filesize = 64M/' /etc/php.ini
sudo sed -i 's/post_max_size = 8M/post_max_size = 64M/' /etc/php.ini
# Restart services
sudo systemctl restart httpd
sudo systemctl restart php-fpm
๐ Simple Commands Summary
Task | Command |
---|---|
๐ Check Apache status | sudo systemctl status httpd |
๐ง Restart Apache | sudo systemctl restart httpd |
๐ Check PHP version | php -v |
๐ View error logs | sudo tail -f /var/log/httpd/error_log |
โป๏ธ Update WordPress perms | sudo chown -R apache:apache /var/www/html/wordpress |
๐ Check database | mysql -u wordpress_user -p |
โ Test site | curl -I http://localhost |
๐ก Tips for Success
- Always backup first ๐ - Before updates or changes, backup your site
- Use strong passwords ๐ - Weak passwords are the #1 security risk
- Keep everything updated ๐ - Regular updates prevent security issues
- Monitor resources ๐ - Watch CPU and memory usage as your site grows
- Use caching plugins ๐ - W3 Total Cache or WP Super Cache for speed
๐ What You Learned
Congratulations! Now you can:
- โ Install and configure Apache web server on AlmaLinux
- โ Set up MariaDB database for WordPress
- โ Install PHP with all required extensions
- โ Deploy WordPress and configure it properly
- โ Implement SSL, caching, and backup solutions
๐ฏ Why This Matters
Your WordPress on AlmaLinux setup provides:
- ๐ Full control over your website and server environment
- ๐ Enhanced security with enterprise-grade Linux
- ๐ Unlimited scalability as your site grows
- โก Superior performance compared to shared hosting
Remember: Running WordPress on your own AlmaLinux server gives you the power and flexibility that shared hosting can never match - youโre now a true webmaster! โญ
Youโve successfully installed WordPress on AlmaLinux! Your website is now running on a professional, enterprise-grade platform that can handle anything from a simple blog to a high-traffic business site! ๐