解压缩:
(注意要确保当前目录下有该压缩包)
解压缩之后,进入/var/local/src/httpd-2.4.4/目录
ls查看目录下的文件
可以先查看一下说明文件 less INSTALL
./configure –prefix=/usr/local/apache
如果直接执行的话,会遇到如下问题:
解决方法:
首先查看系统是否已安装APR
rpm –qa |grep –I apr
如图示,已经安装过了,
那么我们接下来就需要安装apr的开发包devel.
首先,进入我们的挂载点 cd /mnt/cdrom/Server
查看apr相关包
ll apr*
安装devel包
rpm –ivh apr-devel-1.2.7-11.e15_3.1.i386.rpm
接下来便可以去执行刚才的配置文件了:
如图示,提醒的版本不匹配。
我们可以这样解决
用源代码进行安装
我们root目录下已经有所需安装包
解压:
进入源代码安装目录
cd /usr/local/src/apr-1.4.6/
查看README可以看出其简单的安装步骤:
less README
执行安装
./configure
后面可以不跟参数,默认安装到/usr/local目录下。
安装完成后报的一个小错误,我们可以不管它。
接下来便执行make操作
最后再执行make install
我们再次进入usr/local目录下时,便会发现一个apr目录,这个目录便是我们刚才安装文件时形成的目录。
接下来还需要安装我们的util
tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/
安装完成后,进入其目录
当我们直接执行./configure时,会提示如下错误:
Apr不能被定位,需要我们使用 –with-apr 才可以。
./configure --with-apr=/usr/local/apr/bin/apr-1-config
执行结果如下:
[root@localhost apr-util-1.5.1]# ./configure --with-apr=/usr/local/apr/bin/apr-1-config
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking for working mkdir -p... yes
APR-util Version: 1.5.1
checking for chosen layout... apr-util
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
Applying apr-util hints file rules for i686-pc-linux-gnu
checking for APR... yes
setting CPP to "gcc -E"
adding "-pthread" to CFLAGS
setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
checking how to run the C preprocessor... gcc -E
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for ldap support...
checking for default DBM... sdbm (default)
checking for pg_config... no
checking libpq-fe.h usability... no
checking libpq-fe.h presence... no
checking for libpq-fe.h... no
checking postgresql/libpq-fe.h usability... no
checking postgresql/libpq-fe.h presence... no
checking for postgresql/libpq-fe.h... no
checking sqlite3.h usability... yes
checking sqlite3.h presence... yes
checking for sqlite3.h... yes
checking for sqlite3_open in -lsqlite3... yes
setting LDADD_dbd_sqlite3 to " -lsqlite3"
checking sqlite.h usability... no
checking sqlite.h presence... no
checking for sqlite.h... no
checking sybdb.h usability... no
checking sybdb.h presence... no
checking for sybdb.h... no
checking freetds/sybdb.h usability... no
checking freetds/sybdb.h presence... no
checking for freetds/sybdb.h... no
checking for odbc_config... no
checking sql.h usability... no
checking sql.h presence... no
checking for sql.h... no
checking odbc/sql.h usability... no
checking odbc/sql.h presence... no
checking for odbc/sql.h... no
checking Expat 1.95.x... yes
setting APRUTIL_EXPORT_LIBS to "-lexpat"
setting APRUTIL_LIBS to "-lexpat"
checking iconv.h usability... yes
checking iconv.h presence... yes
checking for iconv.h... yes
checking for type of inbuf parameter to iconv... char **
checking for iconv.h... (cached) yes
checking langinfo.h usability... yes
checking langinfo.h presence... yes
checking for langinfo.h... yes
checking for nl_langinfo... yes
checking for CODESET in langinfo.h... yes
checking whether APR has DSO support... yes
checking for library containing crypt... -lcrypt
checking if system crypt() function is threadsafe... no
checking for crypt_r... yes
checking style of crypt_r... struct_crypt_data
adding "/usr/local/apr/lib/libapr-1.la" to APRUTIL_LIBS
adding "-luuid" to APRUTIL_LIBS
adding "-lrt" to APRUTIL_LIBS
adding "-lcrypt" to APRUTIL_LIBS
adding "-lpthread" to APRUTIL_LIBS
adding "-ldl" to APRUTIL_LIBS
configure: creating ./config.status
config.status: creating Makefile
config.status: creating export_vars.sh
config.status: creating build/pkg/pkginfo
config.status: creating apr-util.pc
config.status: creating apu-1-config
config.status: creating include/private/apu_select_dbm.h
config.status: creating include/apr_ldap.h
config.status: creating include/apu.h
config.status: creating include/apu_want.h
config.status: creating test/Makefile
config.status: creating include/private/apu_config.h
config.status: executing default commands
[root@localhost apr-util-1.5.1]#
然后便可以执行make及make install操作。
接下来便开始执行我们之前的操作
./configure --prefix=/usr/local/apache --sysconfdir=/etc/http
如图示,仍然提醒的有问题。
执行如下操作:
./configure --prefix=/usr/local/apache --sysconfdir=/etc/http --with-apr=/usr/local/apr/bin/apr-1-config
出现了新的问题,关于pcre的。
rpm -qa |grep -i pcre
如图示,已经安装版本为
主体文件我们已经安装了,那么接下来需要安装devel文件(开发包)。
rpm -ivh /mnt/cdrom/Server/pcre-devel-6.6-2.el5_1.7.i386.rpm
那么,下面我们再次执行之前的源码指令:
./configure --prefix=/usr/local/apache --sysconfdir=/etc/http --with-apr=/usr/local/apr/bin/apr-1-config
如图示,执行成功,没有问题。
接下来执行make及make install操作。
cd /usr/local/
为了让库文件能够被系统调用,
进入bin/目录下
可以直接开启/停止
事实上,apachectl是调用了httpd程序,
我们可以自己编写httpd脚本,来实现httpd服务的开启/停止/重启服务。
cd /etc/init.d/
vim httpd
我们会发现输入的脚本不会变颜色,给其加上执行权限就行了。
chmod a+x httpd
vim httpd
下面为shell脚本文件:
#!/bin/bash
#chkconfig: - 88 90
#description: httpd server
HTTPD='/usr/local/apache/bin/httpd'
CONFFILE='/etc/httpd/httpd.conf'
. /etc/init.d/functions
start(){
[ -f /var/lock/subsys/http ] && echo "httpd is started......"&& exit
echo -n "httpd is starting......"
sleep 1
$HTTPD -f $CONFFILE && RETVAL=0||RETCAL=1
[ $RETCAL -eq 0 ]&&touch /var/lock/subsys/http && echo -e "\033[31m [ok] \033[0m" ||echo -e "\033[31m [fail] \033[0m"
}
stop(){
echo -n "httpd is stoping...."
sleep 1
killproc httpd && RETVAL=0||RETVAL=1
[ $RETVAL -eq 0 ] && rm -rf /var/lock/subsys/http ||echo -e "\033[031m [fail] \033[0m"
}
case $1 in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "Usage:start|stop|restart"
;;
esac
至此,脚本文件编写结束。
chkconfig –list |grep http
service http stop
chkconfig –level 35 on
//3级别5级别开启
ll /etc/rc.d/rc3.d/ |grep http
ll /etc/rc.d/rc3.d/ |grep http
chkconfig –level 35 on
//3级别5级别关闭
ll /etc/rc.d/rc3.d/ |grep http
ll /etc/rc.d/rc3.d/ |grep http