Nginx 安装和部署
1.1 Nginx安装:sudo yum install nginx
1.2 Nginx启动
sudo systemctl enable nginx
sudo systemctl start nginx
![](https://img2022.cnblogs.com/blog/2211217/202207/2211217-20220705112746855-345789060.png)
1.3 Nginx重启命令 nginx -s reload
1.4 Nginx配置静态资源
配置文件路径:etc/nginx/nginx.conf
1.资源路径:/data/www,新建文件夹后放入静态页面
![](https://img2022.cnblogs.com/blog/2211217/202206/2211217-20220608012633032-1247520697.png)
2.默认首页地址 http://ip 访问index.html
配置文件修改
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /data/www;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
# 启动默认路径 搭配tomcat
proxy_pass http://43.138.149.121:8080/maven2/;
index index.html index.htm;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
1.5 访问43.138.149.121
![](https://img2022.cnblogs.com/blog/2211217/202206/2211217-20220608012408516-2060734439.png)