【备忘录】Nginx + Gunicorn的配置(RHEL)
序言
我自己的记事本,因为切换到日文键盘有点麻烦,所以用英语写。如果我有兴趣,就会改成日语。
安装最新版本的Nginx。
安装
注意:安装 yum-utils,请参考 http://nginx.org/en/linux_packages.html#RHEL-CentOS
yum install yum-utils
建立存储库(/etc/yum.repos.d/nginx.repo)
[nginx-stable]
name=nginx stable repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=1
enabled=1
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
[nginx-mainline]
name=nginx mainline repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=1
enabled=0
gpgkey=https://nginx.org/keys/nginx_signing.key
module_hotfixes=true
安装nginx
yum install nginx
配置
.conf文件
server {
listen 80;
server_name foobar;
# Read static files by nginx
location /static {
alias /usr/share/nginx/html/static;
}
location / {
proxy_pass http://127.0.0.1:8000/;
}
}
服务命令
systemctl start nginx
Python
– Python程序设计语言
– 一种编程语言:Python
– Python编程语言
有一天
独角兽
安装
请在终端输入以下命令进行安装:pip install gunicorn
配置
wsgi_app = config.wsgi:application
chdir = '/etc/foo/bar'
daemon = False
bind = '127.0.0.1:8000'
workers = 3
timeout = 300
# worker_class = 'gevent'
capture_output = True
accesslog = '/var/log/gunicorn/access.log'
errorlog = '/var/log/gunicorn/error.log'
[Unit]
Description=gunicorn daemon
After=network.target
[Service]
User=root
Group=root
WorkingDirectory=/etc/foo/bar
ExecStart=/etc/foo/env/bin/gunicorn \
--config /etc/foo/setting.py
[Install]
WantedBy=multi-user.target
服务命令
systemctl start gunicorn