一、下载
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
来获得服务器中相应的文件。