首页 > 系统相关 >nginx使用经验

nginx使用经验

时间:2023-02-22 06:55:17浏览次数:42  
标签:经验 server nginx html xxxx77 location conf 使用

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

标签:经验,server,nginx,html,xxxx77,location,conf,使用
From: https://www.cnblogs.com/lvye1221/p/17143091.html

相关文章