1.设置IP地址
cd /etc/sysconfig/network-scripts
vi ifcfg-ens32
ONBOOT = yes
BOOTPROTO=static
IPADDR=192.168.172.88
NETMASK=255.255.255.0
GATEWAY=192.168.172.2
DNS1=192.168.172.2
systemctl restart network
2.安装ifconfig
yum install net-tools.x86_64
3.yum安装nginx
安装参考:CentOS7中使用yum安装Nginx的方法 https://www.cnblogs.com/songxingzhu/p/8568432.html
(1)sudo rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
(2)sudo yum install -y nginx
(3)启动
sudo systemctl start nginx.service
sudo systemctl enable nginx.service
(4)开启防火墙
参考:https://blog.csdn.net/a727911438/article/details/88938637
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
4.从windows上复制前端项目代码到nginx上。
(1)/etc/nginx/nginx.conf
(2)/etc/nginx/conf.d/default.conf
root /usr/share/nginx/html;
步骤:a. 在/usr/share/nginx/文件夹下创建angular文件夹,与html文件夹平级。
b. cp ./html/* ./angular 将html文件夹下的文件全部复制到angular下
c. 在windows上进入 F:\study\test\dist\test,将该目录下的所有文件及文件夹全部复制到 /usr/share/nginx/angular下
pscp -r ./ root@192.168.172.88:/usr/share/nginx/angular
d.进入/etc/nginx/conf.d/default.conf,
将 root /usr/share/nginx/html; 修改为 root /usr/share/nginx/angular;
建议将default.conf在修改之前备份一份,备份的文件不要使用.conf做后缀,否则nginx会一起加载。
e.重启nginx即可
systemctl restart nginx
注:采用编译安装,请参考:
https://www.cnblogs.com/zhoading/p/8514050.html
原文:https://www.cnblogs.com/modestlin/p/13040289.html