Apache安装和部署
说明:本次实验采用系统为CentOs8.2版本
4.1 Nginx 安装和部署
4.1.1 Nginx安装:sudo yum install nginx
4.1.2 Nginx启动:sudo systemctl enable nginx,sudo systemctl start nginx
4.1.3 Nginx重启命令 nginx -s reload
4.1.4 Nginx配置静态资源
配置文件路径:etc/nginx/nginx.conf
1.资源路径:/data/www,放入静态页面

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 {
}
}
4.1.5 访问43.138.149.121

4.2 Apache 安装和部署
4.2.1 Centos 8.2 下的Apache安装:yum install httpd

4.2.2 启动Apache:systemctl start httpd
报错信息:Job for httpd.service failed because the control process exited with error code.See "systemctl status httpd.service" and "journalctl -xe" for details.

报错原因:Apache默认80端口被Nginx占用
解决方法:
1.修改默认端口80成82 /etc/httpd/conf/httpd.conf文件

2.吧82端口防火墙打开

3.重新输入systemctl start httpd命令,访问即可

4.2.3 Apache配置静态网页
1.查看配置文件httpd.conf里的资源路径:/var/www/html

2.把写好的静态页面放入该文件夹里,访问43.138.149.121:82即可



浙公网安备 33010602011771号