linux安装httpd服务和步骤,小型linux系统 httpd服务安装

解压缩:

(注意要确保当前目录下有该压缩包)

136394422949.jpg

解压缩之后,进入/var/local/src/httpd-2.4.4/目录

ls查看目录下的文件

可以先查看一下说明文件 less INSTALL

136394423666.jpg

./configure –prefix=/usr/local/apache

如果直接执行的话,会遇到如下问题:

136394424144.jpg

解决方法:

首先查看系统是否已安装APR

rpm –qa |grep –I apr

136394424662.jpg

如图示,已经安装过了,

那么我们接下来就需要安装apr的开发包devel.

首先,进入我们的挂载点 cd /mnt/cdrom/Server

查看apr相关包

ll apr*

136394425141.jpg

安装devel包

rpm –ivh apr-devel-1.2.7-11.e15_3.1.i386.rpm

136394425785.jpg

接下来便可以去执行刚才的配置文件了:

136394426589.jpg

如图示,提醒的版本不匹配。

我们可以这样解决

用源代码进行安装

我们root目录下已经有所需安装包

136394427366.jpg

解压:

136394427765.jpg

进入源代码安装目录

cd /usr/local/src/apr-1.4.6/

136394428352.jpg

查看README可以看出其简单的安装步骤:

less README

136394428875.jpg

执行安装

./configure

后面可以不跟参数,默认安装到/usr/local目录下。

136394429288.jpg

安装完成后报的一个小错误,我们可以不管它。

接下来便执行make操作

136394429795.jpg

最后再执行make  install

136394430424.jpg

我们再次进入usr/local目录下时,便会发现一个apr目录,这个目录便是我们刚才安装文件时形成的目录。

136394431056.jpg

接下来还需要安装我们的util

tar -zxvf apr-util-1.5.1.tar.gz -C /usr/local/src/

136394449043.jpg

安装完成后,进入其目录

136394450667.jpg

当我们直接执行./configure时,会提示如下错误:

136394452759.jpg

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操作。

136394454069.jpg

接下来便开始执行我们之前的操作

./configure --prefix=/usr/local/apache --sysconfdir=/etc/http

136394455015.jpg

如图示,仍然提醒的有问题。

执行如下操作:

./configure --prefix=/usr/local/apache --sysconfdir=/etc/http --with-apr=/usr/local/apr/bin/apr-1-config

136394455711.jpg

出现了新的问题,关于pcre的。

rpm -qa |grep -i pcre

如图示,已经安装版本为

136394456274.jpg

主体文件我们已经安装了,那么接下来需要安装devel文件(开发包)。

136394456674.jpg

rpm -ivh /mnt/cdrom/Server/pcre-devel-6.6-2.el5_1.7.i386.rpm

136394457016.jpg

那么,下面我们再次执行之前的源码指令:

./configure --prefix=/usr/local/apache --sysconfdir=/etc/http --with-apr=/usr/local/apr/bin/apr-1-config

136394457743.jpg

如图示,执行成功,没有问题。

接下来执行make及make install操作。

136394458449.jpg

cd /usr/local/

136394459175.jpg

为了让库文件能够被系统调用,

136394459797.jpg

进入bin/目录下

136394460485.jpg

可以直接开启/停止

136394460961.jpg

事实上,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

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值