21.07.2025

Comprehensive Guide to WordPress Installation on Ubuntu

WordPress is a free and open-source content management system (CMS) written in PHP and using a MySQL or MariaDB database. According to W3Techs data for July 2025, WordPress powers 43.1% of websites with a known CMS. Originally created as a blogging platform in 2003, WordPress has evolved into a powerful tool for creating any type of website. Its popularity stems from ease of use, flexibility, and an extensive developer community.

This article provides an up-to-date guide for installing WordPress on an Ubuntu server, considering modern security and performance requirements.

Prerequisites

Before installing WordPress, ensure your Ubuntu server meets these requirements:

Downloading WordPress

  1. Download the archive
    wget https://wordpress.org/latest.tar.gz
  2. Extract the archive completely
    tar -xzf latest.tar.gz

Database Configuration

Create a Unicode-compatible database and user with minimal privileges:

sudo mysql
CREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
CREATE USER 'wp_user'@'localhost' IDENTIFIED WITH mysql_native_password BY 'secure_password';
GRANT SELECT, INSERT, UPDATE, DELETE, CREATE, ALTER, INDEX ON wordpress.* TO 'wp_user'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Important: Using mysql_native_password ensures compatibility with WordPress.

WordPress Configuration

  1. Copy the sample configuration
    cp /var/www/html/wp-config-sample.php /var/www/html/wp-config.php
  2. Add salt keys
    Generate unique keys at api.wordpress.org/secret-key/1.1/salt/ and paste them in wp-config.php replacing:
    define('AUTH_KEY', 'insert your unique phrase');
    define('SECURE_AUTH_KEY', 'insert your unique phrase');
    // ... remaining keys
  3. Configure database access
    Edit in wp-config.php:
    define('DB_NAME', 'wordpress');
    define('DB_USER', 'wp_user');
    define('DB_PASSWORD', 'secure_password');
    define('DB_HOST', 'localhost');
  4. Set secure permissions
    cd /var/www/html
    sudo find . -type d -exec chmod 755 {} \;
    sudo find . -type f -exec chmod 644 {} \;
    sudo chown -R www-data:www-data /var/www/html

Running the Installation Script

  1. Access the installer in your browser
    Navigate to http://your_IP_address or http://localhost
  2. Enter site information
    • Site title
    • Username (avoid using "admin")
    • Strong password
    • Administrator email
  3. Complete installation
    Click "Install WordPress" and log into the admin dashboard

Troubleshooting Installation Issues

Database connection error

  1. Verify MySQL user authentication:
    SELECT plugin FROM mysql.user WHERE User = 'wp_user';

    Should return: mysql_native_password

  2. Check MySQL status:
    sudo systemctl status mysql

Permission issues

  1. Check file ownership:
    ls -l /var/www/html
  2. Fix permissions:
    sudo chown -R www-data:www-data /var/www/html
    sudo find /var/www/html -type d -exec chmod 755 {} \;
    sudo find /var/www/html -type f -exec chmod 644 {} \;

Missing functionality

  1. Install required PHP modules:
    sudo apt install php-json php-xmlrpc php-soap php-intl
    sudo systemctl restart apache2

SEO-friendly URL issues (Pretty Permalinks)

  1. Enable mod_rewrite:
    sudo a2enmod rewrite
  2. Add to .htaccess:

    AllowOverride All

Installing WordPress on Ubuntu requires attention to modern security requirements, especially when using MySQL 8.0 and PHP 8.0+. By following this guide, you'll create an optimized and secure environment for your website. Regularly update WordPress and its components to maintain security.

Table: Essential WordPress Installation Commands

Command Description
sudo a2enmod rewrite Enables SEO-friendly URL support
sudo apt install php-mysql php-curl Installs required PHP modules
cp -a wordpress/. /var/www/html/ Copies all WordPress files
CREATE USER 'user'@'localhost' IDENTIFIED WITH mysql_native_password Creates a compatible database user
find . -type d -exec chmod 755 {} \; Secure directory permissions
find . -type f -exec chmod 644 {} \; Secure file permissions