• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 众包
  • 赞助商
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录

cokelike

  • 博客园
  • 联系
  • 订阅
  • 管理

公告

View Post

Nginx linux安装

官网下载地址:(.tar.gz)

https://nginx.org/en/download.html

安装linux-nginx:

wget -c http://nginx.org/download/nginx-1.22.0.tar.gz //下载nginx
tar -zxvf nginx-1.22.0.tar.gz
yum -y install gcc gcc-c++ autoconf automake make
yum -y install openssl openssl-devel
cd nginx-1.22.0
//配置configure --prefix 代表安装的路径,--with-http_ssl_module 安装ssl,--with-http_stub_status_module查看nginx的客户端状态
./configure --prefix=/usr/local/nginx-1.22.0 --with-http_ssl_module --with-http_stub_status_module
make & make install //编译nginx

常用命令:

./nginx -v   //查看版本
find / -name nginx.conf  //nginx配置文件的位置
ps aux|grep nginx  //查看服务是否已经启动
netstat -tnlp   //查看端口监听状态
./nginx -t   //验证nignx配置文件是否正确
./nginx -s reload   //重启./nginx -s stop, quit, reopen, reload
./nginx -s quit //此方式停止步骤是待nginx进程处理任务完毕进行停止。
./nginx -s stop //此方式相当于先查出nginx进程id再使用kill命令强制杀掉进程。
./nginx //启动

常用配置:

find / -name nginx.conf //查找nginx配置
vi /usr/local/nginx-1.22.0/conf/nginx.conf
cd /usr/local/nginx-1.22.0/sbin/ #启动位置 ./nginx -s reload
/usr/local/nginx-1.22.0/logs #log日志

linux:配置:

server {
        listen       80;
        server_name  localhost;
        location / {
                root  /xx/xx/dist;
                index  index.html index.htm;
                try_files $uri $uri/ @router;
        }
        location @router {
               rewrite ^.*$ /index.html last;
        }
        location /api/ {
                proxy_pass   http://127.0.0.1:8080/;
       }
	 location /files {
            proxy_pass  http://xxx/api;
            proxy_redirect off; #重定向
            proxy_set_header Host $host;    #后端的Web服务器可以通过X-Forwarded-For>获取用户真实IP
            proxy_set_header X-Real-IP $remote_addr; #添加远程地址
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; #代理地址转发
            client_max_body_size 5120m;   #允许客户端请求的最大单文件字节数
            client_body_buffer_size 5m; #缓冲区代理缓冲用户端请求的最大字节数
            proxy_connect_timeout 600;   #nginx跟后端服务器连接超时时间(代理连接超时)
            proxy_read_timeout 600;      #连接成功后,后端服务器响应时间(代理接收超时)
            proxy_buffer_size 2m;       #设置代理服务器(nginx)保存用户头信息的缓冲区大小
            proxy_buffers 3 2m;        #proxy_buffers缓冲区,网页平均下载设置
            proxy_busy_buffers_size 2m; #高负荷下缓冲大小proxy_buffer_size=proxy_busy_buffers_size<=proxy_buffers
            proxy_temp_file_write_size 2m; #设定缓存文件夹大小,大于这个值,将从upload服务器传
        }
}

  

posted on 2022-06-26 13:24  cokelike  阅读(59)  评论(0)    收藏  举报

刷新页面返回顶部
 
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3