linux使用nginx部署前端

1. 安装nginx

# 安装nginx,提示有依赖和密钥都填Y
yum install nginx

# 我这边安装nginx报错了,具体错误看下面截图
# 依次执行下面两条命令解决

# 更换国内源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo      && yum makecache

# 安装 repo源
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo

# 执行上面两条命令后,再此执行
yum install nginx

安装nginx的错误

2. 文件上传到服务器

# 安装
yum -y install lrzsz


# 我是用的是xshell, 用putty不弹窗,应该是不支持
# 执行命令, 弹出文件选择弹窗,选择文件
# -y 同名文件覆盖
rz -y

# 解压文件 -o 不必先询问用户,unzip执行后覆盖原有文件
unzip -o dist.zip

3. 启动nginx并且开放端口

# 查看nginx安装路径 
whereis nginx

# 查看nginx运行文件所在路径
which nginx

# 查看配置文件路径
nginx -t

# 启动nginx
nginx

# 重启nignx
nginx -s realod

# 关闭nginx
nginx -s stop

# 编辑nginx配置
vi /etc/nginx/nginx.conf

# 查看服务是否启动成功
ps -aux|grep nginx

# 查看nginx启动成功,但是浏览器访问失败,需要开放端口
firewall-cmd --zone=public --add-port=80/tcp --permanent

# 重启防火墙
systemctl restart firewalld.service

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值