yum groupinstall "Development tools"
yum install zlib-devel bzip2-devel pcre-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel wget gcc make zip* openssl-devel libffi-devel xz-devel python-backports-lzma -y
mv /usr/bin/python /usr/bin/python.bak
wget https://www.python.org/ftp/python/3.6.2/Python-3.6.2.tar.xz
tar -xvJf Python-3.6.2.tar.xz
cd Python-3.6.2
./configure --prefix=/usr/local/python3
make && make install
ln -s /usr/local/python3/bin/python3.6 /usr/bin/python3
vi /usr/bin/yum
#把 #! /usr/bin/python 修改为#! /usr/bin/python2
vi /usr/libexec/urlgrabber-ext-down
# 把 #! /usr/bin/python 修改为 #! /usr/bin/python2
python -V
python2 -V
直接使用pip命令,由于刚刚安装了python3.6,会自动安装pip3,所以不用手动安装pip
mv /usr/bin/pip /usr/bin/pip.bak
ln -s /usr/local/python3/bin/pip3 /usr/bin/pip
pip3 install uwsgi -i https://pypi.tuna.tsinghua.edu.cn/simple/
yum install python-devel
ln -s /usr/local/python3/bin/uwsgi /usr/bin/uwsgi
pip install django==1.11.9
wget http://101.96.10.45/nginx.org/download/nginx-1.15.6.tar.gz
tar xf nginx-1.15.6.tar.gz
cd nginx-1.15.6
./configure --prefix=/usr/local/nginx \
--with-http_stub_status_module \
--with-http_gzip_static_module
make && make install
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
DEBUG = True
ALLOWED_HOSTS = ['*']
STATIC_ROOT = os.path.join(BASE_DIR, "/var/www") # /var/www是要迁移文件的目录,这里要与待会nignx的配置一致
python manage.py collectstatic
:8000
/root/django_app/OneBlog
OneBlog.wsgi
4
uwsgi.log
vim /usr/local/nginx/conf/nginx.conf
在http{ }中修改以下内容
server {
listen 80;
server_name localhost;
keepalive_requests 120;
charset utf-8;
#access_log logs/host.access.log main;
access_log off;
location /static {
alias /var/www/; #要与之前django的setting.py中添加的static静态文件转移目录一致
}
location / {
uwsgi_pass 127.0.0.1:8000; # 端口与uwsgi中设置的端口一致
include uwsgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
uwsgi -x socket.xml & nginx
在这里常用的几个命令
重启nginx nginx -s reload
关闭uwsgi killall -9 uwsgi