1、安装nginx
yum -y install gcc make zlib-devel pcre pcre-devel openssl-devel
sudo yum install -y nginx
2、配置防火墙80与443
sudo firewall-cmd --permanent --zone=public --add-service=http sudo firewall-cmd --permanent --zone=public --add-service=https sudo firewall-cmd --reload
3、nginx常用命令
查看nginx状态
sudo systemctl status nginx
启用nginx服务器
sudo systemctl start nginx
重新加载nginx服务器
sudo systemctl reload nginx
禁用nginx服务器
sudo systemctl disable nginx
4、nginx使用位置
配置文件位置
/etc/nginx
日志文件位置
/var/log/nginx
5、修改配置文件 /etc/nginx/nginx.conf
user nginx; worker_processes 1; error_log /var/log/nginx/error.log; #日志地址 pid /run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; access_log /var/log/nginx/access.log; #请求日志 sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; server { listen 80; #监听端口 server_name www.xiaoyaodijun.com; #监听域名或ip charset utf-8; location /{ include uwsgi_params; uwsgi_pass xxx.xx.xx.xx:7000; #与uwsgi的通信地址,必须与uwsgi的配置保持一致 uwsgi_param UWSGI_SCRIPT WebTest.wsgi;#项目wsgi.py目录 uwsgi_param UWSGI_CHDIR var/dongsheng/WebTest;#项目目录 } } }
6、启用uwsgi+nginx,并请求