Linux下apache2的安装和配置
1、下载安装包(如httpd-2.2.0.tar.gz)
并拷贝到服务器上
2、[test@wasu apache2]$ tar -xzvf httpd-2.2.0.tar.gz //解压安装包
3、[test@wasu apache2]$ cd httpd-2.2.0 //进入解压出的文件目录中
4、[test@wasu httpd-2.2.0]$ ./configure --prefix=/home/test/apache2 --enable-so --enable-rewrite --enable-expire //指定安装目录和配置项
5、[test@wasu httpd-2.2.0]$ make //编译
6、[test@wasu httpd-2.2.0]$ make install //安装
7、[test@wasu conf]$ pwd
/home/test/apache2/conf
[test@wasu conf]$ vi httpd.conf
//进入安装目录的conf下编辑httpd.conf文件进行apache服务器的IP和Prot的设置,相关内容如下:
#
ServerRoot "/home/test/apache2" //apache服务器根目录
#
#
#Listen 12.34.56.78:80
Listen 1080 //监听端口
#
# Dynamic Shared Object (DSO) Support
#
ServerName 218.108.0.82:1080 //服务器IP和Port
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "/home/test/apache2/htdocs" //服务器文件根目录
#
8、[test@wasu apache2]$ cd bin
[test@wasu bin]$ ./apachectl start //启动服务
9、[test@wasu bin]$ ps -ef|grep httpd
test 5199 1 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5200 5199 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5201 5199 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5202 5199 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5203 5199 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5204 5199 0 15:48 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 5207 5199 0 15:49 ? 00:00:00 /home/test/apache2/bin/httpd -k start
test 15258 5154 0 16:15 pts/1 00:00:00 grep httpd
[test@wasu bin]$ netstat -lnp|grep 1080
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 :::1080 :::* LISTEN 5199/httpd