Setup WordPress on Linux (Ubuntu 22.04)
This guide walks you through installing WordPress on an Ubuntu 22.04 instance using the LAMP stack (Linux, Apache, MySQL, PHP). It is written for virtual machines provisioned through the WebberStop Cloud Management Portal.
Prerequisites
Before you begin, make sure:
- You have an Ubuntu 22.04 VM deployed.
- The instance has a public IP address.
- You have root or sudo access via SSH (see Connect with SSH).
- Port 80 (and 443, if you plan to add HTTPS) is open to the instance in the Cloud Management Portal.
Step 1: Update the system
Update the existing packages first:
sudo apt update && sudo apt upgrade -y
Step 2: Install Apache
sudo apt install apache2 -y
sudo systemctl enable apache2
sudo systemctl start apache2
You can confirm Apache is running by visiting https://your_server_ip/ — you should see the default Apache page.
Step 3: Install MySQL and create the database
Install MySQL and run the security script:
sudo apt install mysql-server -y
sudo mysql_secure_installation
Then open the MySQL shell:
sudo mysql -u root -p
Create the database and a dedicated user. Replace ChangeThisPassword with a strong, unique password:
CREATE DATABASE wordpress;
CREATE USER 'wpuser'@'localhost' IDENTIFIED BY 'ChangeThisPassword';
GRANT ALL PRIVILEGES ON wordpress.* TO 'wpuser'@'localhost';
FLUSH PRIVILEGES;
EXIT;
Never use the example password above in production. Choose a strong, unique password and store it securely — you will need it again in Step 7.
Step 4: Install PHP
sudo apt install php libapache2-mod-php php-mysql php-curl php-xml php-gd php-mbstring php-xmlrpc php-soap php-intl php-zip -y
Step 5: Download and place WordPress
cd /tmp
curl -O https://wordpress.org/latest.tar.gz
tar -xvzf latest.tar.gz
sudo mv wordpress /var/www/html/wordpress
Set the correct ownership and permissions:
sudo chown -R www-data:www-data /var/www/html/wordpress
sudo chmod -R 755 /var/www/html/wordpress
Step 6: Configure Apache for WordPress
Create a new Apache site configuration:
sudo nano /etc/apache2/sites-available/wordpress.conf
Paste the following, replacing your_domain with your domain name (or the server's public IP if you do not have a domain yet):
<VirtualHost *:80>
ServerAdmin admin@your_domain
DocumentRoot /var/www/html/wordpress
ServerName your_domain
<Directory /var/www/html/wordpress>
AllowOverride All
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Enable the site and the rewrite module, then reload Apache:
sudo a2ensite wordpress.conf
sudo a2enmod rewrite
sudo systemctl reload apache2
Step 7: Complete the installation in your browser
- Open your browser and go to
https://your_server_ip/wordpress(or your domain). - Select your preferred language and click Continue.
- Enter your database details:
- Database Name:
wordpress - Username:
wpuser - Password: the password you set in Step 3
- Database Host:
localhost - Table Prefix:
wp_
- Database Name:
- Click Submit, then Run the installation.
- Set your site title, admin username, a strong admin password, and your email address.
- Click Install WordPress.
Once the installation finishes, you will be redirected to the login page at https://your_server_ip/wordpress/wp-admin.
Next steps
- Point a domain at your instance with the DNS Service.
- Secure the site with HTTPS (for example, using Let's Encrypt / Certbot).
- Review Network Planning Best Practices before going to production.