apache配置
使服务端可以连接http httpd,端口80 443
http 协议的请求的完整域名是:
http://主机IP
配置
1、tar -xf httpd-2.4.29.tar.bz2 #解压源码包
2、安装依赖环境:yum install apr* gcc* pcre* -y #创建本地yum源,后安装依赖环境
PS:进入httpd-2.4.29目录中,再执行以下内容
3、./configure --prefix=/opt/apps/httpd #配置安装路径
以下下两步可一个命令进行 make && make instal
4、编译: make
5、安装:make install
记得此处拍快照,有问题可以节省时间
6、开启服务:
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
#关闭防火墙和安全机制
/opt/apps/httpd/bin/apachectl start 开启服务
/opt/apps/httpd/bin/apachectl stop 停止服务
curl 主机IP
安装完成
优化管理
1、做个软链接,优化路径
ln -s /usr/local/httpd/bin/* /usr/local/bin
2、添加httpd系统服务
以下为添加systemctl 工具管理
vim /lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server #描述
After=network.target #描述服务类别
[Service]
Type=forking #后台运行方式
PIDFile=/opt/apps/httpd/logs/httpd.pid #PID文件位置
ExecStart=/usr/local/bin/apachectl $OPTIONS #启动服务
ExecReload=/bin/kill -HUP $MAINPID #根据PID重载配置
[Install]
WantedBy=multi-user.target
systemctl start httpd.service
systemctl enable httpd.service