版权声明:本文为博主FelixHsp原创文章,遵循 CC 4.0 by-sa 版权协议,转载请附上原文出处链接和本声明。
转载链接:https://blog.csdn.net/FelixHsp/article/details/90047435
安装nginx
//安装nginx
yum install nginx
//开机自启动
systemctl start nginx.service
systemctl enable nginx.service
然后访问公网ip地址测试,如果安装成功会有welcome界面。
使用WinSCP软件将上一步打包的目录传到服务器中,本文将build传到了/usr目录下。
cd /etc
cd nginx
cd nginx.conf
将location 中root后面改成你存build的路径。本文在user目录下。
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name http://www.burc.com.cn;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /usr/build;
index index.html index.htm;
#proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_pass http://127.0.0.1:3001;
}
#location /api {
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_pass http://127.0.0.1:3002;
#}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
重启nginx服务,在浏览器中输入你的公网ip,即可看到你的react项目。
systemctl stop nginx
systemctl start nginx
Docker重启命令
[root@iz2ze5zpq4w7pqprh21agwz bin]# systemctl start docker
[root@iz2ze5zpq4w7pqprh21agwz bin]# docker ps