由于公司的项目是两三年前就开始跑的,创始人自己编译所有软件,这传统一直流传至今(我建议直接用apt-get install apache2安装,因为目录非常整齐好看)。此文章仅做笔记使用。
安装apr和apr-util。
安装步骤及configure参数可以参考:http://www.oralife.cn/html/2007/88_apr-aprutil-install.html
环境:
ubuntu 9.04 hp 500
httpd v2.2.11
1、需要从httpd下载最新的源码包(httpd-2.2.11.tar.gz)。 2、tar -zxvf httpd-2.2.11.tar.gz (解压) 3、 ./configure --prefix=/usr/local/apache --enable-so --enable-proxy=share --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 4、make && sudo make install 5、cp httpd.conf httpd.conf.default (备份httpd.conf及去掉下面配置文件的注释,目的是让httpd支持虚拟主机) # Virtual hosts Include conf/extra/httpd-vhosts.conf (去掉这句前的#) 6、vi /usr/local/apache/conf/extra/httpd-vhosts.conf (添加虚拟主机) <VirtualHost *:80> ServerAdmin admin@easyea.com ProxyPass / ajp://localhost:8009/ ProxyPassReverse / ajp://localhost:8009/ ProxyPass /bingo ajp://localhost:8009/ ProxyPassReverse /bingo ajp://localhost:8009/ # DocumentRoot "/usr/local/apache/docs/dummy-host2.example.com" ServerName localhost ServerAlias bingo.iefgames.com ErrorLog "logs/easyea.com-error_log" CustomLog "logs/easyea.com-access_log" common </VirtualHost> 7、sudo /usr/local/apache/bin/apachectl -t (测试所有config配置文件的语法) nvalid command 'AutoUserFile', perhaps misspelled or defined by a module not included in the server configuration duanyong@duanyong-laptop:~/download$ sudo /usr/local/apache/bin/apachectl -t Warning: DocumentRoot [/usr/local/apache/docs/dummy-host.example.com] does not exist Warning: DocumentRoot [/usr/local/apache/docs/dummy-host2.example.com] does not exist [Wed Jun 17 21:44:43 2009] [warn] worker ajp://localhost:8009/ already used by another worker httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName Syntax OK 8、sudo /usr/local/apache/bin/apachectl -k start (启动) 9、netstat -lnpt (查看端口) duanyong@duanyong-laptop:/usr/local/apache/conf/extra$ netstat -lnpt (Not all processes could be identified, non-owned process info will not be shown, you would have to be root to see it all.) Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:48932 0.0.0.0:* LISTEN 4353/qq tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN - tcp6 0 0 :::81 :::* LISTEN
注:
-
参考:
http://www.kreny.com/docs/apache2.0/install.html
-
用已命名的
config.layout
布局文件来指定安装目录。 -
-
- apache 安装出来的目录结构感觉不合理,如果像ubuntu 通过apt-get install方式安装后的目录结构,那么感觉才优雅。
- 可以通过指定 --enable-layout=APACHE这样的参数形式选择httpd的目录结构。所指定的目录结构可以参考httpd目录下的config.layout文件,选择适合您自己的目录结构。
-
- 我一直想找到apach2这样的目录结构,如下:
-
apache2.conf envvars mods-available ports.conf sites-enabled conf.d httpd.conf mods-enabled sites-available
但不知道怎么配置出来。
--enable-layout=LAYOUT