Python全系列 教程
3567个小节阅读:5931.6k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
1、nginx配置
配置文件位置:在 /usr/local/nginx/conf/nginx.conf
xxxxxxxxxx
########### 每个指令必须有分号结束。#################
# 配置用户或者组,默认为nobody nobody。
# user administrator administrators;
#允许生成的进程数,默认为1
# worker_processes 2;
# 指定nginx进程运行文件存放地址
#pid /nginx/pid/nginx.pid;
#制定日志路径,级别。这个设置可以放入全局块,http块,server块,级别依次为:debug|info|notice|warn|error|crit
error_log logs/error.log debug;
events {
#设置网路连接序列化,防止惊群现象发生,默认为on
accept_mutex on;
#设置一个进程是否同时接受多个网络连接,默认为off
multi_accept on;
#事件驱动模型,select|poll|kqueue|epoll|resig|/dev/poll|eventport
#use epoll;
#最大连接数,默认为 1024
worker_connections 1024;
}
http {
#文件扩展名与文件类型映射表
include mime.types;
#默认文件类型,默认为text/plain
default_type application/octet-stream;
# 取消服务日志
#access_log off;
#自定义格式
log_format myFormat '$remote_addr–$remote_user $request $status $body_bytes_sent $http_referer $http_user_agent $http_x_forwarded_for';
#combined为日志格式的默认值
access_log logs/access.log myFormat;
#允许sendfile方式传输文件,默认为off,可以在http块,server块,location块。
sendfile on;
#每个进程每次调用传输数量不能大于设定的值,默认为0,即不设上限。
sendfile_max_chunk 100k;
#连接超时时间,默认为75秒,可以在http,server,location块设置。
keepalive_timeout 65;
server {
# 端口
listen 80;
# 虚拟主机名,发布到互联网上写 域名,如: *.test.com
server_name 192.168.44.128;
# 默认编码
charset utf-8;
# 路径
location / {
# 开启对http1.1支持
proxy_http_version 1.1;
# 设置Connection为空串, 以禁止传递头部到后端
proxy_set_header Connection "";
# 包含 uwsgi配置,这个是相对路径,也可以使用绝对路径
include uwsgi_params;
# uwsgi的端口
uwsgi_pass 192.168.44.128:8997;
# 指定连接到后端uWSGI的超时时间。
uwsgi_send_timeout 60;
# 指定向uWSGI传送请求的超时时间,完成握手后向uWSGI传送请求的超时时间。
uwsgi_connect_timeout 60;
# 指定接收uWSGI应答的超时时间,完成握手后接收uWSGI应答的超时时间。
uwsgi_read_timeout 60;
}
# 静态文件,和django项目中的settings中配置的 STATIC_URL = '/static/' 相对应
location /static/ {
# 执行 collectstatic 合并静态文件之后的目录
alias /var/projectcode/netshop/static/;
}
# 媒体文件,用户上传的文件
location /media/ {
alias /var/projectcode/netshop/media/;
}
#error_page 404 /404.html;
# 将服务器的错误页面重定向到静态页面 /50x.html
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
将nginx.conf内容设置为空
xxxxxxxxxx
cp /dev/null nginx.conf
2、访问
在防火墙中开放对应的端口,譬如配置中的:80
在浏览器中访问即可
xxxxxxxxxx
http://192.168.44.128
注意事项
- 别忘记将 uwsgi.ini 的配置中端口配置的 http = 修改为 socket =