一、uwsgi安装部署
1、pip install uwsgi
2、配置xml文件
<uwsgi>
<socket>127.0.0.1:8001</socket>
<chdir>/opt/dockeradmin</chdir><!-->项目路径,用来处理请求<-->
<pythonpath>/opt/dockeradmin</pythonpath> <!-->应用文件所在的路径,也就是项目所在路径,也可写成'..'意为当前路径<-->
<module>wsgi</module><!-->wsgi.py文件位置,如果在某个app下面则写成appname.wsgi,因为这个问题曾经报错no python application found, check your startup logs for errors,折腾死了<-->
<processes>4</processes>
<py-autoreload>1</py-autoreload>
<pidfile>/tmp/dockeradmin.pid</pidfile>
</uwsgi>
3、 uwsgi -x uwsgi.xml –daemonize /var/log/uwsgi.log 运行
二、nginx
1、准备yum源
vi /etc/yum.repo.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enable=1
准备好了源之后,更新源
$ yum clean all
$ yum makecache
2、安装nginx
$ yum install -y nginx
安装成功之后可以通过 $ nginx -v查看版本
[root@docker php-5.5.38]# nginx -v
nginx version: nginx/1.13.0
3、启动nginx
nginx
4、关闭nginx
nginx -s stop
5、重新加载
nginx -s reload
6、nginx配置
vim /etc/nginx/conf.d/default.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
upstream project1 {
server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}
upstream project2 {
server 127.0.0.1:8002; # for a web port socket (we'll use this first)
}
server{
listen 8091;
#server_name somename alias another.alias;
location / {
include /opt/dockeradmin/uwsgi_params;
uwsgi_pass project1;
}
location /static/ {
alias /opt/dockeradmin/static/;
}
}
server{
listen 8092;
#server_name somename alias another.alias;
location / {
include /etc/nginx/uwsgi_params;
uwsgi_pass project2;
}
location /static/ {
alias /root/project/python-publish/pub-update/static/;
}
}
}
本文介绍如何使用pip安装UWSGI并配置XML文件,同时详细展示了Nginx的安装步骤及配置方法,包括YUM源设置、启动停止命令、配置文件编辑等。
1270

被折叠的 条评论
为什么被折叠?



