apache源码安装

1.apr和apr-util,下载地址: http://apr.apache.org/download.cgilinux

yum install gcc
yum install libtool
yum install expat-devel
yum install pcre-devel

cd apr-1.6.3/
./configure --prefix=/opt/apr

出现如下错误apache

rm: cannot remove 'libtoolT': No such file or directory

include/arch/unix/apr_private.h is unchange
cp configure ./configure.bak
vi configure
#$RM “$cfgfile”   #注释掉这行
:wq

!./configure --prefix #从新执行上一次相同的命令
make -j 4 #四核运行
make install

tar -zxvf apr-util-1.6.1.tar.bz2 #注意不要下载apr-util-1.6.1.tar.gz这个gz文件会出现安装错误
cd apr-util-1.6.1
./configure --prefix=/opt/apr-util --with-apr=/opt/apr
make && make instal

2. 下载安装pcre【若是以及yum安装则跳过此步】bash

wget https://ftp.pcre.org/pub/pcre/pcre2-10.30.tar.gz
tar -zxvf pcre2-10.30.tar.gz
cd pcre2-10.30
./configure --prefix=/opt/pcre
make && make installyum -y install pcre-devel

 3.安装apachedom

./configure --prefix=/opt/apache --with-apr=/opt/apr --with-apr-util=/opt/apr-util --with-include-apr --enable-so
make && make install

4.你会发现apache stop|restart|start都不成功spa

Could not reliably determine the server's fully qualified domain name

解决办法unix

vi httpd.conf
#ServerName www.example.com:80 
#修改成
ServerName localhost:80

5.将apache设定为开机启动rest

注册Apache到Linux服务
在Linux下用源代码方式编译安装完Apache后,启动关闭Apache能够经过以下命令实现: code

/opt/apache/bin/apachectl start|stop|restart

加入开机启动server

cp /opt/apache/bin/apachectl  /etc/rc.d/init.d/httpd 
#连接文件的S61是启动时的序号。
#当init.d目录下有httpd脚本后,咱们就能够经过service命令来启动关闭apache了。
ln -s /etc/rc.d/init.d/httpd  /etc/rc.d/rc3.d/S61httpd
service httpd start | stop | restart

这时有个问题就是:虽然apache已经能够自动启动,但在linux的服务列表中却看不到它,要添加服务,通常经过chkconfig --add xxx来实现,但须要脚本中有相应的信息才行,不然chkconfig就会提示:xxx 服务不支持 chkconfig。因此咱们首先编辑httpd脚本,在第2行(#!/bin/sh下面)添加以下注释信息(包括#):blog

vi /etc/rc.d/init.d/httpd
# chkconfig: 35 61 61
# description: Apache

第一行的3个参数意义分别为:在哪些运行级别启动httpd(3,5);启动序号(S61);关闭序号(K61)。注意:第二行的描述必需要写!保存后执行:

chkconfig --add httpd #全部开机模式下自启动,另外chkconfig httpd on 表示345模式下自启动

就将httpd添加入服务了。在rc3.d、rc5.d路径中未来就会出现S61httpd的连接,其余运行级别路径中会出现K61httpd的连接。

运行下面的命令查看服务,就能够看到httpd的服务了。

chkconfig --list
相关文章
相关标签/搜索