标签:isa tps php7.0 config uri reload cal fas generated
apt-get update
apt-get upgrade
apt-get install nginx
然后在浏览器输入IP地址若有nginx欢迎界面则成功
apt-get instll python3-pip
注意安装python3的pip而不是python,安装成功后可以更新pip
pip3 install Django
pip3 install uwsgi
也可以采用虚拟环境下的安装
安装成功后将项目上传至服务器
在Django的manage.py同目录下创建uwsgi.ini
添加下面内容,注意将地址改成自己的
[uwsgi]
chdir = /home/feixue/python/www/for_test //项目根目录
module = for_test.wsgi:application //指定wsgi模块
socket = 127.0.0.1:8000 //对本机8000端口提供服务
master = true //主进程
#vhost = true //多站模式
#no-site = true //多站模式时不设置入口模块和文件
#workers = 2 //子进程数
#reload-mercy = 10
#vacuum = true //退出、重启时清理文件
#max-requests = 1000
#limit-as = 512
#buffer-size = 30000
#pidfile = /var/run/uwsgi9090.pid //pid文件,用于下脚本启动、停止该进程
daemonize = /home/feixue/python/www/for_test/run.log
disable-logging = true //不记录正常信息,只记录错误信息
打开/etc/nginx/sites-available/default,更改配置
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
server_name your_ip;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
# try_files $uri $uri/ =404;
include uwsgi_params;
uwsgi_pass 127.0.0.1:8000;
}
location /media {
alias /usr/local/mysite/media; # your Django project's media files - amend as required
}
location /static {
alias /usr/local/mysite/statics;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
将your_ip更改为你的ip,且项目地址自己改
sudo uwsgi uwsgi.ini
sudo service nginx restart
若出现You may need to add ‘XXXXXXXX‘ to ALLOWED_HOSTS.
则在seting.py文件中添加即可
在setting.py中修改下列信息
DEBUG = False
STATIC_ROOT = os.path.join(BASE_DIR, 'statics')
然后执行
python manage.py collectstatic
这样就产生了static文件,静态请求由Nginx处理
标签:isa tps php7.0 config uri reload cal fas generated
原文地址:https://www.cnblogs.com/vhyz/p/8942980.html