ManagedCloud Servers

High performance handled and monitored by us 24/7/365. A complete solution to provide you with our in house expertise 24/7 tailored to your specific needs. We'll setup a bespoke server for your site using the latest tehnologies so you can get the most out of your hardware and get your website loading quickly and reliably. Find out more..

cPanelCloud Servers

Recommended - High performance cloud servers with no technical knowledge required. If you're hosting multiple websites already and you're looking to consolidate, or if you're looking to isolate yourself from the shared hosting environment but you don't have the time or knoweldge to manage a server, then the Managed cPanel Servers are for you. Find out more..

UnmanagedCloud Servers

Our unmanaged range gives you complete control at rock bottom prices and our cloud platform boasts super fast multipath 40Gb/s network, the latest Intel Xeon V3 CPUs and enterprise grade redundant SSDs. If you're a sysadmin look no further, we offer some of the best specification to price ratio servers available. Find out more..

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans

How to Install Wagtail CMS on CentOS 7

Wagtail is a free and open source Content Management System written in Python and built on Django.

It is simple, fast, beautiful and provides a fast attractive interface for editors. Wagtail is a flexible Django content management system focused on flexibility and user experience.

It comes with lots of features, some of them are listed below:

  1. Support for multiple language and sites.
  2. Provides an attractive interface for authors and editors.
  3. Comes with integrated search.
  4. Supports embedded content.
  5. Easily build and manage custom forms.

In this guide, we will go through how to install Wagtail on CentOS 7 with Nginx.

Requirements

  • A fresh server running CentOS 7.
  • A non root user with sudo privileges setup on your server.

Install Required Packages

Before starting, let's start to install the EPEL repository on your CentOS 7 server.

sudo yum install epel-release -y

After installing the EPEL repository, update your system's package repository with the latest version with the following command:

sudo yum update -y

Once your system is up to date, install required packages by running the following command:

sudo yum install python-pip python-virtualenv pcre-devel python-imaging python-devel libjpeg-turbo-devel make gcc -y

Once all the packages are installed, you can proceed to install Wagtail.

Install Wagtail

Before installing Wagtail, you will need to create a new system user for Wagtail.

To do so, run the following command:

sudo adduser --home-dir /home/wagtail wagtail

Next, give proper permissions to the Wagtail home directory with the following command:

sudo chmod 755 /home/wagtail

Next, install Wagtail with the pip command as below:

sudo pip install wagtail

Once Wagtail is installed, you will need to create a python virtual environment and your Wagtail project.

First, switch to wagtail user with the following command:

su - wagtail

Next, create a new Wagtail project with the following command:

wagtail start newsite

Next, create a new virtualenv using the following command:

virtualenv wagtail-env

Next, activate the new virtual environment witht the following command:

source ~/wagtail-env/bin/activate

Next, install all the required dependencies by running the pip command:

(wagtail-env)[wagtail]$ cd newsite (wagtail-env)[wagtail]$ pip install -r requirements.txt

Next, you will need to create a new SQLite database and an admin user. You can do this by running the following command:

(wagtail-env)[wagtail]$ python manage.py migrate (wagtail-env)[wagtail]$ python manage.py createsuperuser

Once you are done, you can proceed to install Nginx.

Install and Configure Nginx

By default Nginx is not available in the CentOS 7 repository, so you will need to add the official Nging repository first.

To add the Nginx repository, run the following command:

sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

Once Nginx repository is installed, install Nginx with the following command:

sudo yum install nginx -y

Next, create a new Nginx virtual host file with the following command:

sudo nano /etc/nginx/conf.d/Wagtail.conf

Add the following contents:

server {
    server_name yourdomain.com;

client_body_in_file_only clean; client_body_buffer_size 64K; client_max_body_size 40M; sendfile on; send_timeout 300s;

error_log /var/log/nginx/wagtail_error.log; access_log /var/log/nginx/wagtail_access.log;

location / { uwsgi_pass unix:/home/wagtail/newsite/newsite/wagtail.socket; include /etc/nginx/uwsgi_params; uwsgi_param UWSGI_SCHEME $scheme; uwsgi_param SERVER_SOFTWARE nginx/$nginx_version; } }

Save and close the file when you are finished.

Next, you will need to install uWSGI to your server.

You can install it by using the pip command as below:

sudo pip install --upgrade uwsgi

Next, create a uwsgi configuration file for Wagtail.

sudo mkdir /etc/uwsgi.d/sudo nano /etc/uwsgi.d/wagtail.ini

Add the following lines:

[uwsgi]
chmod-socket = 666
virtualenv = /home/wagtail/wagtail-env
mount  = /=wsgi:application
chdir  = /home/wagtail/newsite/
wsgi-file = newsite/wsgi.py
socket = /home/wagtail/newsite/newsite/%n.socket
stats  = /home/wagtail/newsite/newsite/%n.stats.socket
logto  = /home/wagtail/newsite/newsite/%n.log
workers = 4
uid = wagtail
gid = wagtail
limit-as = 512

Save and close the file when you are finished.

Next, create a new service file for Wagtail.

sudo nano /etc/systemd/system/uwsgi.service

Add the following lines:

[Unit]
Description=uWSGI Emperor Service
After=syslog.target

[Service] ExecStart=/usr/bin/uwsgi --master --die-on-term --emperor /etc/uwsgi.d ExecReload=/bin/kill -HUP $MAINPID KillSignal=SIGINT Restart=always Type=notify StandardError=syslog NotifyAccess=all

[Install] WantedBy=multi-user.target

Save the file, then start uWSGI service and enable it to start on boot with the following command:

sudo systemctl start uwsgi sudo systemctl enable uwsgi

Finally, start Nginx service and enable it to start on boot time with the following command:

sudo systemctl start nginx sudo systemctl enable nginx

Once you are done, you can proceed to access the Wagtail web interface.

Access Wagtail

Before accessing the Wagtail web interface, you will need allow port 80 through firewalld.

You can do this by running the following command:

sudo firewall-cmd --permanent --zone=public --add-port=80/tcp

Next, reload the firewalld with the following command:

sudo firewall-cmd --reload

Finally, open your web browser and type the URL http://yourdomain.com/, then complete the required steps to finish the installation.

Conclusion

I hope you now have enough knowledge to install and configure Wagtail on CentOS 7 server. You can now easily deploy it to your production environment.

Want your very own server? Get our 1GB memory, Xeon V4, 20GB SSD VPS for £10.00 / month.

View Plans