apache源码安装

作者: admin 分类: Linux 发布时间: 2018-05-18 16:43 浏览:4,224 次    

环境:Centos 7.4      apr-1.5.2     apr-util-1.5.2     httpd-2.4.27

1、安装依懒包

[root@localhost ~]# yum install openssl-devel pcre-devel -y

2、安装apr

[root@localhost ~]# mkdir /usr/local/apr
[root@localhost ~]# tar xvf apr-util-1.5.2.tar.gz -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/apr-1.5.2/
[root@localhost apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.5.2]# make -j 2 && make install

3、安装apr-util

[root@localhost ~]# mkdir /usr/local/apr-util
[root@localhost ~]# tar xvf apr-util-1.5.2.tar.gz -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/apr-util-1.5.2
[root@localhost apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@localhost apr-util-1.5.2]# make && make install

4、安装apache

[root@localhost ~]# mkdir /usr/local/apache
[root@localhost ~]# tar -xvf httpd-2.4.27.tar.bz2 -C /usr/local/src/
[root@localhost ~]# cd /usr/local/src/httpd-2.4.27/
[root@localhost httpd-2.4.27]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --enable-deflate --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@localhost httpd-2.4.27]# make -j 2 && make install

5、启动脚本

[root@localhost ~]# vim /usr/lib/systemd/system/httpd.service
[Unit]
Description=The Apache HTTP Server
After=network.target remote-fs.target nss-lookup.target
Documentation=man:httpd(8)
Documentation=man:apachectl(8)

[Service]
Type=forking
EnvironmentFile=/etc/httpd/httpd.conf
ExecStart=/usr/local/apache/bin/apachectl
ExecRestart=/usr/local/apache/bin/apachectl restart
ExecStop=/usr/local/apache/bin/apachectl stop
KillSignal=SIGCONT
PrivateTmp=true

[Install]
WantedBy=multi-user.target

6、启动服务

[root@localhost ~]# systemctl start httpd
[root@localhost ~]# systemctl enable httpd

7、测试

[root@localhost ~]# curl -I 172.20.100.11
HTTP/1.1 200 OK
Date: Fri, 18 May 2018 16:34:45 GMT
Server: Apache/2.4.27 (Unix)
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html

 

 


温馨提示:如无特殊说明,本站文章均为作者原创,转载时请注明出处及相应链接!

发表评论