Apache编译安装(小白篇)
Apache编译安装[*]系统环境
[*]下载软件包
[*]编译安装
[*]启动测试
系统环境
# cat /etc/redhat-release
CentOS Linux release 7.5.1804 (Core)
# uname -r
3.10.0-862.el7.x86_64
# hostname
Zabbix_Client_56.8
# ip a|grep 192.168.
inet 192.168.56.8/24 brd 192.168.56.255 scope global noprefixroute dynamic eth0
下载软件包
apr和apr-util中包含了一些常用的开发组件,也是apache的依赖包
wget wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz
wget wget http://archive.apache.org/dist/apr/apr-util-1.5.2.tar.gz
wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.35.tar.gz
yum install pcre pcre-devel gcc-c++ openssl openssl-devel expat-devel -y
编译安装
# cd /usr/local/src/
# tar xf apr-1.5.2.tar.gz
# cd apr-1.5.2
# ./configure --prefix=/usr/local/apr
# make && make install
# cd ../
# tar xf apr-util-1.5.2.tar.gz
# cd apr-util-1.5.2
# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
# make && make install
# cd ..
# tar xf httpd-2.4.35.tar.gz
# cd httpd-2.4.35
# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-user=httpd --with-group=httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-mpm=prefork --enable-module=most --enable-mpms-shared=all
# make && make install
启动测试
# cd /usr/local/apache/conf/
# sed -i 's@#ServerName www.example.com:80@ServerName 192.168.56.8:80@g' httpd.conf
# cp -rf /usr/local/apache/bin/apachectl/etc/init.d/httpd
# vim /etc/init.d/httpd
#chkconfig:35 95 96 #在第二行加入以下内容以支持开机自启
# cd /etc/init.d/
# chkconfig --add httpd
# chkconfig httpd on
# /etc/init.d/httpd restart
# curl http://127.0.0.1 -I
HTTP/1.1 200 OK
Date: Tue, 16 Oct 2018 02:48:02 GMT
Server: Apache/2.4.35 (Unix)
Last-Modified: Mon, 11 Jun 2007 18:53:14 GMT
ETag: "2d-432a5e4a73a80"
Accept-Ranges: bytes
Content-Length: 45
Content-Type: text/html
页:
[1]