柚子快报邀请码778899分享:nginx使用经验

http://www.51969.com/

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

柚子快报邀请码778899分享:nginx使用经验

http://www.51969.com/

查看原文