Back to: Technology Guides

How to install Wordpress on Ubuntu on a Cloud VPS (Virtual Private Server)

To install WordPress on Ubuntu on a cloud VPS, install Apache, PHP and MariaDB, create a database and user for WordPress, download WordPress from wordpress.org into the web folder, and finish the setup in your browser. The commands below work on Ubuntu 26.04 LTS and 24.04 LTS, and take a fresh server to a working site.

  • Stack: Apache 2.4, PHP and MariaDB from Ubuntu’s own repositories, often called a LAMP stack.

  • Versions: checked against WordPress’s and Ubuntu’s documentation in November 2026.

  • Result: WordPress at http://example.ca, then HTTPS with a free Let’s Encrypt certificate.

What you need before you install WordPress

You need a VPS running a fresh Ubuntu LTS release, a user with sudo rights, and a domain whose DNS points to the server. We use example.ca and www.example.ca throughout; set an A record for each to the server’s IP address before you start.

A virtual private server gives you more control than shared hosting, including the root access this guide needs. Any provider that offers Ubuntu images works, such as Linode, now part of Akamai Cloud.

As of November 2026, WordPress recommends PHP 8.3 or greater and MariaDB 10.11 or greater (or MySQL 8.4). Both current Ubuntu LTS releases meet that out of the box:

Ubuntu release

Default PHP and MariaDB

26.04 LTS

PHP 8.5, MariaDB 11.8

24.04 LTS

PHP 8.3, MariaDB 10.11

The versions come from Ubuntu’s package archive. WordPress 6.9 and later support PHP 8.5, according to WordPress’s PHP compatibility table.

Step 1: Update the server

Bring every package up to date, then reboot so a new kernel, if any, takes effect:

sudo apt update sudo apt upgrade -y sudo reboot

Step 2: Install Apache and open the firewall

Install the Apache web server:

sudo apt install apache2

If you use Ubuntu’s UFW firewall, allow SSH first so you don’t lock yourself out, then allow web traffic on ports 80 and 443:

sudo ufw allow OpenSSH sudo ufw allow 'Apache Full' sudo ufw enable

Visit http://example.ca. Apache’s default page means the server and DNS are working.

Step 3: Install PHP and the extensions WordPress uses

WordPress runs on PHP. Install PHP, Apache’s PHP module, the MySQL/MariaDB driver and the extensions WordPress’s hosting team recommends:

sudo apt install php libapache2-mod-php php-mysql php-curl php-imagick php-intl php-mbstring php-xml php-zip

Check the version with php -v. On Ubuntu 26.04 LTS it reports PHP 8.5; on 24.04 LTS, PHP 8.3.

Step 4: Install MariaDB and secure it

MariaDB is the database WordPress stores its content in. Install it, then run its security script:

sudo apt install mariadb-server sudo mariadb-secure-installation

mariadb-secure-installation is the current name of the old mysql_secure_installation script, per MariaDB’s documentation. Answer its questions like this:

  1. Current root password: press Enter. On a new install, root signs in through the system’s unix_socket authentication and has no password.

  2. Switch to unix_socket authentication: n. Root is already protected.

  3. Change the root password: n, for the same reason.

  4. Remove anonymous users, disallow remote root login, remove the test database, reload privileges: y to each.

Step 5: Create the WordPress database and user

Open the MariaDB shell as root:

sudo mariadb

Create a database and a user that can only reach that database. Replace the password with a long, unique one and keep it for step 8:

CREATE DATABASE wordpress_db; CREATE USER 'wordpress_user'@'localhost' IDENTIFIED BY 'replace-with-a-long-password'; GRANT ALL PRIVILEGES ON wordpress_db.* TO 'wordpress_user'@'localhost'; FLUSH PRIVILEGES; EXIT;

Giving WordPress its own user, rather than root, limits the damage if the site is ever compromised.

Step 6: Download WordPress into the web folder

Download the latest WordPress release from wordpress.org, unpack it and copy it into Apache’s web folder. Remove Apache’s default page first, so it doesn’t load instead of WordPress:

cd /tmp wget https://wordpress.org/latest.tar.gz tar xzf latest.tar.gz sudo rm /var/www/html/index.html sudo cp -a /tmp/wordpress/. /var/www/html/

Then let Apache’s user, www-data, own the files. WordPress needs this to write wp-config.php during setup and to install updates and plugins later:

sudo chown -R www-data:www-data /var/www/html/ sudo find /var/www/html/ -type d -exec chmod 750 {} \; sudo find /var/www/html/ -type f -exec chmod 640 {} \;

These permissions let Apache read and write the site while other users on the server can’t. Ubuntu’s WordPress tutorial notes that if several sites share one server, each should get its own user.

Step 7: Configure the Apache virtual host

Tell Apache which domain to serve and allow WordPress’s .htaccess rules, which power its readable permalinks. Open the default site:

sudo nano /etc/apache2/sites-available/000-default.conf

Replace its contents with:

<VirtualHost *:80> ServerName example.ca ServerAlias www.example.ca ServerAdmin webmaster@example.ca DocumentRoot /var/www/html <Directory /var/www/html> Options FollowSymLinks AllowOverride Limit Options FileInfo DirectoryIndex index.php Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>

ServerName is the main domain and ServerAlias adds the www version. The AllowOverride line follows Ubuntu’s tutorial; Debian and Ubuntu set it to None by default, which makes WordPress’s readable permalinks return 404 errors. Enable the rewrite module, test the configuration and restart Apache:

sudo a2enmod rewrite sudo apache2ctl configtest sudo systemctl restart apache2

To host a second site or a staging copy on the same server, give it its own virtual host, as in our guide to setting up a subdomain on the same Apache web server.

Step 8: Run the WordPress installer in your browser

Visit http://example.ca. WordPress asks for a language, then for the database details from step 5: database name wordpress_db, username wordpress_user, your password, database host localhost and the table prefix (keep wp_ or choose another). The full flow is in WordPress’s installation guide.

WordPress installer form asking for the database name, username, password, host and table prefix

Next, enter the site title, an admin username (avoid admin), a strong password and your email address:

WordPress installer welcome screen with site title, admin username, password and email fields

WordPress confirms the installation. Log in at http://example.ca/wp-admin.

WordPress installer confirming that the installation succeeded, with a Log In button

The installer has now written wp-config.php, which holds your database password. Ubuntu’s tutorial suggests restricting it:

sudo chmod 400 /var/www/html/wp-config.php

Step 9: Add HTTPS with a free SSL certificate

Secure the site with a free Let’s Encrypt certificate before you share it. With certbot installed, one command gets the certificate, configures Apache and redirects HTTP to HTTPS:

sudo certbot --apache -d example.ca -d www.example.ca

Our guide to installing an SSL certificate with certbot on Ubuntu and Apache covers the certbot install and the renewal test. Afterwards, in WordPress, go to Settings, then General, and change the WordPress Address and Site Address to https://example.ca, so WordPress builds its links with HTTPS.

Frequently asked questions

Which PHP version does WordPress need in 2026?

WordPress recommends PHP 8.3 or greater. Ubuntu 26.04 LTS ships PHP 8.5 and Ubuntu 24.04 LTS ships PHP 8.3, and both are supported by current WordPress releases.

Should I use MariaDB or MySQL for WordPress?

Either works. WordPress recommends MariaDB 10.11 or greater, or MySQL 8.4 or greater. This guide uses MariaDB because Ubuntu’s mariadb-server package installs and secures it in two commands.

Why does WordPress ask for FTP details when I install a plugin?

WordPress asks for FTP details when it can’t write to its own files. Run the chown -R www-data:www-data /var/www/html/ command from step 6 again, and the prompt goes away.

Can I use Nginx instead of Apache?

Yes. WordPress recommends Apache or Nginx. This guide uses Apache because WordPress’s .htaccess permalink rules work with it as soon as mod_rewrite is on, while Nginx needs those rules written into its own configuration.

Can I run more than one WordPress site on one VPS?

Yes. Give each site its own folder, Apache virtual host and database user. Keep an eye on memory as you add sites, since each one adds PHP and database load.

Need help with your WordPress server? Talk to msmtech.

No off-the-shelf solution? We'll build it.