Learn how to install Wagtail and how to connect it to the OVHcloud Cloud Databases PostgreSQL® database service.
Wagtail is a free and open-source content management system (CMS) written in Python. It is popular amongst websites using the Django framework.
NOTE: OVHcloud provides services for which you are responsible for their configuration and management. You are therefore responsible for their proper functioning.
This tutorial is designed to help you as much as possible with common tasks. If you are having difficulty performing these actions, please contact a specialized service provider. OVHcloud can't provide you with technical support in this regard.
Requirements
- Access to the OVHcloud Control Panel
- A Public Cloud project in your OVHcloud account
- An up-and-running Cloud Database for PostgreSQL®
- A Python environment with a stable version and public network connectivity (Internet)
This tutorial was made using Python 3.10.12. Wagtail supports Python 3.7, 3.8, 3.9, and 3.10.
Configure your PostgreSQL® instance to accept incoming connections
Before making a connection, we need to verify that our PostgreSQL® instance is correctly configured.
Log in to your OVHcloud Control Panel and open your database via the Public Cloud and Databases menus.
Step 1: Verify your user roles and password
Select the Users tab. Verify that you have a user and a configured password. If you don't remember the user's password, you can either create a new user or regenerate the password of an existing user. Be careful! By doing so, you will need to update all the places where you already use this user/password pair.
This first user, avnadmin, comes with the following privileges:
We rely on official PostgreSQL® roles and privileges. You can manage them yourself via CLI or code. So far, user grants and privileges management are not supported via the OVHcloud Control Panel or the OVHcloud API.
Please read the official PostgreSQL® documentation to select the right roles for your use case.
In our example, we will simply reset the avnadmin password.
Once created or updated, the user has to be ready and have the status "READY" in the Control Panel.
Step 2: Authorize incoming connections from the PostgreSQL® client
In this step, select the Configuration tab (Access Control List). By default, a Public Cloud Database does not accept any form of connection from the outside world. This way, we can help prevent intrusive connection attempts.
In the IPs panel, enter the previously found IP of your Python environment and click the add + button.
Click Save changes when you are finished.
If you want to allow any connections from the outside, you can enter the IP 0.0.0.0/0. Please use it carefully. Every IP will be authorized.
NOTE: Before installing Wagtail, it is necessary to install the libjpeg and zlib libraries, which provide support for working with JPEG, PNG, and GIF images (via the Python Pillow library).
To install the libjpeg and zlib libraries, use the following command pairs:
-
sudo apt updateandsudo apt install libjpeg-dev -
sudo apt updateandsudo apt install zlib1g-dev
Instructions
Create and activate a virtual environment
Create an isolated virtual environment for your Python projects that can have unique dependencies, regardless of any other project's dependencies:
Depending on your version, you might need to use "python" rather than "python3" in the command below.
Set up your shell to execute Python packages by default:
If you’re using version control (e.g., git), mysite will be the directory for your project. The env directory inside it should be excluded from any version control.
Install Wagtail
Please follow the official documentation to install Wagtail.
Below, you will find a resume of the installation process
Use pip, which is packaged with Python, to install Wagtail and its dependencies:
Generate your site
Wagtail provides a start command similar to django-admin startproject. Running wagtail start mysite in your project will generate a new mysite folder with a few Wagtail-specific extras, including the required project settings, a “home” app with a blank HomePage model and basic templates, and a sample “search” app.
Because the folder mysite was already created by venv, run wagtail start with an additional argument to specify the destination directory:
This command will start the mysite folder created in the first step of this guide, and the second "mysite" in the command specifies that a new directory should be created in your current home directory and that Wagtail should start there.
Install project dependencies
Create the database
If you keep Wagtail on default settings, a local SQLite database will be used inside the project directory. It’s fine for a PoC but not recommended for production, for multiple reasons (performance, security, resiliency, etc.). Here we will configure Wagtail to use a Public Cloud Database for PostgreSQL® as a backend.
Before creating the database, let's edit the mysite/mysite/settings/base.py file and adapt the connection parameters to the database.
The useful parameters available in the OVHcloud Control Panel are:
| Information | Location |
|---|---|
| db Host | Dashboard tab, in the Connection information box. |
| db Port | Dashboard, in the Connection information box. |
| db Name | Databases tab, usually "defaultdb" |
| db User | Users tab, usually "avnadmin" |
| db Password | Displayed in Users tab after resetting. |
Then create the database:
This command ensures that the tables in your database are matched to the models in your project. Every time you alter your model (e.g., you may add a field to a model) you will need to run this command to update the database.
Create an admin user
When logged into the admin site, a superuser has full permissions and can view/create/manage the database.
Start the server
Run the following command, specifying the IP address of the virtual machine running wagtail.:
If the previous steps were successful, http://<your VM's IP>:8000 will show you a welcome page:
You can now access the administrative area at http://<your VM's IP>/admin:
Cleaning up
To clean your Wagtail, make sure it is closed by pressing CTRL+C in the terminal you used to launch it, then delete your installation folder.
To clean your PostgreSQL®, use the OVHcloud Control Panel to delete your managed PostgreSQL® service from the Configuration tab:
Go further
For more information and tutorials, please see our other Managed Databases & Analytics or Platform as a Service guides. You can also explore the guides for other OVHcloud products and services.
OVHcloud Managed Databases and Analytics:
- Grafana® is a registered trademark of Grafana Labs and is used with the permission of Grafana Labs. OVH SAS and its subsidiaries are not affiliated with or endorsed by Grafana Labs.
- Kafka® is a registered trademark of The Apache Software Foundation and has been licensed for use by OVHcloud, who has no affiliation with and is not endorsed by The Apache Software Foundation.
- MongoDB® is a registered trademark of MongoDB, Inc.
- MySQL® is a registered trademark of Oracle and/or its affiliates.
- PostgreSQL® is a registered trademark of the PostgreSQL Community Association of Canada.