Total Pageviews

Monday, 8 August 2016

编译httpd-2.2.x

wget http://www.apache.org/dist/httpd/httpd-2.2.31.tar.gz
tar zxvf httpd-2.2.31.tar.gz
cd httpd-2.2.31
./configure --prefix=/usr/local/apache2 --enable-mods=all --enable-so --enable-rewrite
make && make install
(说明:
so模块用来提供 DSO 支持的 apache 核心模块.
--enable-mods-shared=all选项:
告诉编译器将所有标准模块都动态编译为DSO模块。
--enable-mods-shared=all意思是动态加载所有模块,如果去掉-shared,是静态加载所有模块.
--enable-so选项:让 Apache 可以支持DSO模式,注意,这里采用的是 Apache2.0 的语法。)

root@AR:~/httpd-2.2.31# cd /usr/local/apache2
root@AR:/usr/local/apache2# ls
bin    cgi-bin error icons lib   man     modules
build  conf htdocs include  logs  manual
root@AR:/usr/local/apache2# ls bin
ab       apu-1-config  dbmmanage htcacheclean  htpasswd   logresolve
apachectl     apxs     envvars htdbm       httpd   rotatelogs
apr-1-config  checkgid     envvars-std  htdigest      httxt2dbm
root@AR:/usr/local/apache2# ls conf
extra  httpd.conf  magic  mime.types  original
root@AR:/usr/local/apache2# ls htdocs
index.html
root@AR:/usr/local/apache2# cd htdocs
root@AR:/usr/local/apache2/htdocs# ls
index.html
root@AR:/usr/local/apache2/htdocs# 
(可见/usr/local/apache2/htdocs/就是默认的apache2 webserver的根目录)
root@AR:/usr/local/apache2/htdocs# cd ../conf
root@AR:/usr/local/apache2/conf# ls
extra  httpd.conf  magic  mime.types  original

root@AR:/usr/local/apache2/conf# nano httpd.conf
(把Listen 80改为Listen 81
ServerRoot "/usr/local/apache2/"改为ServerRoot "/usr/local/apache2/htdocs/"
root@AR:/usr/local/apache2/conf# cd ../bin/
root@AR:/usr/local/apache2/bin# mkdir /usr/local/apache2/htdocs/logs
root@AR:/usr/local/apache2/bin# ./httpd

(不过,这样并未启动httpd!)