WordPress is the most popular open-source content management system in the world, powering over a quarter of all websites. It is built on PHP and MySQL and comes with a plugin and theme ecosystem that can handle anything from a personal blog to a full e-commerce store.
This guide walks you through installing WordPress on Ubuntu 18.04 with Apache as the web server. You will end up with a working WordPress site running behind HTTPS using a Let’s Encrypt SSL certificate.
Prerequisites:
Run a quick package update before starting:
bashsudo apt update && sudo apt upgrade
WordPress needs a MySQL or MariaDB database to store posts, pages, users, plugins, and theme settings. If MySQL or MariaDB is not already installed on your server, set that up before continuing.
Log into the MySQL shell:
bashsudo mysql
Create a dedicated WordPress database with the correct character set:
sqlCREATE DATABASE wordpress CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
Create a MySQL user and grant it full access to the database. Replace the placeholder with a strong password:
sqlGRANT ALL ON wordpress.* TO 'wordpressuser'@'localhost' IDENTIFIED BY 'change-with-strong-password';
Exit the MySQL shell:
sqlEXIT
PHP 7.2 is the default PHP version on Ubuntu 18.04 and is fully supported by WordPress. Install it along with all required extensions:
bashsudo apt install php7.2 php7.2-cli php7.2-mysql php7.2-json php7.2-opcache php7.2-mbstring php7.2-xml php7.2-gd php7.2-curl
Restart Apache to load the new PHP extensions:
bashsudo systemctl restart apache2
Create the document root directory for your domain:
bashsudo mkdir -p /var/www/example.com
Download the latest WordPress archive to the /tmp directory and extract it:
bashcd /tmp && wget https://wordpress.org/latest.tar.gztar xf latest.tar.gzsudo mv /tmp/wordpress/* /var/www/example.com/
Set the correct ownership so Apache can read and write to the WordPress files:
bashsudo chown -R www-data: /var/www/example.com
Create an Apache virtual host file for your domain:
bashsudo nano /etc/apache2/sites-available/example.com.conf
Paste the following configuration, replacing example.com with your domain and updating the SSL certificate paths:
apache<VirtualHost *:80> ServerName example.com Redirect permanent / https://example.com/</VirtualHost><VirtualHost *:443> ServerName example.com DocumentRoot /var/www/example.com SSLEngine On SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem <Directory /var/www/example.com> AllowOverride All Require all granted </Directory></VirtualHost>
The AllowOverride All directive lets WordPress manage URL rewrites through its .htaccess file, which is required for pretty permalinks.
Enable the site and restart Apache:
bashsudo a2ensite example.comsudo systemctl restart apache2
Open your domain in a browser. The WordPress setup wizard walks you through:
wordpress), username (wordpressuser), password, host (localhost), and table prefixadmin for security), and set a strong passwordClick Install WordPress. Once complete, you are redirected to the WordPress dashboard where you can install themes, add plugins, and create your first pages.
WordPress is now installed on your Ubuntu 18.04 server. Check out the First Steps With WordPress guide to get started customizing your site. Leave a comment below if you run into any issues during setup.
Joomla is one of the most popular open-source content management systems in the world. It is…
You follow a tutorial, run a command, and get: curl: command not found. It simply means…
Postman is a complete API development environment used by developers at every stage of building APIs…
VLC is one of the most popular open-source multimedia players in the world, developed by the…
Opera is one of the most popular cross-platform web browsers in the world, available on Windows,…
Gogs is a free, self-hosted Git service written in Go. It gives you a private GitHub-like…