Wagtail(https://wagtail.io/)是基于Django的开源内容管理系统,专注于灵活性和用户体验。
Wagtail的源代码:https://github.com/torchbox/wagtail
Features
A fast, attractive interface for authors and editors
Complete control over design with standard Django templates
Configure content types through standard Django models
Fast out of the box. Cache-friendly if you need it
Tightly integrated search
Strong document and image management
Wide support for embedded content
Straightforward integration with existing Django apps
Simple, configurable permissions
Workflow support
An extensible form builder
Multi-site and multi-language support
Optional static site generation
Excellent test coverage
本文记录在CentOS 7上安装配置Wagtail步骤,使用Nginx+uWSGI。
1.安装一些依赖包
安装EPEL仓库:
yum update
yum install epel-release
安装Python、gcc等:
yum install python-pip python-virtualenv pcre-devel python-imaging python-devel libjpeg-turbo-devel make gcc libtiff-devel libjpeg-devel libzip-devel freetype-devel lcms2-devel libwebp-devel tcl-devel tk-devel
2.创建新用户
为Wagtail创建一个用户:
useradd --comment 'Wagtail User' --home-dir /home/wagtail wagtail
更改wagtail用户家目录权限:
chmod 755 /home/wagtail
3.安装wagtail
pip install wagtail
4.创建Wagtail项目
切换到新创建的用户:
su - wagtail
创建Wagtail项目:
wagtail start newsite
创建虚拟环境:
virtualenv wagtail-env
切换到虚拟环境:
source ~/wagtail-env/bin/activate
安装项目依赖:
cd newsite
pip install -r requirements.txt
创建SQLite数据库:
python manage.py migrate
创建管理员用户:
python manage.py createsuperuser
启动:
python manage.py runserver
访问127.0.0.1:8000,如果没有问题按CTRL+C结束。
5.安装配置Nginx+uWSGI
退出到root用户,安装Nginx:
yum install nginx
安装uwsgi:
pip install --upgrade uwsgi
创建Nginx虚拟主机配置文件:
vim /etc/nginx/conf.d/wagtail.conf
写入内容:
server {
listen 80;
server_name your_domain.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;
}
}
注意替换上面的域名和uwsgi_pass。
配置uwsgi:
mkdir /etc/uwsgi.d/
vim /etc/uwsgi.d/wagtail.ini
写入内容:
[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
为wagtail创建后台服务:
vim /etc/systemd/system/uwsgi.service
写入内容:
[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
启动上面创建的服务:
systemctl enable uwsgi
systemctl start uwsgi
启动Nginx:
systemctl enable nginx
systemctl restart nginx
最后使用浏览器访问http://your_domain.com。