How To Install WordPress On Linux : WordPress LAMP Stack Installation Steps

Running a website on Linux starts with setting up WordPress, which requires a web server and database. This guide covers exactly how to install WordPress on Linux step by step, from server prep to final configuration. You don’t need to be a Linux expert—just follow these clear instructions.

WordPress powers over 40% of all websites, and Linux is its natural home. Installing it manually gives you full control and better performance than shared hosting. Let’s get your site live quickly.

Prerequisites For Installing WordPress On Linux

Before you start, make sure your Linux server meets these requirements. You’ll need root or sudo access to complete the installation.

Server Requirements

  • A Linux distribution (Ubuntu 20.04/22.04, Debian 11/12, CentOS 7/8, or Rocky Linux)
  • Apache or Nginx web server
  • MySQL or MariaDB database server
  • PHP 7.4 or higher (PHP 8.0+ recommended)
  • At least 1 GB RAM (2 GB+ for production sites)
  • A domain name pointed to your server IP

Basic Linux Skills Needed

  • Using the terminal via SSH
  • Running commands with sudo
  • Editing text files with nano or vim
  • Basic file permission knowledge

If you’re using a cloud provider like AWS, DigitalOcean, or Linode, you already have a fresh Linux server. This guide assumes you have SSH access and a non-root user with sudo privileges.

How To Install WordPress On Linux

Now we get to the core of this guide. Follow these steps exactly to install WordPress on your Linux server. The process takes about 20 minutes if everything goes smoothly.

Step 1: Update Your System

Always start with a clean, updated system. Run these commands:

  1. sudo apt update (for Debian/Ubuntu) or sudo yum update (for CentOS/RHEL)
  2. sudo apt upgrade -y or sudo yum upgrade -y

This ensures all packages are current and reduces security risks.

Step 2: Install A Web Server (Apache Or Nginx)

Choose one web server. Apache is easier for beginners; Nginx offers better performance under high traffic.

Install Apache

  1. sudo apt install apache2 -y
  2. sudo systemctl start apache2
  3. sudo systemctl enable apache2
  4. Check status: sudo systemctl status apache2

Install Nginx

  1. sudo apt install nginx -y
  2. sudo systemctl start nginx
  3. sudo systemctl enable nginx
  4. Test with: sudo systemctl status nginx

Step 3: Install MySQL Or MariaDB

WordPress needs a database. MariaDB is a drop-in replacement for MySQL and often faster.

  1. sudo apt install mariadb-server mariadb-client -y
  2. sudo systemctl start mariadb
  3. sudo systemctl enable mariadb
  4. Secure the installation: sudo mysql_secure_installation

During the security script, set a root password, remove anonymous users, disallow root login remotely, and remove test databases. Answer “Y” to all prompts.

Step 4: Install PHP And Required Extensions

WordPress requires PHP with several extensions. Install them all at once:

  1. sudo apt install php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y
  2. Restart your web server: sudo systemctl restart apache2 or sudo systemctl restart nginx

Verify PHP version: php -v. If below 7.4, add a newer PHP repository.

Step 5: Create A Database For WordPress

Log into MySQL/MariaDB and create a database and user:

  1. sudo mysql -u root -p (enter your root password)
  2. Run these SQL commands one by one:
CREATE DATABASE wordpress_db;
CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'strong_password_here';
GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘strong_password_here’ with a secure password. Write it down—you’ll need it soon.

Step 6: Download WordPress

Navigate to your web root directory and download the latest WordPress package:

  1. cd /var/www/html (Apache) or cd /var/www (Nginx)
  2. sudo wget https://wordpress.org/latest.tar.gz
  3. sudo tar -xzvf latest.tar.gz
  4. This creates a wordpress folder with all files.

Step 7: Configure File Permissions

WordPress needs proper ownership and permissions to write files:

  1. sudo chown -R www-data:www-data /var/www/html/wordpress (Apache) or sudo chown -R www-data:www-data /var/www/wordpress (Nginx)
  2. sudo chmod -R 755 /var/www/html/wordpress

The user “www-data” is the web server user on Debian/Ubuntu. On CentOS, use “apache” instead.

Step 8: Configure WordPress

Copy the sample config file and edit it:

  1. cd /var/www/html/wordpress
  2. sudo cp wp-config-sample.php wp-config.php
  3. sudo nano wp-config.php

Find these lines and update them with your database details:

define('DB_NAME', 'wordpress_db');
define('DB_USER', 'wp_user');
define('DB_PASSWORD', 'strong_password_here');
define('DB_HOST', 'localhost');

Save and exit (Ctrl+X, then Y, then Enter in nano).

Step 9: Set Up Your Web Server Virtual Host (Nginx Example)

If using Apache, skip this step—the default configuration works. For Nginx, create a server block:

  1. sudo nano /etc/nginx/sites-available/wordpress
  2. Add this configuration (adjust server_name to your domain):
server {
    listen 80;
    server_name yourdomain.com www.yourdomain.com;
    root /var/www/wordpress;
    index index.php index.html index.htm;

    location / {
        try_files $uri $uri/ /index.php?$args;
    }

    location ~ \.php$ {
        include snippets/fastcgi-php.conf;
        fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
    }

    location ~ /\.ht {
        deny all;
    }
}
  1. Enable the site: sudo ln -s /etc/nginx/sites-available/wordpress /etc/nginx/sites-enabled/
  2. Test configuration: sudo nginx -t
  3. Reload Nginx: sudo systemctl reload nginx

Step 10: Complete Installation Via Web Browser

Open your browser and go to http://yourdomain.com or your server’s IP address. You’ll see the WordPress setup wizard:

  1. Select your language
  2. Enter your Site Title, Username, Password, and Email
  3. Click “Install WordPress”
  4. Log in with your new credentials

That’s it! Your WordPress site is now live on Linux.

Post-Installation Security Tips

After installation, secure your site with these essential steps:

  • Change the default “admin” username if you used it
  • Install an SSL certificate using Let’s Encrypt (Certbot)
  • Set strong file permissions: chmod 644 wp-config.php
  • Disable file editing in WordPress by adding to wp-config.php: define('DISALLOW_FILE_EDIT', true);
  • Install a security plugin like Wordfence or Sucuri
  • Regularly update WordPress core, themes, and plugins

Troubleshooting Common Issues

Even with careful steps, problems can arise. Here are fixes for frequent issues:

White Screen Of Death

This usually means a PHP error. Enable debugging in wp-config.php:

define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);

Check the wp-content/debug.log file for errors.

Database Connection Error

Verify your database credentials in wp-config.php. Ensure MySQL/MariaDB is running: sudo systemctl status mariadb.

404 Errors On Pages

For Nginx, ensure your server block includes the try_files line shown above. For Apache, enable mod_rewrite: sudo a2enmod rewrite and restart Apache.

File Upload Issues

Check folder permissions: sudo chmod -R 755 wp-content/uploads. Also verify PHP upload settings in php.ini.

Automating With Scripts (Optional)

If you install WordPress frequently, consider automation. A simple bash script can handle steps 2 through 8. Here’s a basic example:

#!/bin/bash
apt update && apt upgrade -y
apt install apache2 mariadb-server php php-mysql -y
systemctl start apache2 mariadb
mysql -u root -e "CREATE DATABASE wp_db; CREATE USER 'wp_user'@'localhost' IDENTIFIED BY 'pass'; GRANT ALL ON wp_db.* TO 'wp_user'@'localhost';"
cd /var/www/html && wget https://wordpress.org/latest.tar.gz && tar -xzvf latest.tar.gz
chown -R www-data:www-data wordpress
echo "WordPress files ready. Complete setup via browser."

Save as install-wp.sh, make executable with chmod +x install-wp.sh, and run with sudo.

Frequently Asked Questions

Can I Install WordPress On Linux Without A Domain?

Yes, use your server’s IP address in the browser. However, you’ll need a domain for email and SSL certificates.

What’s The Difference Between Installing WordPress On Ubuntu Vs CentOS?

Package managers differ (apt vs yum), but the steps are nearly identical. Ubuntu is more beginner-friendly due to larger community support.

Do I Need A Control Panel Like CPanel Or Plesk?

No, this guide shows manual installation without a control panel. Many developers prefer this for better performance and control.

How Long Does It Take To Install WordPress On Linux?

Around 15-30 minutes for a first-time installation. Experienced users can do it in under 10 minutes.

Is It Safe To Install WordPress On A VPS?

Yes, but you must maintain security updates yourself. Consider using a managed WordPress host if you prefer hands-off maintenance.

Conclusion

You now know how to install WordPress on Linux from scratch. The process involves setting up a LAMP or LEMP stack, downloading WordPress, configuring the database, and running the web installer. With practice, you can complete this in under 20 minutes.

Remember to keep your server updated and backup your site regularly. WordPress on Linux offers unmatched flexibility and performance for your website. If you encounter issues, refer back to the troubleshooting section or consult the WordPress Codex.

Now go ahead and build something amazing with your new WordPress site on Linux.