CentOSLinuxTutorials

How To Install Wagtail on CentOS 7

Install Wagtail on CentOS 7

In this tutorial, we will show you how to install Wagtail on your CentOS 7. For those of you who didn’t know, For those of you who didn’t know, Wagtail is a free and open-source Content Management System written in Python and constructed on Django. It is easy, fast, beautiful, and provides a fast, appealing interface for both editors. Wagtail is a flexible Django content management program focused on flexibility and consumer expertise.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of Wagtail CMS on a CentOS 7 server.

Prerequisites

  • A server running one of the following operating systems: CentOS Linux.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install Wagtail on CentOS 7

Step 1. First, let’s start by ensuring your system is up-to-date.

yum clean all
yum -y install epel-release
yum -y update

Step 2. Installing Required Packages.

Install the necessary packages:

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

Step 3. Create a new system user.

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

adduser --comment 'Wagtail User' --home-dir /home/wagtail wagtail
chmod 755 /home/wagtail

Step 4. Installing Wagtail.

Next, install Wagtail with the pip command as below:

pip install wagtail

Step 5. Create a python virtual environment and your Wagtail project.

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

su - wagtail

Create a new Wagtail project:

wagtail start mysite

Create a new virtualenv using the following command:

virtualenv wagtail-env

Switch to the new virtualenv:

source ~/wagtail-env/bin/activate

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

cd mysite
pip install -r requirements.txt

Next, create a new SQLite database:

python manage.py migrate
python manage.py createsuperuser

Step 6. Installing and configure Nginx and uWSGI.

Add the official Nginx repository first:

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

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

yum install nginx -y

Next, create a new Nginx vhost:

nano /etc/nginx/conf.d/YOUR_WAGTAIL_DOMAIN.conf
Add the following lines:

server {
 server_name your-domain;
 
 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/mywagtailsite_error.log;
 access_log /var/log/nginx/mywagtailsite_access.log;

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

Next, you will need to install uWSGI on your server:

pip install --upgrade uwsgi

Create uwsgi configuration file for Wagtail:

mkdir /etc/uwsgi.d/
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/mysite/
wsgi-file = mysite/wsgi.py
socket = /home/wagtail/mysite/mysite/%n.socket
stats = /home/wagtail/mysite/mysite/%n.stats.socket
logto = /home/wagtail/mysite/mysite/%n.log
workers = 4
uid = wagtail
gid = wagtail
limit-as = 512

Next, create a new service file for Wagtail:

nano /etc/systemd/system/uwsgi.service

Add the following code 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

Start uWSGI service and enable it to start on boot with the following command:

systemctl enable uwsgi
systemctl start uwsgi

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

systemctl enable nginx
systemctl start nginx

Step 6. Wagtail CMS.

Wagtail CMS will be available on HTTP port 80 by default. Open your favorite browser and navigate to http://your-domain.com/ or http://your-server-ip and complete the required steps to finish the installation.

Congratulations! You have successfully installed Wagtail. Thanks for using this tutorial for installing Wagtail CMS on CentOS 7 systems. For additional help or useful information, we recommend you check the official Wagtail CMS website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button