LAMP搭建——apache安装

官网下载2.2版本。实际上我们所说的Apache真正的名字是httpd。
下载解压就不说了。
配置编译参数:
#cd http-2.2.24
#vim INSTALL
#./configure \
--prefix=/usr/local/apache2 \
--with-included-apr \
--enable-so \
--enable-deflate=shared \
--enable-expires=shared \
--enable-rewrite=shared \
--with-pcre
--prefix 指定安装到哪里,
--with-included-apr \
底层的一个模块,是数据可以跨平台使用。
--enable-so 表示启用DSO
DSO 是 Dynamic Shared Objects (动态共享目标)的缩写,它提供了一种在运行时将特殊格式的代码在程序运行需要时,将需要的部分从外存调
入内存执行的方法。 Apache 支持动态共享模块,也支持静态模块,静态的话,会把需要的目标直接编译进 apache 的可执行文件中,相比较动态,
虽然省去了加载共享模块的步骤,但是也加大了二进制执行文件的空间,变得臃肿。
--enable-deflate=shared 表示共享的方式编译deflate,
既然可以动态共享当然也可以静态方式编译deflate模块。什么是动态和静态?apache编译安装完成后会生成一个核心的二进制可执行文件叫做
httpd,这个文件作为核心文件,提供服务时就是它在处理用户的请求,但是有一些功能,比如提到的expires就是配置静态文件、图片过期时间的,
也就是说图片可以再用户浏览器的临时缓存目录中缓存多久。这些功能是作为httpd的一个扩展模块来工作的,那么这种扩展模块有两种存在的方式,
一种是直接在编译的时候和httpd文件拧到一起,组成一个体积大的文件,这种叫做静态。另一种,扩展模块作为独立的文件存在,只有在使用这个模
块时再去调用它,这种叫做动态共享。动态的好处是,核心文件httpd比较小,模块随时用随时加载,耗费内存小队较少。静态的优势,在服务启动
时,会把所有模块加载,用到时很快执行,效率较高。
--enable-expires=shared 共享的方式编译 expires
--enable-rewrite=shared 共享的方式编译 rewrite
#yum install -y pcre pcre-devel apr apr-devel 【make之前安装这些包,避免出错】
#make
#echo $?
#make install
#echo $?
启动验证
# /usr/local/apache2/bin/apachectl start 【启动程序】
# ps aux |grep httpd 【验证是否启动】
# netstat -nlp 【检查监听端口是不是80】
常用选项:
-M 列出所有模块,主要是查看动态模块# /usr/local/apache2/bin/apachectl -M
core_module (static)
authn_file_module (static)
authn_default_module (static)
authz_host_module (static)
authz_groupfile_module (static)
authz_user_module (static)
authz_default_module (static)
auth_basic_module (static)
include_module (static)
filter_module (static)
log_config_module (static)
env_module (static)
setenvif_module (static)
version_module (static)
mpm_prefork_module (static)
http_module (static)
mime_module (static)
status_module (static)
autoindex_module (static)
asis_module (static)
cgi_module (static)
negotiation_module (static)
dir_module (static)
actions_module (static)
userdir_module (static)
alias_module (static)
so_module (static)
deflate_module (shared)
expires_module (shared)
rewrite_module (shared)
# ls /usr/local/apache2/modules/ 【动态模块存放路径,下图绿色的为动态共享模块】
# ls /usr/local/apache2/bin/httpd 【静态模块存放文件】
静态文件模块是将上述静态模块全部编译层进这个httpd文件内。
-L 【只列出静态模块】
# /usr/local/apache2/bin/apachectl -l
-t 【查看配置文件有没有错误】
# /usr/local/apache2/bin/apachectl -t
Syntax OK
配置文件路径 /usr/local/apache2/conf/httpd.conf
NOTE:
1、重新加载httpd有两种选项
# /usr/local/apache2/bin/apachectl restart
# /usr/local/apache2/bin/apachectl graceful
resatart这个选项要先把httpd进程杀死,再重新加载。
graceful,原来的进程还在,只是把配置文件重新加载2、工作模式
#cd /usr/local/src/httpd-2.2.24
#./configure --help
--with-mpm=MPM
Choose the process model for Apache to use.
MPM={beos|event|worker|prefork|mpmt_os2|winnt}
--with-mpm=MPM这个选项可以指定工作模式,常用的是 worker , prefork, event。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值