参考文档:http://lamp.linux.gov.cn/Apache/ApacheMenu/
Ø 下载Apache2.2.4 的压缩包,文件名为:Apache21.tar.gz ;
Ø 在 /usr/local 目录下解压此压缩文件:
[root@wxr local]# tar xzvf Apache21.tar.gz
之后生成一个名为“httpd-2.2.4 ”的文件夹;
Ø apr 和apr-util 包含在Apache httpd 的发行源代码中,并且在绝大多数情况下使用都不会出现问题。当然,如果apr 或apr-util 的1.0 或1.1 版本已经安装在你的系统中了,则必须将你的apr/apr-util 升级到1.2 版本,或者将httpd 单独分开编译。要使用发行源代码中自带的apr/apr-util 源代码进行安装,你必须手动完成:
# 编译和安装 apr
cd /usr/local/httpd-2.2.4/srclib/apr
./configure --prefix=/usr/local/apr-httpd/
make
make install
# 编译和安装 apr-util
cd /usr/local/httpd-2.2.4/srclib/apr-util
./configure --prefix=/usr/local/apr-util-httpd/ --with-apr=/usr/local/apr-httpd/
make
make install
# 配置和安装 httpd
cd /usr/local/httpd-2.2.4
./configure --with-apr=/usr/local/apr-httpd/ --with-apr-util=/usr/local/apr-util-httpd/
make
make install
之后会在local 目录下生成一个”apache2” 的文件目录,即安装的apache 目录。
Ø 启动apache :
cd /usr/local/apache2/bin
[root@wxr bin]# ./apachectl start
Ø 查看测试页:
在其他机器上如果能ping 通安装了apache 的服务器地址,就应该能访问apache 的测试页了,如在ie 中直接访问:http://192.168.2.254
另外,apache 安装后的默认端口号是80 ,如果此端口号被占用了也不会访问到测试页,此时需要手动改一下端口号:
cd /usr/local/apache2/conf
[root@wxr conf]# vi httpd.conf
#
# This is the main Apache HTTP server configuration file. It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do. They're here only as hints or reminders. If you are unsure
# consult the online docs. You have been warned.
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path. If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "/usr/local/apache2" will be interpreted by the
# server as "/usr/local/apache2/logs/foo.log".
#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path. If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk. If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "/usr/local/apache2"
#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 8023
此处端口号被改为了“8023 ”,于是在ie 中则要访问:http://192.168.2.254:8023/
注1 :测试页显示的内容可以修改:
[root@wxr htdocs]# pwd
/usr/local/apache2/htdocs
[root@wxr htdocs]# vi index.html
<html><body><h1>HaHa~~ It works!</h1></body></html>
经过以上修改,测试页显示如下:
注2 :如果访问不到测试页,很有可能是apache 服务器中打开了防火墙,此时需要关闭防火墙:
[root@wxr apache2]# iptables -F
Ø 设置自启动:
在/etc/rc.d/rc.local 文件中加入一行
/usr/local/apache2/bin/apachectl start
这样每次重新启动系统以后,apache 也会随系统一起启动.
Ø The End…