Chinaunix首页 | 论坛 | 博客
  • 博客访问: 6337551
  • 博文数量: 162
  • 博客积分: 3600
  • 博客等级: 中校
  • 技术积分: 10366
  • 用 户 组: 普通用户
  • 注册时间: 2011-01-19 11:23
个人简介

专注系统运维、网络架构,研究技术解决方案,记录我的思想轨迹、工作学习、生活和关注的领域

文章分类
文章存档

2014年(2)

2013年(16)

2012年(27)

2011年(117)

分类: 系统运维

2011-03-24 14:00:17

Apache安装学习总结
 
说明:
本学习记录是在Redhat Linux5.4和apache2.2.9环境下进行测试记录的。
//源文件
httpd-2.2.9.tar.gz
//upload apache源文件
存放路径:/usr/local/src/下
//解压
# cd /usr/local/src
# tar zxvf httpd-2.2.9.tar.gz
//配置、编译、安装

配置方法知识:
最简要的安装概述:
下载  $ wget
( )
解压  $ gzip -d httpd-NN.tar.gz
    $ tar xvf httpd-NN.tar
    $ cd httpd-NN
配置  $ ./configure --prefix=PREFIX
编译  $ make
安装  $ make install
配置  $ vi PREFIX/conf/httpd.conf
测试  $ PREFIX/bin/apachectl -k start
其中NN必须用当前的副版本号替代;PREFIX是服务器被安装到文件系统中的路径名,如果没有指定PREFIX,默认会装到/usr/local/apache2。

要想用所有的默认值配置源代码树只要简单的执行 ./configure 命令就可以了,同时configure还可以接受命令行参数以改变默认值。
最重要的选项是Apache安装目录的前缀:--prefix ,因为Apache需要知道这个目录才能正常运作。
可以通过在配置选项中指定要启用或禁用哪些模块来定制Apache的特性。Base组的模块默认包含在Apache中。其他组的模块可以通过 --enable-module 指令启用。其中module是模块名去掉"mod_"并将下划线转换成连字符后的字符串。你也可以使用 --enable-module=shared 指令将模块编译为可在运行时加载和卸载的动态共享对象(DSO)。同样的,你也可以使用 --disable-module 指令禁用Base组的模块。注意,使用这些指令的时候configure不会对你拼写错误的模块发出警告说找不到某某模块,而只是简单的忽略这个选项。

另外,有时候还必须提供给configure脚本关于编译器、库、头文件位置的更多信息。这些可以通过环境变量或者命令行选项传递给configure脚本。
 
我对安装的理解总结:
1)Base组的模块默认包含在Apache之中,如要禁用Base组模块,可用--disable-module指令。
2)其它非Base组模块可以通过--enable-module指令启用。
3)也可以使用—enable-module=shared将模块编译为可在运行时加裁和卸载的动态共享对象(DSO)。
4)configure不进行拼写检查,而是忽略些选项。
5)有时还要为特殊的需求,提供给configure脚本关于编译器、库、头文件的更多信息。

##########################################################
####  以下为8种不同configuer参数的安装实例以及说明  ####
##########################################################
1)仅指定目录的默认配置
./configure --prefix=/usr/local/apache2
Make
Make install
默认安装的module有:(共26个,这26个module就是BASE组模块)
[root@yy httpd-2.2.9]# /usr/local/apache/bin/httpd -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_include.c
  mod_filter.c
  mod_log_config.c
  mod_env.c
  mod_setenvif.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_cgi.c
  mod_negotiation.c
  mod_dir.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_so.c
[root@yy httpd-2.2.9]# ls /usr/local/apache2/modules
httpd.exp
[root@yy bin]# ./apachectl -V
Server version: Apache/2.2.9 (Unix)
Server built:   Sep 27 2008 01:01:51
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.3.0, APR-Util 1.3.0
Compiled using: APR 1.3.0, APR-Util 1.3.0
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/prefork"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_PIDLOG="logs/httpd.pid"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_LOCKFILE="logs/accept.lock"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
 
 
2)指定目录的默认配置,不安装以上默认的某个module(以不安装mod_status.c为例),另外还要加安mod_expires、headers、deflate模块。
[root@yy httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --disable-status --enable-expires --enable-headers --enable-deflate
(以下配置不可以执行:
[root@yy httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --disable-modules=status --enable-modules=expires --enable-modules=headers --enable-modules=deflate)
make
make install
[root@yy bin]# ./httpd -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_include.c
  mod_filter.c
  mod_deflate.c
  mod_log_config.c
  mod_env.c
  mod_expires.c
  mod_headers.c
  mod_setenvif.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_autoindex.c
  mod_asis.c
  mod_cgi.c
  mod_negotiation.c
  mod_dir.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_so.c

[root@yy httpd-2.2.9]# ls /usr/local/apache2/modules
httpd.exp
 
3)指定目录的默认配置,通过DSO安装expires、headers、deflate模块。
[root@yy httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --enable-expires=shared --enable-headers=shared --enable-deflate=shared
[root@yy apache2]# ./bin/httpd -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_include.c
  mod_filter.c
  mod_log_config.c
  mod_env.c
  mod_setenvif.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_cgi.c
  mod_negotiation.c
  mod_dir.c
  mod_actions.c
  mod_userdir.c
  mod_alias.c
  mod_so.c
[root@yy apache2]# ls /usr/local/apache2/modules
httpd.exp
mod_deflate.so
mod_expires.so
mod_headers.so
[root@yy apache2]# grep "Load" /usr/local/apache2/conf/httpd.conf
# have to place corresponding `LoadModule' lines at this location so the
# LoadModule foo_module modules/mod_foo.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so

4)指定目录的默认配置,并用—enable-modules=most安装模块。
[root@yy httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --enable-modules="most"
[root@yy httpd-2.2.9]# make
[root@yy httpd-2.2.9]# make install
[root@yy bin]# ./httpd -l
Compiled in modules:
  core.c
  mod_authn_file.c
  mod_authn_dbm.c
  mod_authn_anon.c
  mod_authn_dbd.c
  mod_authn_default.c
  mod_authz_host.c
  mod_authz_groupfile.c
  mod_authz_user.c
  mod_authz_dbm.c
  mod_authz_owner.c
  mod_authz_default.c
  mod_auth_basic.c
  mod_auth_digest.c
  mod_dbd.c
  mod_dumpio.c
  mod_ext_filter.c
  mod_include.c
  mod_filter.c
  mod_substitute.c
  mod_deflate.c
  mod_log_config.c
  mod_logio.c
  mod_env.c
  mod_expires.c
  mod_headers.c
  mod_ident.c
  mod_setenvif.c
  prefork.c
  http_core.c
  mod_mime.c
  mod_dav.c
  mod_status.c
  mod_autoindex.c
  mod_asis.c
  mod_info.c
  mod_cgi.c
  mod_dav_fs.c
  mod_vhost_alias.c
  mod_negotiation.c
  mod_dir.c
  mod_imagemap.c
  mod_actions.c
  mod_speling.c
  mod_userdir.c
  mod_alias.c
  mod_rewrite.c
  mod_so.c
[root@yy apache2]# ls /usr/local/apache2/modules
httpd.exp
[root@yy conf]# grep "LoadModule" httpd.conf
# have to place corresponding `LoadModule' lines at this location so the
# LoadModule foo_module modules/mod_foo.so
 
5)指定目录的默认配置,并用--enable-modules=all安装模块。
  略:本方法应与4)相同,1)、2)、4)5)都为静态的方法安装。
 
6)指定目录的默认配置,并用--enable-mods-shared=most安装模块。
[root@yy httpd-2.2.9]# ./configure --prefix=/usr/local/apache2 --enable-mods-shared=most
[root@yy httpd-2.2.9]# make
[root@yy httpd-2.2.9]# make install
[root@yy bin]# ll /usr/local/apache2/modules/
total 2292
-rw-r--r--  1 root root   8998 Sep 28 22:46 httpd.exp
-rwxr-xr-x  1 root root  24645 Sep 28 22:51 mod_actions.so
-rwxr-xr-x  1 root root  32884 Sep 28 22:51 mod_alias.so
-rwxr-xr-x  1 root root  22789 Sep 28 22:51 mod_asis.so
-rwxr-xr-x  1 root root  26076 Sep 28 22:51 mod_auth_basic.so
-rwxr-xr-x  1 root root  61070 Sep 28 22:51 mod_auth_digest.so
-rwxr-xr-x  1 root root  23170 Sep 28 22:50 mod_authn_anon.so
-rwxr-xr-x  1 root root  26478 Sep 28 22:50 mod_authn_dbd.so
-rwxr-xr-x  1 root root  24001 Sep 28 22:50 mod_authn_dbm.so
-rwxr-xr-x  1 root root  21213 Sep 28 22:50 mod_authn_default.so
-rwxr-xr-x  1 root root  23760 Sep 28 22:50 mod_authn_file.so
-rwxr-xr-x  1 root root  26441 Sep 28 22:51 mod_authz_dbm.so
-rwxr-xr-x  1 root root  21161 Sep 28 22:51 mod_authz_default.so
-rwxr-xr-x  1 root root  26916 Sep 28 22:50 mod_authz_groupfile.so
-rwxr-xr-x  1 root root  26206 Sep 28 22:50 mod_authz_host.so
-rwxr-xr-x  1 root root  23938 Sep 28 22:51 mod_authz_owner.so
-rwxr-xr-x  1 root root  22122 Sep 28 22:50 mod_authz_user.so
-rwxr-xr-x  1 root root  71215 Sep 28 22:51 mod_autoindex.so
-rwxr-xr-x  1 root root  57287 Sep 28 22:51 mod_cgi.so
-rwxr-xr-x  1 root root 144418 Sep 28 22:51 mod_dav_fs.so
-rwxr-xr-x  1 root root 273184 Sep 28 22:51 mod_dav.so
-rwxr-xr-x  1 root root  42317 Sep 28 22:51 mod_dbd.so
-rwxr-xr-x  1 root root  48280 Sep 28 22:51 mod_deflate.so
-rwxr-xr-x  1 root root  24606 Sep 28 22:51 mod_dir.so
-rwxr-xr-x  1 root root  26682 Sep 28 22:51 mod_dumpio.so
-rwxr-xr-x  1 root root  23639 Sep 28 22:51 mod_env.so
-rwxr-xr-x  1 root root  30009 Sep 28 22:51 mod_expires.so
-rwxr-xr-x  1 root root  46463 Sep 28 22:51 mod_ext_filter.so
-rwxr-xr-x  1 root root  38425 Sep 28 22:51 mod_filter.so
-rwxr-xr-x  1 root root  41942 Sep 28 22:51 mod_headers.so
-rwxr-xr-x  1 root root  27530 Sep 28 22:51 mod_ident.so
-rwxr-xr-x  1 root root  37834 Sep 28 22:51 mod_imagemap.so
-rwxr-xr-x  1 root root  93876 Sep 28 22:51 mod_include.so
-rwxr-xr-x  1 root root  41403 Sep 28 22:51 mod_info.so
-rwxr-xr-x  1 root root  60413 Sep 28 22:51 mod_log_config.so
-rwxr-xr-x  1 root root  25039 Sep 28 22:51 mod_logio.so
-rwxr-xr-x  1 root root  39079 Sep 28 22:51 mod_mime.so
-rwxr-xr-x  1 root root  78354 Sep 28 22:51 mod_negotiation.so
-rwxr-xr-x  1 root root 121464 Sep 28 22:51 mod_rewrite.so
-rwxr-xr-x  1 root root  31179 Sep 28 22:51 mod_setenvif.so
-rwxr-xr-x  1 root root  30849 Sep 28 22:51 mod_speling.so
-rwxr-xr-x  1 root root  44365 Sep 28 22:51 mod_status.so
-rwxr-xr-x  1 root root  31780 Sep 28 22:51 mod_substitute.so
-rwxr-xr-x  1 root root  25972 Sep 28 22:51 mod_userdir.so
-rwxr-xr-x  1 root root  29320 Sep 28 22:51 mod_vhost_alias.so

[root@yy bin]# ./httpd -l
Compiled in modules:
  core.c
  prefork.c
  http_core.c
  mod_so.c
[root@yy conf]# grep "LoadModule" httpd.conf
# have to place corresponding `LoadModule' lines at this location so the
# LoadModule foo_module modules/mod_foo.so
LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_anon_module modules/mod_authn_anon.so
LoadModule authn_dbd_module modules/mod_authn_dbd.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule auth_digest_module modules/mod_auth_digest.so
LoadModule dbd_module modules/mod_dbd.so
LoadModule dumpio_module modules/mod_dumpio.so
LoadModule ext_filter_module modules/mod_ext_filter.so
LoadModule include_module modules/mod_include.so
LoadModule filter_module modules/mod_filter.so
LoadModule substitute_module modules/mod_substitute.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule logio_module modules/mod_logio.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule ident_module modules/mod_ident.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule mime_module modules/mod_mime.so
LoadModule dav_module modules/mod_dav.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule asis_module modules/mod_asis.so
LoadModule info_module modules/mod_info.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule dav_fs_module modules/mod_dav_fs.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule dir_module modules/mod_dir.so
LoadModule imagemap_module modules/mod_imagemap.so
LoadModule actions_module modules/mod_actions.so
LoadModule speling_module modules/mod_speling.so
LoadModule userdir_module modules/mod_userdir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so
 
7)指定目录的默认配置,并用--enable-mods-shared=all安装模块。
  略:本方法应与6)相同,为动态的方法安装。
 
8)指定目录的默认配置,以上所有配置方法安装后Server MPM都为Prefork,可以用--with-mpm定制运行方式。
[root@yy httpd-2.2.9]#  ./configure --prefix=/usr/local/apache2 --with-mpm=worker
[root@yy httpd-2.2.9]# make
[root@yy httpd-2.2.9]# make install
[root@yy apache2]# cd bin/
[root@yy bin]# ./httpd -V
Server version: Apache/2.2.9 (Unix)
Server built:   Sep 28 2008 23:28:26
Server's Module Magic Number: 20051115:15
Server loaded:  APR 1.3.0, APR-Util 1.3.0
Compiled using: APR 1.3.0, APR-Util 1.3.0
Architecture:   32-bit
Server MPM:     Worker
  threaded:     yes (fixed thread count)
    forked:     yes (variable process count)
Server compiled with....
 -D APACHE_MPM_DIR="server/mpm/worker"
 -D APR_HAS_SENDFILE
 -D APR_HAS_MMAP
 -D APR_HAVE_IPV6 (IPv4-mapped addresses enabled)
 -D APR_USE_SYSVSEM_SERIALIZE
 -D APR_USE_PTHREAD_SERIALIZE
 -D SINGLE_LISTEN_UNSERIALIZED_ACCEPT
 -D APR_HAS_OTHER_CHILD
 -D AP_HAVE_RELIABLE_PIPED_LOGS
 -D DYNAMIC_MODULE_LIMIT=128
 -D HTTPD_ROOT="/usr/local/apache2"
 -D SUEXEC_BIN="/usr/local/apache2/bin/suexec"
 -D DEFAULT_SCOREBOARD="logs/apache_runtime_status"
 -D DEFAULT_ERRORLOG="logs/error_log"
 -D AP_TYPES_CONFIG_FILE="conf/mime.types"
 -D SERVER_CONFIG_FILE="conf/httpd.conf"
阅读(4198) | 评论(0) | 转发(3) |
给主人留下些什么吧!~~