ew21w 发表于 2015-3-31 08:24:58

httpd 2.4.12 安装配置

编译apache 之前查看官网的安装说明

http://httpd.apache.org/docs/2.4/install.htmlapache 安装说明

下载组件wgethttp://mirrors.hust.edu.cn/apache/apr/apr-1.5.1.tar.gz

      wget http://mirrors.hust.edu.cn/apache/apr/apr-util-1.5.4.tar.gz

      wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.35.tar.gz

需要编译安装组件 aprapr-util pcre ,验证一下下载的组件包是否正常

       https://apr.apache.org/docs/apr/1.5/查看官网安装说明

2.4.1 编译apache

http://httpd.apache.org/docs/2.4/en/programs/configure.html编译参数选项说明

# cd /soft/tool/

#tarapr-1.5.1.tar.gz -C /usr/local/src/

#tar zxfapr-util-1.5.4.tar.gz -C /usr/local/src/

#cd/usr/local/src/apr-1.5.1/

# ./configure --prefix=/usr/local/apr

备注:有时候这样的编译的apache也会报错apr的错误,解决方法:./configure --prefix=/usr/local/apr-httpd

编译的时候可以使用./configure –help

rm: cannot remove `libtoolT': Nosuch file or directory

config.status: executing default commands

如果不是error 或者警告之类的错误提示 不需要理会他就行了

或者参考去修改configure 文件 将这行注释掉

   cfgfile="${ofile}T"

    trap"$RM \"$cfgfile\"; exit 1" 1 2 15

   # "$RM \"$cfgfile\"注释掉就可以了,可以去apache官网查找帮助

https://bz.apache.org/bugzilla/show_bug.cgi?id=51726

[root@web1_lampapr-1.5.1]#make && make install

# cd/usr/local/src/apr-util-1.5.4/

#

#

./configure\

--prefix=/usr/local/apr-util\

--with-apr=/usr/local/apr

备注:即使这样编译安装了也会报错,解决方法:--prefix=/usr/local/apr-util-httpd

apr-util参考官网或者使用./configure–help 去添加一些参数

# make

# make install

[root@web1_lampapr-util-1.5.4]# cd /soft/tool/

# tarzxf pcre-8.36.tar.gz -C /usr/local/src/

# cd/usr/local/src/pcre-8.36

#./configure --prefix=/usr/local/pcre

# make&& make install

#cd /usr/local/src/httpd-2.4.12/

[root@web1_lamphttpd-2.4.12]#

./configure\

--prefix=/usr/local/apache2 \

--with-apr=/usr/local/apr \

--with-apr-util=/usr/local/apr-util \

--with-pcre=/usr/local/pcre \

--enable-modules=mall \

--enable-rewrite\

--enable-mpms-shared=all \

--with-mpm=event \

--enable-v4-mapped \

--enable-so

[root@web1_lamphttpd-2.4.12]# make && make install

参数说明

静态编译所有模块,但保留动态加载选项--enable-so,之后还是可以在配置文件中动态加载自己编译的模块。

--sysconfdir=/etc/httpd   指定apache的配置文件在/etc/httpd

如果不指定apahce 的配置文件,默认在/usr/local/apache/conf

[root@web1_lamphttpd-2.4.12]# make && make install

#/usr/local/apache2/bin/apachectl -t测试apache

AH00558:httpd: Could not reliably determine the server's fully qualified domain name,using 20.0.0.10. Set the 'ServerName' directive globally to suppress thismessage

SyntaxOK

关于源码启动解决

故障原因是由于源码conf/httpd.conf中关于hostname设置和/etc/sysconfig/network的hostname不一致导致的

默认的HOSTNAME=localhost.localdomain

1.# vim /etc/http/httpd.conf   

ServerName localhost:80   è设置为本机

# more/usr/local/apache2/bin/apachectl   查看apache的启动脚本

# /usr/local/apache2/bin/apachectl-k start

Apche 启动之后需要查看apche状态,需要去查apache的端口或者进程,默认的端口号为80

# netstat -anp| grep 80

tcp      0      0 :::80                     :::*                        LISTEN      1282/httpd         

unix3      [ ]         STREAM   CONNECTED   10580 1249/master   

[root@web1_lamphttpd-2.4.12]# ps axu|grep httpd

root       2383 0.01.7 2446128668 ?       Ss   18:16   0:00 /usr/local/apache2/bin/httpd -k start

daemon   2384 0.01.3 5867366616 ?       Sl   18:16   0:00 /usr/local/apache2/bin/httpd -k start

daemon   2385 0.01.3 5867366620 ?       Sl   18:16   0:00 /usr/local/apache2/bin/httpd -k start

daemon   2386 0.01.3 5867366624 ?       Sl   18:16   0:00 /usr/local/apache2/bin/httpd -k start

root       2469 0.00.1 103244   864 pts/0   S+   18:16   0:00 grep httpd

启动之后可以在客户端去测试,注意必须使用hosts 解析

测试apache安装ok

# /usr/local/app/apache2/bin/apachectl -k start启动apache

#/usr/local/apache2/bin/apachectlgraceful

重启不断开链接/ apachectl生产常用 apachectl–t 检查配置文件语法关闭就是-kstop

2.4.2 Apache 配置

# echo"/usr/local/apache2/bin/apachectl start" >> /etc/rc.d/rc.local è添加到开机加载文件中,设置apache为开机启动

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

# chmod 755 /etc/init.d/httpd

# chkconfig --add httpdè这样添加会报错

service httpd does not support chkconfig   没有这个服务

# chkconfig--add httpd

service httpd does not support chkconfig

# more /etc/init.d/httpd   查看一下httpd的启动脚本

# vim/etc/init.d/httpd    编辑httpd 启动脚本

# # tail -2/etc/init.d/httpd需要将注释的下面两行添加到/etc/init.d/httpd

#chkconfig: 2345 8515

#description:Activates/Deactivates Apache Web Server

# chkconfig--add httpd

# chkconfig--list httpd

httpd         0:off   1:off2:on    3:on    4:on   5:on    6:off

[root@web1_lamprc.d]# chkconfig httpd on 添加为开机自启动



页: [1]
查看完整版本: httpd 2.4.12 安装配置