记录步骤
1.购买云服务器(本文测试的是阿里云服务器)
记得设置安全组 默认连接服务器的是22端口 nginx默认端口80
2.VScode 安装插件 remote-ssh 或者使用 git bash
3.点击侧边栏,然后点击+号
输入 ssh root@47.113.xxx.xxx , 打开新页面 然后输入密码
4.连接成功
centos7.x => yum命令
centos8.x => dnf命令
5.安装nginx
yum install nginx 最后输入y
pwd 查看当前所在的路径
ls 查看当前路径下的文件
5.1 cd /etc/nginx
5.2 cat nginx.conf 查看nginx配置文件
5.3 service nginx start 启动nginx服务
注意: 打开公网IP显示如下页面.如果显示无法访问或者连接超时就是安全组的问题,添加80端口.
5.4 打开nginx配置文件
vim nginx.conf (vi:无颜色,vim有颜色)
5.5 按 i 开始编辑, 要保存: 先按esc,再按 : ,输入 wq ,按回车结束编辑
第一种配置
第二种配置
5.6 新建文件夹
cd /root
mkdir fhup
新建文件 touch fhup.js
删除文件 rm -rf fhup.js
5.7 然后打包好的文件拖到fhup文件夹下.
cd /root/nginx
service nginx restart
5.8 打开公网IP,刷新或者清理缓存显示网站
命令
yum search xxx 看有没有xxx
yum install xxx
systemctl start nginx 执行没有错误就是启动成功
systemctl status nginx 有active(running)就是启动状态
systemctl enable nginx 默认启动
systemctl restart nginx 重启nginx