yum update -y
yum -y groupinstall "Development tools"
yum install openssl-devel bzip2-devel expat-devel gdbm-devel readline-devel sqlite-devel psmisc libffi-devel
pip3 install uwsgi # 安装uwsgi
wget http://nginx.org/download/nginx-1.18.0.tar.gz # 下载nginx
nginx下载网站:http://nginx.org/en/download.html
tar zxvf nginx-1.18.0.tar.gz -C /opt/install/
目的:检测环境中依赖是否完整,设置python的安装位置,
同时生成一个编译文件,用于进行python编译:make
./configure --prefix=/usr/local/Python3 --enable-optimizations (这个不用)
./configure
wget http://downloads.sourceforge.net/project/pcre/pcre/8.35/pcre-8.35.tar.gz #下载pcre
tar zxvf nginx-1.18.0.tar.gz -C /opt/install/
##### 进入到解压的文件夹#####
检查配置:./configure
安装:make && make install
pcre下载网站:https://sourceforge.net/projects/pcre/files/pcre/
./configure # 检查配置
make && make install # 编译安装
默认情况下,nginx会安装到/usr/local/nginx下面;
可以指定到安装到/root目录下:编译:./configure --prefix=/root/nginx
安装:make && make install
进入到安装目录
cd /usr/local/nginx/sbin/
./nginx -s stop #停止Nginx
./nginx #启动Nginx
./nginx -s reload
upstream ems{
server 192.168.157.141:9001; # uWSGI's socket = 192.168.x.x:9001
#可以在添加其他的uWSGI的服务器
#对 原有 uWSGI服务器进行 克隆,配置ip。
}
server {
listen 80;
server_name 192.168.157.142; # nginx服务器的ip
charset utf-8;
location / {
uwsgi_pass ems; #和上面的upstream转接
include /usr/local/nginx/conf/uwsgi_params; # the uwsgi_params file you installed
}
location /static { #http://ip:80/static/a/b/c/d.png ==> /usr/local/static/a/b/c/d.png
alias /usr/local/static; # your Django project's static files - amend as required
}
...
}
配置好后,重启nginx即可,可以使用Nginx服务器来访问项目