一、下載
1.apr和apr-util:
http://apr.apache.org/download.cgi
Unix Source: apr-1.5.2.tar.gz [PGP] [MD5]
Unix Source: apr-util-1.5.4.tar.gz [PGP] [MD5]
2.PCRE
即:Perl Compatible Regular Expressions
http://pcre.org/
pcre-8.38.tar.gz
3.http server
http://httpd.apache.org/download.cgi#apache24
Source: httpd-2.4.18.tar.gz [ PGP ] [ MD5 ] [ SHA1 ]
二、解壓
解壓到/usr/apache目錄下:
root@master:mkdir /usr/apache
root@master:cd /usr/apache
root@master:/usr/apache# tar -zxvf /home/hadoop/Downloads/apr-1.5.2.tar.gz
root@master:/usr/apache# tar -zxvf /home/hadoop/Downloads/apr-util-1.5.4.tar.gz
root@master:/usr/apache# tar -zxvf /home/hadoop/Downloads/pcre-8.38.tar.gz
root@master:/usr/apache# tar -zxvf /home/hadoop/Downloads/httpd-2.4.18.tar.gz
三、安裝
注意:每一步的依賴關係不能省略,否則報錯。
1.創建目錄
root@master:mkdir /usr/apache/installed/apr
root@master:mkdir /usr/apache/installed/apr-util
root@master:mkdir /usr/apache/installed/pcre
root@master:mkdir /usr/apache/installed/apache
2.安裝apr
root@master:~# cd /usr/apache/apr-1.5.2
root@master:/usr/apache/apr-1.5.2# ./configure --prefix=/usr/apache/installed/apr
root@master:/usr/apache/apr-1.5.2# make
root@master:/usr/apache/apr-1.5.2# make install
3.安裝apr-util
root@master:/usr/apache/apr-1.5.2# cd /usr/apache/apr-util-1.5.4
root@master:/usr/apache/apr-util-1.5.4# ./configure --prefix=/usr/apache/installed/apr-util --with-apr=/usr/apache/installed/apr
root@master:/usr/apache/apr-util-1.5.4# make
root@master:/usr/apache/apr-util-1.5.4# make install
4.安裝pcre
root@master:/usr/apache/apr-util-1.5.4# cd /usr/apache/pcre-8.38
root@master:/usr/apache/pcre-8.38# ./configure --prefix=/usr/apache/installed/pcre --with-apr=/usr/apache/installed/apr
root@master:/usr/apache/pcre-8.38# make
root@master:/usr/apache/pcre-8.38# make install
5.安裝apache server
root@master:/usr/apache/pcre-8.38# cd /usr/apache/httpd-2.4.18
root@master:/usr/apache/httpd-2.4.18# ./configure --prefix=/usr/apache/installed/apache --with-apr=/usr/apache/installed/apr --with-apr-util=/usr/apache/installed/apr-util --with-pcre=/usr/apache/installed/pcre
root@master:/usr/apache/httpd-2.4.18# make
root@master:/usr/apache/httpd-2.4.18# make install
四、修改配置文件
root@master: cd /usr/apache/installed/apache
root@master:/usr/apache/installed/apache# gedit conf/httpd.conf
寫入:
ServerName localhost:80
至此,Apache服務器安裝與配置已經完成。
啓動:
root@master:/usr/apache/installed/apache# ./bin/apachectl start
打開瀏覽器,輸入:
127.0.0.1
顯示“It works!”
/usr/apache/isntalled/apache/htdocs目錄爲服務器文件的存放目錄,其中存放的文件可以通過在瀏覽器地址欄輸入
master/tomorrow.mp3
來獲得服務器中相應的文件。