Bootstrap

源码编译安装httpd 2.4,提供系统服务管理脚本并测试

1.安装httpd

  1. wget https://downloads.apache.org/httpd/httpd-2.4.62.tar.gzbmcv
  2. tar -zxvf httpd-2.4.62.tar.gz
  3. cd httpd-2.4.62

2.安装依赖包 

  1. sudo yum install -y gcc make apr-devel apr-util-devel pcre-devel

  2. 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

 

;