nginx使用经验
nginx使用经验
官网下载链接
https://nginx.org/en/download.html
service nginx stop
service nginx start
service nginx restart
/etc/init.d/nginx start
常用脚本
/nginx-1.22.0/start-nginx.bat
start nginx
/nginx-1.22.0/stop-nginx.bat
nginx -s stop
nginx -s quit
域名配置
conf/nginx.conf
...
include conf.d/xxxx77.conf;
include conf.d/xxxx88.conf;
}
xxxx88.conf 文件内容。多个域名之间 以空格 分隔
server
{
listen 80;
server_name xxxx88.com xxxx88.cn www.xxxx88.com www.xxxx88.cn;
location /
{
proxy_pass http://120.79.170.53:8080/;
}
}
xxxx77.conf 本地文件内容的显示:
server {
listen 80;
server_name xxxx77.com xxxx77.cn www.xxxx77.com www.xxxx77.cn xxxx77.anancar.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
问题及解决
端口被占用
nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
【解决办法】 换个端口启动即可。
// 命令行停止服务器
nginx -s stop
nginx -s quit
// 启动nginx
start nginx
不停服加载配置文件
1) nginx -t; nginx -s reload
2) nginx -t; kill -HUP
nginx -t 检查nginx配置的语法,操作前都要检查一下,很重要,发现错误可及时修正.
nginx 上传文件大小限制修改
client_max_body_size 1000m;
https://blog.csdn.net/bruce128/article/details/9665503
资料
nginx 反向代理与正向代理
https://blog.csdn.net/weixin_34138255/article/details/88032461
常用命令
service nginx stop
service nginx start
service nginx restart
/etc/init.d/nginx start
centos 7 下的 安装
centos 7
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
// 安装 nginx
yum install nginx -y
// 进入安装目录
cd /usr/share/nginx/html
// nginx 配置文件路径
/etc/nginx/nginx.conf
域名配置
conf/nginx.conf
...
include conf.d/xxxx77.conf;
include conf.d/xxxx88.conf;
}
xxxx88.conf 文件内容。多个域名之间 以空格 分隔
server
{
listen 80;
server_name xxxx88.com xxxx88.cn www.xxxx88.com www.xxxx88.cn;
location /
{
proxy_pass http://120.79.170.53:8080/;
}
}
xxxx77.conf 本地文件内容的显示:
server {
listen 80;
server_name xxxx77.com xxxx77.cn www.xxxx77.com www.xxxx77.cn xxxx77.anancar.cn;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
问题及解决
端口被占用
nginx: [emerg] bind() to 0.0.0.0:80 failed (10013: An attempt was made to access a socket in a way forbidden by its access permissions)
【解决办法】 换个端口启动即可。
// 命令行停止服务器
nginx -s stop
nginx -s quit
// 启动nginx
start nginx
不停服加载配置文件
- nginx -t; nginx -s reload
- nginx -t; kill -HUP
nginx -t 检查nginx配置的语法,操作前都要检查一下,很重要,发现错误可及时修正.
nginx 上传文件大小限制修改
client_max_body_size 1000m;
https://blog.csdn.net/bruce128/article/details/9665503
资料
nginx 反向代理与正向代理
https://blog.csdn.net/weixin_34138255/article/details/88032461
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· .NET10 - 预览版1新功能体验(一)