In this blog post we will show you how to install Wagtail on Centos 7 with Nginx and uWSGI. Wagtail is open source flexible Django content management system focused on flexibility and user experience. This guide should work on other Linux VPS systems as well but was tested and written for a Centos 7 VPS.
Table of Contents
1. Login to your VPS via SSH
ssh root@vps
2. Install the EPEL repository
To install the EPEL repository on your CentOS VPS, just run:
[root]$ rpm -Uvh http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-8.noarch.rpm
3. Update the system and install necessary packages
[root]$ yum -y update [root]$ yum -y install python-pip python-virtualenv pcre-devel python-imaging python-devel libjpeg-turbo-devel make gcc
5. Create a new system user
Create a new user for Wagtail:
[root]$ adduser --comment 'Wagtail User' --home-dir /home/wagtail wagtail
[root]$ chmod 755 /home/wagtail
Install wagtail and
[root]$ pip install wagtail
6. Create a python virtual environment and your Wagtail project
The following commands are run as wagtail user. To switch to wagtail user run:
[root]$ su - wagtail
Create a new Wagtail project
[wagtail]$ wagtail start mysite
Create a new virtualenv using the following command
[wagtail]$ virtualenv wagtail-env
Switch to the new virtualenv
[wagtail]$ source ~/wagtail-env/bin/activate
Install all dependencies with pip:
(wagtail-env)[wagtail]$ cd mysite (wagtail-env)[wagtail]$ pip install -r requirements.txt
Create a new SQLite database
(wagtail-env)[wagtail]$ python manage.py migrate
Create an admin user
(wagtail-env)[wagtail]$ python manage.py createsuperuser
7. Install and configure Nginx and uWSGI
Nginx is not available by default in CentOS 7 so we will use the official Nginx repository:
[root]$ rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
To install Nginx run:
[root]$ yum -y install nginx
Next, create a new Nginx server block:
[root]$ nano /etc/nginx/conf.d/YOUR_WAGTAIL_DOMAIN.conf
server { server_name YOUR_WAGTAIL_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; } }
Install uWSGI using pip
pip install --upgrade uwsgi
Create uwsgi configuration file for Wagtail:
[root]$ mkdir /etc/uwsgi.d/
[root]$ nano /etc/uwsgi.d/wagtail.ini
[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
Open your editor of choice and create a new systemd service for Wagtail:
[root]$ nano /etc/systemd/system/uwsgi.service
and 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 and enable uWSGI at boot:
[root]$ systemctl enable uwsgi [root]$ systemctl start uwsgi
Start and enable Nginx at boot:
[root]$ systemctl enable nginx [root]$ systemctl start nginx
8. Verify Installation
That’s it. You have successfully installed your Wagtail. To access it, open http://YOUR_WAGTAIL_DOMAIN/
in your browser. For more information about Wagtail, please refer to the official Wagtail website.
Of course you don’t have to install Wagtail on CentOS 7 if you use one of our CentoOS 7 VPS Hosting services, in which case you can simply ask our expert Linux admins to Install Wagtail on CentOS 7, for you. They are available 24×7 and will take care of your request immediately.
PS. If you liked this post on how to install Wagtail on CentOS 7 please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.