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即可
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· .NET10 - 预览版1新功能体验(一)