Installing WordPress on an instance
Find out how to use a Public Cloud instance to host WordPress websites
Find out how to use a Public Cloud instance to host WordPress websites
Last updated 15th October 2021
WordPress is a content management system (CMS) which enables you to create and manage websites for multiple purposes, without the need for any programming skills.
This tutorial provides the basic steps for a manual installation of WordPress on a Public Cloud instance: installing a web server and configuring the database, downloading and launching WordPress.
This guide explains how to install WordPress on a Public Cloud instance.
This guide will show you how to use one or more OVHcloud solutions with external tools, and will describe the actions to be carried out in a specific context. Please remember to adapt these actions to fit your situation.
If you encounter any difficulties performing these actions, please contact a specialised service provider and/or discuss the issue with our community. OVHcloud cannot provide you with technical support in this regard.
The following instructions are verfied for Debian 11. Since Ubuntu is based on Debian the tutorial should work for a current Ubuntu distribution as well.
In order to access your installation via a domain name, you need to attach it to your instance. This is done by editing the DNS zone which you can do in your OVHcloud Control Panel, provided OVHcloud is your domain registrar and the domain name uses OVHcloud DNS servers.
Please refer to our guide on Editing your DNS zone for further instructions. If the domain name is currently in use, only configure DNS after the new WordPress is installed and your website is ready.
To be able to serve dynamic web pages with WordPress, a so-called LAMP stack will be installed on the instance. LAMP stands for Linux, Apache, MariaDB and PHP.
After logging in to your instance with SSH, ensure that all packages are up-to-date:
debian@instance:~$ sudo apt update && sudo apt upgrade -y
Since software packages are regularly updated, you might need to adjust the following instructions according to the latest versions.
Install the LAMP packages:
debian@instance:~$ sudo apt install apache2 mariadb-server php libapache2-mod-php php-mysql
MariaDB provides a script to assist with the initial configuration and to apply some security-related settings.
To run it, enter this command:
debian@instance:~$ sudo mysql_secure_installation
Confirm the first prompt by pressing
Next you can choose a method to secure access to the database server.
Switch to unix_socket authentication [Y/n]
It is recommended to use the proposed authentication method instead of the access via root password. Press
y and then
Enter. (If you decide to use root user access, type
n and then set a root password.)
n at the next prompt:
Change the root password? [Y/n]
Since the subsequent prompts concern security measures, confirm them all with
y until the script is finished.
If you have configured MariaDB access in the recommended way (unix_socket), you now have automatic root access to it whenever you are logged in on the instance as a user with with elevated permissions.
Open the MariaDB shell:
debian@instance:~$ sudo mariadb
Create the database for WordPress:
MariaDB [(none)]> CREATE DATABASE wordpress;
Next, grant a new user "wordpress" all rights on this database. This user will access the database and carry out all operations for the WordPress CMS. Replace
your_password with a strong password for this user.
MariaDB [(none)]> GRANT ALL ON wordpress.* TO 'wordpress'@'localhost' IDENTIFIED BY 'your_password' WITH GRANT OPTION;
You will need these credentials later when installing WordPress.
The database is now ready for use with WordPress. Ensure the changes are applied for the next steps and then exit the MariaDB shell:
MariaDB [(none)]> FLUSH PRIVILEGES;
MariaDB [(none)]> exit;
Configuring a firewall (iptables) will enhance the security of your WordPress instance. This process can be simplified by using the frontend "Uncomplicated Firewall" (UFW) and its preset of profiles. Install UFW:
debian@instance:~$ sudo apt install ufw
The relevant profiles are labelled as "WWW" in the application list:
debian@instance:~$ sudo ufw app list | grep WWW WWW WWW Cache WWW Full WWW Secure
By choosing "WWW Full", both secure connections (port 443) and not-secured http requests (port 80) to the web server will be allowed.
To see which ports are affected by a particular profile, enter
sudo ufw app info "profile name".
By entering the following command, the ports defined by the profile "WWW Full" will be opened:
debian@instance:~$ sudo ufw allow 'WWW Full'
Since all ports not explicitly allowed will be blocked after enabling the firewall, make sure to allow SSH connections (port 22) as well:
debian@instance:~$ sudo ufw allow 'SSH'
Finally, verify the configuration and activate the firewall rules:
debian@instance:~$ sudo ufw status
debian@instance:~$ sudo ufw enable
You can go further with UFW, for example if you want to restrict denial of service (DOS) attacks or prevent requests by certain IP address ranges. Please refer to the official UFW documentation.
Visit the official WordPress website to retrieve the download URL for the latest version (in the "tar.gz" format). Then download the file:
debian@instance:~$ wget https://wordpress.org/latest.tar.gz
Uncompress the downloaded archive:
debian@instance:~$ tar zxvf latest.tar.gz
Your Apache server should be ready to use at this point. You can verify with the following command.
debian@instance:~$ sudo systemctl status apache2
You can also open
http://ip_of_your_instance in a web browser. The "Apache2 Debian Default Page" should appear.
The following steps will install WordPress by replacing the Apache default folder for web pages.
Instead of using the default folder, you can also create a new Virtual Host for the WordPress installation. This is useful for hosting multiple websites which is not relevant for this tutorial.
Delete the existing folder:
debian@instance:~$ sudo rm -R /var/www/html/
Replace the default web server folder with the WordPress folder:
debian@instance:~$ sudo mv wordpress /var/www/html
Give the web server
write permissions for the folder:
debian@instance:~$ sudo chown -R www-data:www-data /var/www/html/
The web server is now ready for the initial WordPress configuration.
Open a web browser and log in to your WordPress website by entering your instance's IP address (or the domain name if you have attached one to the instance yet). Choose a language on the first page.
Use the WordPress configuration assistant to enable access to your database. Enter the details you have configured previously.
In the next step, you can pre-configure your website's general information and create your WordPress admin user.
Once this is confirmed, you will be able to log in to your website's administation panel with the user credentials defined in the previous step.
In order to establish secure connections (
https), the web server has to be secured via a Certificate Authority such as "Let’s Encrypt" which offers free certificates. You will need to install a client tool (such as "Certbot") and configure Apache. Without this step, your website can only accept
First make sure that your domain name has the correct records in the DNS zone, i.e. is pointing to the IP address of your instance.
Install the necessary packages for the Certbot client:
debian@instance:~$ sudo apt install certbot python3-certbot-apache
Obtain the certificate for your domain name. (You can include the "www" subdomain by appending
debian@instance:~$ sudo certbot --apache -d yourdomainname.ovh
You will need to enter a valid email address and accept the terms of service.
Certbot will automatically renew the certificates. There are no further steps required. However, you can look into the available options to learn about the capabilities of Certbot.
Join our community of users on https://community.ovh.com/en/.
Please feel free to give any suggestions in order to improve this documentation.
Whether your feedback is about images, content, or structure, please share it, so that we can improve it together.
Your support requests will not be processed via this form. To do this, please use the "Create a ticket" form.
Thank you. Your feedback has been received.
Access your community space. Ask questions, search for information, post content, and interact with other OVHcloud Community members.Discuss with the OVHcloud community