1.安装httpd
wget https://downloads.apache.org/httpd/httpd-2.4.62.tar.gzbmcv
tar -zxvf httpd-2.4.62.tar.gz
cd httpd-2.4.62
2.安装依赖包
sudo yum install -y gcc make apr-devel apr-util-devel pcre-devel
sudo yum groupinstall "Development Tools"
3.配置和编译
./configure --prefix=/usr/local/apache2 --enable-so --with-mpm=event
make
sudo make install
4.配置环境变量
echo 'export PATH=/usr/local/apache2/bin:$PATH' >> /etc/profile.d/httpd2.sh
source /etc/profile.d/httpd2.sh
配置系统服务
[Unit]
Description=The Apache HTTP Server
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/apache2/bin/apachectl start
ExecReload=/usr/local/apache2/bin/apachectl graceful
ExecStop=/usr/local/apache2/bin/apachectl stop
PIDFile=/usr/local/apache2/logs/httpd.pid
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载systemd
sudo systemctl daemon-reload
启动服务
sudo systemctl start httpd
检查服务状态
sudo systemctl status httpd