下载安装包: cd /usr/local/src wget http://mirrors.sohu.com/apache/httpd-2.2.31.tar.bz2 解压: tar jxf httpd-2.2.31.tar.bz2 编译安装 cd /usr/local/src/httpd-2.2.31 yum -y install gcc yum -y install zlib-devel openssl-devel apr依赖包 shared动静态的包 pcre正则相关的库 ./configure --prefix=/usr/local/apache2 --with-included-apr --enable-so --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with-pcre make make install 启动Apache:/usr/local/apache2/bin/apachectl start ps aux |grep httpd netstat -lnp vi /usr/local/apache2/conf/httpd.conf(若报错就需要编辑该文件)搜到 ServerName,添加以下信息: ServerName localhost:80 保存提出 ps aux |grep httpd netstat -lnp /usr/local/apache2/bin/apachectl -M (列出所有模块) ls /usr/local/apache2/modules/ (.so结尾的文件是模块文件) ls /usr/local/apache2/bin/httpd du -sh !$ /usr/local/apache2/bin/apachectl -l (列出静态模块) /usr/local/apache2/bin/apachectl -t (查看配置文件是否有语法错误) ls /usr/local/apache2/conf/httpd.conf /usr/local/apache2/bin/apachectl restart(杀掉进程,才重新开启) /usr/local/apache2/bin/apachectl stop !ps /usr/local/apache2/bin/apachectl restart /usr/local/apache2/bin/apachectl graceful (原来进程还在,重新加载配置文件) 工作模式: /usr/local/apache2/bin/apachectl -l (prefork) ./configure --help |less (可以用/--with-mpm选项指定模式,共三种event、worker 、prefork默认是prefork) 2.4版本是event,2.2版本默认是prefork
|