Summarize this article with:

Managed hosting is convenient. But it comes with limits.

Installing WordPress on Ubuntu gives you complete control over your server, your PHP configuration, and your security settings.

No restrictions on plugins. No shared resources slowing you down. No monthly fees eating into your budget.

This guide walks you through the entire LAMP stack setup process, from updating system packages to completing the WordPress installation wizard.

You will configure Apache, create a MySQL database, set file permissions, and launch a fully functional self-hosted WordPress site.

Takes about 45-60 minutes. Requires basic command line knowledge and SSH access to your VPS or dedicated server.

Installing WordPress on Ubuntu

YouTube player

Installing WordPress on Ubuntu is the process of configuring a LAMP stack and deploying WordPress files on an Ubuntu server using terminal commands.

Users need this when setting up a self-hosted WordPress site with full server control, custom PHP configuration, or specific security requirements.

This guide covers 8 steps requiring 45-60 minutes and intermediate Linux command-line knowledge.

Prerequisites

Gather these before starting:

  • Ubuntu Server 22.04 LTS or Ubuntu Server 24.04 LTS
  • Root or sudo privileges on your VPS hosting or dedicated server
  • SSH client (Terminal on macOS/Linux, PuTTY on Windows)
  • Registered domain name with DNS configuration pointing to your server IP
  • Minimum 1GB RAM, 25GB storage
  • 45-60 minutes

Step One: How Do You Update the Ubuntu System Packages?

Run the apt-get commands to refresh package lists and upgrade installed software to the latest versions, preventing compatibility issues during LAMP stack setup.

Action

Connect to your server via SSH access:

ssh root@yourserverip `

Update the package manager index:

` sudo apt update `

Upgrade all installed packages:

` sudo apt upgrade -y `

The -y flag auto-confirms prompts.

Purpose

Fresh packages prevent security vulnerabilities and dependency conflicts when installing Apache, MySQL, and PHP.

Step Two: How Do You Install the Apache Web Server?

Install Apache HTTP Server using apt, then verify the service is running and configure firewall settings to allow HTTP traffic on port 80.

Action

Install Apache:

` sudo apt install apache2 -y `

Enable Apache to start on boot:

` sudo systemctl enable apache2 `

Check service status:

` sudo systemctl status apache2 `

You should see “active (running)” in the output.

Configure UFW firewall:

` sudo ufw allow 'Apache Full' sudo ufw enable `

Visit http://yourserverip in a browser.

The default Apache page confirms successful web server configuration.

Purpose

Apache serves as the backend foundation that handles HTTP requests and delivers WordPress content to visitors.

A misconfigured Apache can trigger a 500 internal server error when loading your site.

Step Three: How Do You Install and Configure MySQL Database?

Install MySQL or MariaDB database server, run the security script to remove default vulnerabilities, then create a dedicated WordPress database and user with appropriate privileges.

Action

Install MySQL server:

` sudo apt install mysql-server -y `

Run the security script:

` sudo mysqlsecureinstallation `

Follow these prompts:

  • Set root password: Yes
  • Remove anonymous users: Yes
  • Disallow root login remotely: Yes
  • Remove test database: Yes
  • Reload privilege tables: Yes

Log into MySQL:

` sudo mysql -u root -p `

Enter the password you just created.

Purpose

MySQL stores all WordPress content, user data, settings, and plugin configurations.

Skipping the security script leaves your database management system exposed to attacks.

Wrong database credentials later cause the “error establishing a database connection” message that blocks site access.

Step Four: How Do You Create a WordPress Database and User?

Create a dedicated MySQL database, a database user with a strong password, and grant full privileges for WordPress to store content and settings.

Action

While logged into MySQL, run these commands:

` CREATE DATABASE wordpressdb DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4unicodeci; `

Create a database user:

` CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'yourstrongpassword'; `

Grant privileges:

` GRANT ALL PRIVILEGES ON wordpressdb. TO 'wpuser'@'localhost'; FLUSH PRIVILEGES; EXIT; `

Save these database credentials for wp-config.php later.

Purpose

WordPress requires its own database and user; using root credentials creates security risks.

Wrong database prefix or credentials trigger WordPress database errors during installation.

Step Five: How Do You Install PHP and Required Extensions?

Install PHP and the required PHP extensions that WordPress and its plugins need for image processing, database connections, and XML parsing.

Action

Install PHP with extensions:

` sudo apt install php libapache2-mod-php php-mysql php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip -y `

Verify PHP installation:

` php -v `

You should see PHP 8.1 or higher.

Restart Apache:

` sudo systemctl restart apache2 `

Edit php.ini for WordPress optimization:

` sudo nano /etc/php/8.1/apache2/php.ini `

Adjust these values:

  • uploadmaxfilesize = 64M
  • postmaxsize = 64M
  • memorylimit = 256M
  • maxexecutiontime = 300

Purpose

Missing PHP extensions cause plugin failures; low memory limits trigger WordPress memory exhausted errors.

Step Six: How Do You Download and Extract WordPress Files?

Download the latest WordPress core files from WordPress.org, extract them to the document root, and prepare the directory structure.

Action

Navigate to the web directory:

` cd /var/www/html `

Download WordPress:

` sudo wget https://wordpress.org/latest.tar.gz `

Extract the archive:

` sudo tar -xzvf latest.tar.gz `

Move files to document root:

` sudo mv wordpress/ /var/www/html/ `

Remove empty folder and archive:

` sudo rm -rf wordpress latest.tar.gz `

Remove default Apache index page:

` sudo rm /var/www/html/index.html `

Purpose

Extracting to the correct root directory ensures Apache serves WordPress files when visitors access your domain.

Step Seven: How Do You Configure WordPress Directory Permissions?

Set correct file permissions and ownership on the wp-content folder so Apache can write uploads, cache files, and plugin data while maintaining security.

Action

Set ownership to the Apache user:

` sudo chown -R www-data:www-data /var/www/html `

Set directory permissions:

` sudo find /var/www/html -type d -exec chmod 755 {} ; `

Set file permissions:

` sudo find /var/www/html -type f -exec chmod 644 {} ; `

Secure wp-config.php after creation:

` sudo chmod 600 /var/www/html/wp-config.php `

Purpose

Wrong permissions cause “Permission denied” errors or security vulnerabilities; use these exact values to fix WordPress permissions issues.

Step Eight: How Do You Complete the WordPress Installation Wizard?

Access the browser-based installation wizard, enter database credentials, and configure your site title, admin username, and password.

Action

Open your browser and visit:

` http://yourdomainorip/wp-admin/install.php `

Select your language.

Enter database details:

  • Database Name: wordpressdb
  • Username: wpuser
  • Password: your database password
  • Database Host: localhost
  • Table Prefix: wp (change for security)

Click “Run the installation.”

Configure site information:

  • Site Title: your website name
  • Username: admin username (avoid “admin”)
  • Password: strong password
  • Email: your email address

Click “Install WordPress.”

Purpose

The wizard creates wp-config.php and populates database tables; WordPress installation errors here usually mean wrong database credentials.

Verification

Confirm successful installation:

  • Visit http://yourdomain to see the default theme
  • Log into http://yourdomain/wp-admin with your credentials
  • Check Dashboard > Site Health for configuration issues
  • Verify permalinks are working under Settings > Permalinks

Enable modrewrite for pretty permalinks:

` sudo a2enmod rewrite sudo systemctl restart apache2 `

Troubleshooting

Apache Not Starting

Check syntax errors:

` sudo apache2ctl configtest `

View error logs:

` sudo tail -f /var/log/apache2/error.log `

Port 80 conflict? Check with sudo netstat -tlnp | grep 80.

MySQL Connection Refused

Verify MySQL is running:

` sudo systemctl status mysql `

Check if socket exists at /var/run/mysqld/mysqld.sock.

Restart the service: sudo systemctl restart mysql.

PHP Not Processing

Verify module is loaded:

` sudo a2enmod php8.1 sudo systemctl restart apache2 `

Check PHP errors are showing for debugging.

Permission Denied Errors

Re-run ownership commands:

` sudo chown -R www-data:www-data /var/www/html `

Check SELinux or AppArmor restrictions on CentOS/Ubuntu.

White Screen After Installation

Enable WPDEBUG in wp-config.php:

` define('WPDEBUG', true); define('WPDEBUGLOG', true); `

Check WordPress error log at /var/www/html/wp-content/debug.log.

The WordPress white screen of death usually indicates PHP memory issues or plugin conflicts.

Alternative Method: Installing WordPress with WP-CLI

WP-CLI offers faster command line installation without browser interaction.

Install WP-CLI:

` curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar chmod +x wp-cli.phar sudo mv wp-cli.phar /usr/local/bin/wp `

Download WordPress:

` wp core download --path=/var/www/html `

Create config:

` wp config create --dbname=wordpressdb --dbuser=wpuser --dbpass=yourpassword --path=/var/www/html `

Run installation:

` wp core install --url=yourdomain --title="Site Name" --adminuser=admin --adminpassword=securepass --adminemail=you@email.com --path=/var/www/html `

Browser method: 8 steps, 45-60 minutes, visual confirmation at each stage.

WP-CLI method: 4 commands, 10-15 minutes, scriptable for multiple deployments.

Choose WP-CLI for staging environment setup or automated server administration.

Next Steps

After successful WordPress deployment on your Ubuntu server:

  • Install an SSL certificate using Let’s Encrypt and Certbot
  • Configure Apache virtual host for your domain
  • Set up automated backups with cron jobs
  • Install security plugins and configure firewall settings
  • Optimize performance with cache configuration
  • Install Google Tag Manager for analytics tracking

Consider managing multiple WordPress sites from a single dashboard if deploying additional instances.

FAQ on Installing WordPress On Ubuntu

What Are the Minimum Server Requirements for WordPress on Ubuntu?

WordPress requires PHP 7.4 or higher, MySQL 5.7 or MariaDB 10.4, and Apache or Nginx web server.

Ubuntu recommends 1GB RAM minimum, though 2GB performs better for sites with plugins and traffic.

Should I Use Apache or Nginx for WordPress on Ubuntu?

Apache HTTP Server works well for beginners with .htaccess support and modrewrite for permalinks.

Nginx handles more concurrent connections but requires manual configuration for WordPress rules.

How Do I Secure My WordPress Installation on Ubuntu?

Install an SSL certificate using Let’s Encrypt and Certbot. Configure UFW firewall settings to block unused ports.

Change the default database prefix and use strong credentials for database user accounts.

Can I Install WordPress Without Command Line Access?

No. Ubuntu server installation requires terminal commands for package installation, database creation, and file permission configuration.

Use managed hosting or cPanel if you need a graphical interface instead.

Why Does WordPress Show “Error Establishing a Database Connection”?

Wrong database credentials in wp-config.php cause this error. Verify database name, username, password, and host match your MySQL configuration.

Check if MySQL service is running with systemctl status mysql.

How Do I Fix Permission Denied Errors After Installation?

Set ownership to www-data user: sudo chown -R www-data:www-data /var/www/html.

Apply 755 for directories and 644 for files. Wrong file permissions block uploads and plugin installations.

Which Ubuntu Version Works Best for WordPress?

Ubuntu Server 22.04 LTS or 24.04 LTS provide long-term support with security updates for five years.

LTS versions offer stability for production servers running content management systems.

How Do I Increase PHP Memory Limit on Ubuntu?

Edit php.ini at /etc/php/8.1/apache2/php.ini. Change memorylimit to 256M or higher.

Restart Apache after changes. Low limits cause fatal error out of memory messages.

Can I Run Multiple WordPress Sites on One Ubuntu Server?

Yes. Configure Apache virtual host files for each domain pointing to separate document root directories.

Create individual MySQL databases and WordPress installations for each site.

How Do I Update WordPress Safely on Ubuntu?

Create database and file backups before updating. Use the WordPress dashboard for minor updates.

For major versions, test on a staging environment first to catch plugin compatibility issues.

Conclusion

Installing WordPress on Ubuntu takes under an hour when you follow the right steps.

You now have a production server running Apache, MySQL, and PHP with proper security configurations.

Your self-hosted setup offers advantages that managed hosting cannot match: full root access, custom server optimization, and zero platform restrictions.

The real work starts after installation. Configure cache settings for performance tuning. Set up automated backups through cron jobs. Install an SSL certificate from Let’s Encrypt.

Consider using WP-CLI for future server administration tasks and plugin updates.

Whether you deployed on DigitalOcean, Linode, or AWS EC2, your Ubuntu WordPress server is ready for traffic.

Build something worth visiting.

Author

Bogdan Sandu specializes in web and graphic design, focusing on creating user-friendly websites, innovative UI kits, and unique fonts.Many of his resources are available on various design marketplaces. Over the years, he's worked with a range of clients and contributed to design publications like Designmodo, WebDesignerDepot, and Speckyboy, Slider Revolution among others.