This tutorial will guide you through the steps to install Wagtail, which is a Python-based web framework designed to create attractive, user-friendly websites. The steps below have been tested on Pop!_OS Latest, but should work on other versions of Linux as well.
Before you begin, ensure you have the following:
First, we need to ensure that Python3 and pip3 are installed on our system. Enter the following commands to install them:
sudo apt update
sudo apt install python3 python3-pip
Wagtail requires PostgreSQL to operate. You can install it with the following command:
sudo apt install postgresql
Now that PostgreSQL is installed, we need to create a database and user for Wagtail to use. To do so, use the following commands:
sudo su - postgres
psql
CREATE DATABASE wagtaildb;
CREATE USER wagtailuser WITH PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE wagtaildb TO wagtailuser;
Remember to replace 'password' with a new password of your choice.
Creating a virtual environment for Python is an optional but recommended step as it allows Wagtail to run in a contained environment. To create a virtual environment, use the following command:
python3 -m venv wagtail_venv
To activate the virtual environment, use the following command:
source wagtail_venv/bin/activate
Now that we have created a virtual environment and activated it, we can install Wagtail using pip3:
pip3 install wagtail
We are now ready to create a new Wagtail project. Use the following command to create a project named wagtailproject:
wagtail start wagtailproject
To configure Wagtail to use the PostgreSQL database,we need to edit the wagtailproject/settings/base.py
file. Use the following commands to edit the file:
cd wagtailproject
nano settings/base.py
Add the following changes to the database settings at the bottom of the file:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'wagtaildb',
'USER': 'wagtailuser',
'PASSWORD': 'password',
'HOST': 'localhost',
}
}
Save and close the file by pressing Ctrl + X
, Y
, and Enter
.
Now that we have configured the database, we need to migrate it. Run the following command:
python manage.py migrate
To manage the Wagtail project, we need to create a superuser account. Use the following command:
python manage.py createsuperuser
We are now ready to run the server using the following command:
python manage.py runserver
Go to this link on your web browser to view the application: http://localhost:8000/
Congratulations! You have successfully installed Wagtail and created a new project. You can now continue to develop your project, create new pages, and manage content using the Wagtail admin interface.
If you want to self-host in an easy, hands free way, need an external IP address, or simply want your data in your own hands, give IPv6.rs a try!
Alternatively, for the best virtual desktop, try Shells!