赞
踩
优点:
缺点:
优点:
缺点:
优点:
缺点:
1、解压源码包
tar -xf httpd-2.4.29.tar.bz2
2、安装依赖环境:创建本地yum源后,安装依赖环境
yum install apr* gcc* pcre* -y
3、进入httpd-2.4.29目录下,带安装路径执行./configure (也可安装到/usr/local/httpd下)
./configure --prefix=/opt/apps/httpd #配置安装路径
4、编译
make
5、安装(时间较长,可以使用&&两条一起执行)
make install
6、关闭防火墙和安全机制,真实场景应配置防火墙规则
systemctl stop firewalld #关闭防火墙服务
systemctl disable firewalld #禁止开机自启
setenforce 0 #核心防护关闭
7、开启服务
/opt/apps/httpd/bin/apachectl start #开启服务
/opt/apps/httpd/bin/apachectl stop #停止服务
开启服务后会报警告
AH00558: httpd: Could not reliably determine the server's fully qualified do main name,
using localhost.localdomain.Set the 'ServerName' directive globally to suppress this message
调试状态下暂时可以忽视
8、使用curl命令模拟一个HTTP的形式来访问目标,再使用浏览器访问目标IP
curl 192.168.233.21
浏览器访问也是正常的
9、使用netstat查看端口占用情况,此时80端口是开启的
netstat -natp | grep 80
配置系统服务使systemctl可以管理httpd。
systemctl
是 Linux 系统上用于控制 systemd
系统和服务管理器的命令行工具。
假设安装到/usr/local/httpd/目录下,创建软连接
ln -s /usr/local/httpd/bin/* /usr/local/bin
此时在/usr/local/bin/目录下已经有了apachectl文件,此时系统已经可以识别这个命令,可以使用这个文件进行启动等操作
但是并没有配置系统服务,也就是systemctl 管理工具并不能识别httpd
systemctl status httpd
1、需要在/lib/systemd/system/创建httpd.service文件并添加配置信息
vim /lib/systemd/system/httpd.service
2、定义文件配置,将服务路径添加到systemd,才可以识别
[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
注:使用d+$可以向后删除
3、此时,systemctl已经可以控制httpd服务
systemctl start httpd
systemctl status httpd
4、在使用systemctl关闭前,最好先使用apachectl关闭
apachectl stop
5、使用netstat 可以查看到80端口启动
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。