Centos下安装ngnix

### 设置安装源

[centos@localhost root]$ sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

获取http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

警告:/var/tmp/rpm-tmp.fyErPh: 头V4 RSA/SHA1 Signature, 密钥 ID 7bd9bf62: NOKEY

准备中...                          ################################# [100%]

正在升级/安装...

   1:nginx-release-centos-7-0.el7.ngx ################################# [100%]

[centos@localhost root]$ sudo yum install nginx

已加载插件:fastestmirror

Loading mirror speeds from cached hostfile

 * base: mirrors.tuna.tsinghua.edu.cn

 * extras: mirrors.tuna.tsinghua.edu.cn

 * updates: mirrors.huaweicloud.com

nginx                                                    | 2.9 kB     00:00

nginx/x86_64/primary_db                                    |  67 kB   00:01

正在解决依赖关系

--> 正在检查事务

---> 软件包 nginx.x86_64.1.1.20.1-1.el7.ngx 将被 安装

--> 解决依赖关系完成

依赖关系解决

================================================================================

 Package       架构           版本                          源             大小

================================================================================

正在安装:

 nginx         x86_64         1:1.20.1-1.el7.ngx            nginx         790 k

事务概要

================================================================================

安装  1 软件包

总下载量:790 k

安装大小:2.8 M

Is this ok [y/d/N]: y

Downloading packages:

nginx-1.20.1-1.el7.ngx.x86_64.rpm                          | 790 kB   00:13

Running transaction check

Running transaction test

Transaction test succeeded

Running transaction

警告:RPM 数据库已被非 yum 程序修改。

  正在安装    : 1:nginx-1.20.1-1.el7.ngx.x86_64                             1/1

----------------------------------------------------------------------

Thanks for using nginx!

Please find the official documentation for nginx here:

* https://nginx.org/en/docs/

Please subscribe to nginx-announce mailing list to get

the most important news about nginx:

* https://nginx.org/en/support.html

Commercial subscriptions for nginx are available on:

* https://nginx.com/products/

----------------------------------------------------------------------

  验证中      : 1:nginx-1.20.1-1.el7.ngx.x86_64                             1/1

已安装:

  nginx.x86_64 1:1.20.1-1.el7.ngx

完毕!

## 查看版本

[centos@localhost root]$ nginx -version

nginx version: nginx/1.20.1

[centos@localhost root]$ whereis nginx

nginx: /usr/sbin/nginx /usr/lib64/nginx /etc/nginx /usr/share/nginx /usr/share/man/man8/nginx.8.gz

```

## 设置开机自动启动

[centos@localhost root]$ sudo systemctl start nginx

[centos@localhost root]$ sudo systemctl enable nginx

Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.

## nginx 80端口改成6180

[centos@localhost root]$ cd /etc/nginx/conf.d

[centos@localhost conf.d]$ ls

default.conf

[centos@localhost conf.d]$ sudo vi default.conf

### 访问测试

192.168.1.147:8080

https://118.213.240.3:6180/

## 反向代理mysql

和http同级

stream {

    server {

        listen 6181;

        proxy_connect_timeout 1s;

        proxy_timeout 300s;

        proxy_pass 127.0.0.1:3306;

    }

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

citip

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值