Linux上部署nginx

1、下载nginx

  • 下载地址:https://nginx.org/en/download.html

2、把tar包上传到服务器上

3、安装nginx依赖

  • 由于nginx是C语言开发,运行时需要下载依赖:pcre、openssl、gcc、zlib
  • 命令(使用yum安装):yum -y install gcc zlib zlib-devel pcre-devel openssl openssl-devel

4、解压tar包

  • 命令:tar -xvf nginx-1.17.8.tar

5、执行nginx中的configure

  • 命令:
    • cd nginx-1.17.8
    • ./configure

6、解析nginx

  • 命令:
    • make
    • make install
  • 执行命令后,会在/usr/local/下会产⽣⼀个nginx⽬录

7、启动nginx

  • 命令:
    • cd nginx/sbin
    • ./nginx

8、验证

  • 访问虚拟机ip即可(默认端口为80)在这里插入图片描述

  • 如果无法访问则需要关闭防火墙

9、关闭防火墙

  • systemctl stop firewalld.service #停止firewall
  • systemctl disable firewalld.service #禁止firewall开机启动

10、主要命令

  • ./nginx 启动nginx
  • ./nginx -s stop 终⽌nginx(当然也可以找到nginx进程号,然后使⽤kill -9 杀掉nginx进程)
  • ./nginx -s reload (重新加载nginx.conf配置⽂件)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值