笔记:Nginx安装、配置、卸载

安装配置Nginx笔记(Ubuntu16.04)

卸载命令

卸载前最好先停止服务nginx -s stop 有时候不停止 直接卸载会出现卸不掉的情况

sudo apt-get --purge remove nginx

有时候会发现卸载不掉

用sudo apt-get autoremove命令去卸载

删除Nginx相关服务

dpkg --get-selections|grep nginx
 
sudo apt-get --purge remove nginx
 
sudo apt-get --purge remove nginx-common
 
sudo apt-get --purge remove nginx-core

安装Nginx

apt install -y nginx

常用命令

查找nginx路径:whereis nginx

启动 service nginx start

查看Nginx的版本号:nginx -V

停止 nginx -s stop

退出 nginx -s quit

重启加载配置 nginx -s reload

 

测试配置是否正确

配置Nginx

root@ubuntu:/etc/nginx# more nginx.conf 

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}

 

自定义配置文件

root@ubuntu:/etc/nginx# cd conf.d/
root@ubuntu:/etc/nginx/conf.d# more cloud.conf 
server {
    listen  80;
    root /home/app/run/html/dist;
    index index.html;
    error_page 404 index.html;
    location /cloudac/ {
        client_max_body_size    20m;
        proxy_pass http://localhost:8070/cloudac/;
        proxy_read_timeout 1800;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header REMOTE_ADDR $remote_addr;
    }

     location /file/ {
        alias  /home/www/file/;
    }
    location /tool/ {
        client_max_body_size    20m;
        proxy_pass http://localhost:9000/tool/;
        proxy_read_timeout 1800;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Scheme $scheme;
        proxy_set_header REMOTE_ADDR $remote_addr;
    }

  }

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值