Apache 安装先去官网上下载安装包/usr/local/src/,版本不要太新,也不要太旧。
http://mirrors.cnnic.cn/apache/httpd/
下载之后解压
[root@OBird src]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.2.31.tar.bz2
[root@OBird src]# tar jxvf httpd-2.2.31.tar.bz2
进入到解压目录
[root@OBird src]# cd httpd-2.2.31
#######################################################################################
如果不知道怎么安装可以查看帮助
[root@OBird src]# vim INSTALL
For complete installation documentation, see [ht]docs/manual/install.html or
http://httpd.apache.org/docs/2.2/install.html
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start
#######################################################################################
因为我是看的视频有现成的步骤(直接拷贝编译文档)
[root@OBird httpd-2.2.31]# ./configure \
> --prefix=/usr/local/apache2 \ #指定安装的目录
> --with-included-apr \ #apr 是httpd 依赖的一个包(底层的包,支持Apache跨平台运行)
> --enable-so \
> --enable-deflate=shared \ #deflate 支持压缩的 shared 表示动态支持,下同
> --enable-expires=shared \ #expires支持静态文件过期的一些操作
> --enable-rewrite=shared \ #rewrite 域名重定向,伪静态。
> --with-pcre #pcre 是否支持正则表达式。
这个过程中如果有出现错误,请根据报错提示,解决问题
配置完成后
[root@OBird httpd-2.2.31]# echo $?
0
输出“0”表示没有问题。接着下一步 make,但是我在安装过程中出现了一个小问题
checking for zlib location... not found
checking whether to enable mod_deflate... configure: error: mod_deflate has been requested but can not be built due to prerequisite failures
[root@OBird httpd-2.2.31]# echo $?
1
上网寻找解决办法,有网友遇到类似问题
http://blog.csdn.net/xinhaozheng/article/details/4221525
似乎是没有安装zlib引起的,而似乎mod_deflate模块又是有依赖于zlib
[root@OBird httpd-2.2.31]# yum install zlib-devel
安装后,再次编译
[root@OBird httpd-2.2.31]# echo $?
0
问题解决。下一步make
[root@OBird httpd-2.2.31]# make
make 这个过程在约2分钟,完成以后
[root@OBird httpd-2.2.31]# echo $? #检查有没有问题
0
接下来:
[root@OBird httpd-2.2.31]# make install
每一步操作完成后建议
[root@OBird httpd-2.2.31]# echo $? #检查有没有问题
0
至此Apache 安装完成
###########################################################################################
启动Apache
[root@OBird httpd-2.2.31]# /usr/local/apache2/bin/apachectl start
[root@OBird httpd-2.2.31]# ls /usr/local/apache2/modules/
httpd.exp mod_deflate.so mod_expires.so mod_rewrite.so
mod_deflate.so mod_expires.so mod_rewrite.so 这三个模块
这三个模块,都是在编译选项中加了这三个
[root@OBird httpd-2.2.31]# ls -l /usr/local/apache2/bin/httpd
-rwxr-xr-x 1 root root 2262241 Sep 20 09:41 /usr/local/apache2/bin/httpd
如果在编译里不加 shared(动态) 这个三个块就会和httpd 和在一起,会使得httpd 这个文件变大。
动态shared 会把这些文件单独拿出来生成块文件和httpd 分开。
静态staic 会把文件聚合在一起,用不用都会加载。耗费资源。
[size=75%]l ./configure --prefix=/ usr /local/apache2--with-included-apr --enable-deflate=shared --enable-expires=shared --enable-rewrite=shared --with- pcre
################################################
列出所有的模块
[root@OBird httpd-2.2.31]# /usr/local/apache2/bin/apachectl -M 查看动态加载的模块
[root@OBird httpd-2.2.31]# /usr/local/apache2/bin/apachectl -l 查看静态加载的模块
/usr/local/apache2/bin/apachectl restrat :(把进程先杀掉再重新开启新的进程)
/usr/local/apache2/bin/apachectl stop :(关闭进程)
/usr/local/apache2/bin/apachectl graceful :(旧进程还在,只是重新加载了配置文件)
[root@OBird httpd-2.2.31]# /usr/local/apache2/bin/apachectl -t 查看配置文件有没有语法错误
httpd: apr_sockaddr_info_get() failed for OBird
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
Syntax OK
[root@OBird httpd-2.2.31]# ls /usr/local/apache2/conf/httpd.conf 配置文件路径
/usr/local/apache2/conf/httpd.conf
[root@OBird httpd-2.2.31]# ./configure --help |less 查看帮助
指定工作模式
--with-mpm=MPM Choose the process model for Apache to use.
MPM={beos|event|worker|prefork|mpmt_os2|winnt}
worker|prefork 这两种是我们常用的工作模式
2.4 的版本不指定的,黙认的是 event 模式
2.2 的版本不指定的,黙认的是 prefork 模式
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com