Apache編譯安裝(小白篇)

Apache編譯安裝

  • 系統環境
  • 下載軟件包
  • 編譯安裝
  • 啓動測試

Apache編譯安裝(小白篇)

系統環境

[root@Zabbix_Client_56 /]# cat /etc/redhat-release 
CentOS Linux release 7.5.1804 (Core) 
[root@Zabbix_Client_56 /]# uname -r
3.10.0-862.el7.x86_64
[root@Zabbix_Client_56 /]# hostname
Zabbix_Client_56.8
[root@Zabbix_Client_56 /]# 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

編譯安裝

[root@Zabbix_Client_56 /]# cd /usr/local/src/
[root@Zabbix_Client_56 src]# tar xf apr-1.5.2.tar.gz 
[root@Zabbix_Client_56 src]# cd apr-1.5.2
[root@Zabbix_Client_56 apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@Zabbix_Client_56 apr-1.5.2]# make && make install
[root@Zabbix_Client_56 apr-1.5.2]# cd ../
[root@Zabbix_Client_56 src]# tar xf apr-util-1.5.2.tar.gz 
[root@Zabbix_Client_56 src]# cd apr-util-1.5.2
[root@Zabbix_Client_56 apr-util-1.5.2]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@Zabbix_Client_56 apr-util-1.5.2]# make && make install
[root@Zabbix_Client_56 apr-util-1.5.2]# cd ..
[root@Zabbix_Client_56 src]# tar xf httpd-2.4.35.tar.gz 
[root@Zabbix_Client_56 src]# cd httpd-2.4.35
[root@Zabbix_Client_56 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
[root@Zabbix_Client_56 httpd-2.4.35]# make && make install

啓動測試

[root@Zabbix_Client_56 httpd-2.4.35]# cd /usr/local/apache/conf/
[root@Zabbix_Client_56 conf]# sed -i 's@#ServerName www.example.com:80@ServerName 192.168.56.8:80@g' httpd.conf 
[root@Zabbix_Client_56 conf]# cp -rf /usr/local/apache/bin/apachectl  /etc/init.d/httpd
[root@Zabbix_Client_56 conf]# vim /etc/init.d/httpd     
#chkconfig:35 95 96                                         #在第二行加入以下內容以支持開機自啓
[root@Zabbix_Client_56 conf]# cd /etc/init.d/
[root@Zabbix_Client_56 init.d]# chkconfig --add httpd
[root@Zabbix_Client_56 init.d]# chkconfig httpd on
[root@Zabbix_Client_56 init.d]# /etc/init.d/httpd restart
[root@Zabbix_Client_56 init.d]# 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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章