LAMP中的apache源码包安装

apache安装:

首先,解压httpd包,进入解压后的目录,最先查看INSTALL文件查看安装步骤

接着:

第一步:./configure  (配置编译参数)

./configure    \

> --prefix=/usr/local/apache2  \    //指定安装到哪里

> --with-included-apr  \         //它是httpd要依赖的包,它支持httpd跨平台去运作

> --enable-so  \               //表示启用DSO

> --enable-deflate=shared  \       //表示动态共享的方式编译deflate模块

> --enable-expires=shared  \       //表示动态共享的方式编译expires模块

> --enable-rewrite=shared \        //表示动态共享的方式编译rewrite模块

> --with-pcre

遇到的问题:

apache安装遇到的问题:

1.出现:configure: error: no acceptable C compiler found in $PATH

是因为你的机器里没有安装任何C语言编译器,可以安装gcc (yum install -y gcc)

2.出现:configure: error: mod_deflate has been requested but can not be built due to prerequisite failures

是因为你的机器没有安装zlib包,可以用yum安装:yum install -y zlib-devel

3.为了避免在make 的时候错误,所以最好是提前安装好一些文件

解决方法:yum install -y  pcre  pcre-devel  apr  apr-devel

第二步:make (编译)

第三步:make install (安装)

检验编译安装是否成功:echo $?

编译安装完成之后,进入你刚才指定的文件位置(--prefix=/usr/local/apache2)

进入到apache2目录之后,这个bin里面的apachectl,是它的启动文件,你可以这样启动:

/usr/local/apache2/bin/apachectl   start

第二种方法:把bin/apachectl复制到/etc/init.d/目录下并重命名:

cp   /usr/local/apache2/bin/apachectl    /etc/init.d/httpd

启动apache的时候,会有这样一种情况:service httpd  start

出现如下信息:“httpd:Could not reliably determine the server's fully qualified domain name,using localhost.localdomain for ServerName".

解决方法就是:找到你--prefix指定的文件路径,进入到apache中,进入conf中,编辑httpd.conf

命令如下:cd  /usr/local/apache2

cd  conf

vi  httpd.conf

打开这个httpd.conf文件之后,找到#ServerName  www.example.com:80前面的#去掉,保存即可

apache的一些常用选项:

/usr/local/apache2/bin/apachectl   -l      //列出静态模块

/usr/local/apache2/bin/apachectl   -t      //查看配置文件有没有错误)

/usr/local/apache2/bin/apachectl   -M      //把有哪些模块列出来


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章