编译安装httpd2.4,配置httpd服务

1.安装apr,apr-utils,pcre-devel和openssl-devel

[[email protected] ~]# tar xf apr-1.5.1.tar.gz

[[email protected] ~]# tar xf apr-util-1.5.3.tar.gz

[[email protected] apr-1.5.1]# cd apr-1.5.1

[[email protected] apr-1.5.1]# ./configure --prefix=/usr/local/apr

[[email protected] apr-1.5.1]# make && make install

[[email protected] apr-1.5.1]# cd ../apr-util-1.5.3

[[email protected] apr-util-1.5.3]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr

[[email protected] apr-util-1.5.3]# make&& make install

[[email protected] httpd-2.4.10]# yum install pcre-devel

[[email protected] httpd-2.4.10]# yum install openssl-devel

2.安装httpd

[[email protected] ~]# tar xf httpd-2.4.10.tar.gz

[[email protected] ~]# cd httpd-2.4.10

[[email protected] httpd-2.4.10]#./configure--prefix=/usr/local/apache\>  \

>--sysconfdir=/etc/httpd24 \

> --enable-so \

> --enable-ssl \

> --enable-cgi \

> --enable-rewrite \

> --with-zlib  \

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

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

> --enable-mpms-shared=all  \

> --with-mpm=event \

> --enable-modules=most

[[email protected] httpd-2.4.10]# make && make install

为httpd24提供启动脚本

[[email protected] httpd24]# cat /etc/rc.d/init.d/httpd24

#!/bin/bash

#

# httpd24        Startup script for the Apache HTTP24 Server

#

# chkconfig: - 85 15

# description: Apache is a World Wide Web server.  It is used to serve \

#        HTML files and CGI.

# processname: httpd24

# config: /etc/httpd24/conf/httpd24.conf

# config: /etc/sysconfig/httpd24

# pidfile: /var/run/httpd24.pid

# Source function library.

. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/httpd24 ]; then

. /etc/sysconfig/httpd24

fi

# Start httpd24 in the C locale by default.

HTTPD_LANG=${HTTPD_LANG-"C"}

# This will prevent initlog from swallowing up a pass-phrase prompt if

# mod_ssl needs a pass-phrase from the user.

INITLOG_ARGS=""

# Set HTTPD=/usr/sbin/httpd24.worker in /etc/sysconfig/httpd24 to use a server

# with the thread-based "worker" MPM; BE WARNED that some modules may not

# work correctly with a thread-based MPM; notably PHP will refuse to start.

# Path to the apachectl script, server binary, and short-form for messages.

apachectl=/usr/local/apache/bin/apachectl

httpd24=${HTTPD-/usr/local/apache/bin/httpd}

prog=httpd24

pidfile=${PIDFILE-/var/run/httpd24.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd24}

RETVAL=0

start() {

echo -n $"Starting $prog: "

LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd24 $OPTIONS

RETVAL=$?

echo

[ $RETVAL = 0 ] && touch ${lockfile}

return $RETVAL

}

stop() {

echo -n $"Stopping $prog: "

killproc -p ${pidfile} -d 10 $httpd24

RETVAL=$?

echo

[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

}

reload() {

echo -n $"Reloading $prog: "

if ! LANG=$HTTPD_LANG $httpd24 $OPTIONS -t >&/dev/null; then

RETVAL=$?

echo $"not reloading due to configuration syntax error"

failure $"not reloading $httpd24 due to configuration syntax error"

else

killproc -p ${pidfile} $httpd24 -HUP

RETVAL=$?

fi

echo

}

# See how we were called.

case "$1" in

start)

start

;;

stop)

stop

;;

status)

status -p ${pidfile} $httpd24

RETVAL=$?

;;

restart)

stop

start

;;

condrestart)

if [ -f ${pidfile} ] ; then

stop

start

fi

;;

reload)

reload

;;

graceful|help|configlinuxidc|fullstatus)

$apachectl [email protected]

RETVAL=$?

;;

*)

echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configlinuxidc}"

exit 1

esac

exit $RETVAL

添加到启动项并启动服务

[email protected] httpd24]# chkconfig --add httpd24

[[email protected] httpd24]# chmod +x /etc/rc.d/init.d/httpd24

[[email protected] httpd24]# chkconfig httpd24 on

[[email protected] httpd24]# service httpd24 start

Starting httpd24: AH00558: httpd: Could not reliably determine the server‘s fully qualified domain name, using wh1.mageedu.com. Set the ‘ServerName‘ directive globally to suppress this message

[  OK  ]

3. 安装后配置

[[email protected] profile.d]# vim httpd24.sh

PATH=/usr/local/apache/bin:$PATH

[[email protected] etc]# vim man.config

MANPATH /usr/local/apache/man

[[email protected] httpd24]# vim httpd.conf

PidFile "/var/run/httpd24.pid"

4. 搭建基于IP的虚拟主机

[[email protected] extra]# vim /etc/httpd24/httpd.conf

Include /etc/httpd24/extra/httpd-vhosts.conf

[[email protected] extra]# cat httpd-vhosts.conf

<VirtualHost 172.16.21.250:80>

DocumentRoot "/web/172"

ServerName www.linuxidc.com

</VirtualHost>

<Directory /web/172>

Require all granted

</Directory>

<VirtualHost 192.168.1.123:80>

DocumentRoot "/web/192"

ServerName www.linuxidc.com

</VirtualHost>

<Directory /web/192>

Require all granted

</Directory>

[[email protected] extra]mkdir -p /web/{192,172}

[[email protected] extra]echo "Access from 192" >/web192/index.html

[[email protected] extra]echo "Access from 172" >/web/172/index.html

#重启服务

[[email protected] extra]# service httpd24 restart

#验证

[[email protected] extra]# curl 192.168.1.123

Access from 192

[[email protected] extra]# curl 172.16.21.250

Access from 172

5. 搭建基于端口的虚拟主机

[[email protected] extra]# cat httpd-vhosts.conf

Listen 8080

<VirtualHost 172.16.21.250:80>

DocumentRoot "/web/80"

ServerName www.linuxidc.com

</VirtualHost>

<Directory /web/80>

Require all granted

</Directory>

<VirtualHost 172.16.21.250:8080>

DocumentRoot "/web/8080"

ServerName www.linuxidc.com

</VirtualHost>

<Directory /web/8080>

Require all granted

</Directory>

[[email protected] extra]# mkdir -v /web/{80,8080}

[[email protected] extra]# echo "Access from port8080" >/web/8080/index.html

[[email protected] extra]# echo "Access from port80" >/web/80/index.html

#重启服务

[[email protected] extra]# service httpd24 restart

#验证

[[email protected] extra]# curl 172.16.21.250:8080

Access from port8080

[[email protected] extra]# curl 172.16.21.250:80

Access from port80

6.搭建基于域名的虚拟主机

#在httpd2.2版本定义基于域名的虚拟主机时,需要加入如下现象,在2.4则不再需要,直接定义即可

#NameVirtualHost IP:PORT

[[email protected] extra]# vim httpd-vhosts.conf

<VirtualHost 172.16.21.250:80>

DocumentRoot "/web/80"

ServerName www1.linuxidc.com

</VirtualHost>

<Directory /web/www1>

Require all granted

</Directory>

<VirtualHost 172.16.21.250:80>

DocumentRoot "/web/80"

ServerName www2.linuxidc.com

</VirtualHost>

<Directory /web/www2>

Require all granted

</Directory>

#由于没有DNS服务器,方便起见,在/etc/host中添加以下两行

172.16.21.250  www1.linuxidc.com

172.16.21.250  www2.linuxidc.com

#验证

[[email protected] extra]# curl www1.linuxidc.com

www1.linuxidc.com

[[email protected] extra]# curl www2.linuxidc.com

www2.linuxidc.com

源代码下载地址:

Apr:http://mirrors.cnnic.cn/apache//apr/apr-1.5.1.tar.gz

Apr-util:http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.3.tar.gz

httpd:http://mirrors.cnnic.cn/apache//httpd/httpd-2.4.10.tar.gz

--------------------------------------------------------------------------------

The End

CentOS 6.5编译安装httpd-2.4.7 http://www.linuxidc.com/Linux/2014-02/97265.htm

httpd中工作模型的比较 http://www.linuxidc.com/Linux/2014-02/97265.htm

编译安装最新版httpd-2.4 http://www.linuxidc.com/Linux/2014-03/98761.htm

httpd2.4基本功能的实现... http://www.linuxidc.com/Linux/2014-03/98762.htm

时间: 2024-10-17 18:33:28

编译安装httpd2.4,配置httpd服务的相关文章

编译安装LAMP之配置httpd以FastCGI方式与php整合

一.编译安装httpd(httpd 2.4.4,相关软件包可到apache官网上下载) # hwclock -s 将软件时间同步为硬件时间,防止安装软件时出错 1.解决依赖关系 httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级.这里使用源码包进行升级(apr-1.5.2,apr-util-1.5.4 ) (1) 编译安装apr # tar xf apr-1.5.2.tar.bz2 # cd apr-1.5.2 # ./configure --prefix=/

编译安装httpd-2.4.9及配置其相关的工作方式

写在前面:如果此文有幸被某位朋友看见并发现有错的地方,希望批评指正.如有不明白的地方,愿可一起探讨. 解决依赖关系 httpd-2.4.9依赖于较新版本的apr和apr-util,接下来就编译安装apr和apr-util 1.编译安装apr # tar xf apr-1.5.0.tar.bz2 # cd apr-1.5.0 # ./configure --prefix=/usr/local/apr # make && make install 2.编译安装apr-util # tar xf

DNS服务编译安装,及配置

DNS服务是域名转换服务. 原理及功能可以参考http://kmk0226.blog.51cto.com/5975994/1678180 今天的博客是介绍DNS服务的编译安装,以及安装之后如何配置DNS服务,让服务能正常运行. 在Linux系统中,DNS服务在Bind这个程序中配置的. 首先,要编译安装DNS服务,需要先去下载源码包. 源码包可以在bind官方网站下载 bind官方站点:www.isc.org 有9.9.X与9.10.X的版本,我们这里以9.9.X的版本来编译安装. X代表子版本

CentOS6 编译安装httpd-2.4

httpd-2.4:新特性:    (1) MPM支持运行为DSO机制:以模块形式按需加载:    (2) event MPM生产环境可用:    (3) 异步读写机制:    (4) 支持每模块及每目录的单独日志级别定义:    (5) 每请求相关的专用配置:    (6) 增强版的表达式分析式:    (7) 毫秒级持久连接时长定义:    (8) 基于FQDN的虚拟主机也不再需要NameVirutalHost指令:    (9) 新指令,AllowOverrideList:只能将那些文件放

我的linux学习之旅:(2)编译安装httpd2.4

编译安装httpd2.4 目标:在www1这台主机上编译安装httpd服务,www2暂不安装为将来扩展使用 操作系统CentOS6.6 x32_64 安装中使用的文件 /etc/sysconfig/network-scripts/ifcfg-eth0 配置 安装开始 安装完成启动服务时会出现提示 将配置文件中该行注释删除 ok 检测一下域名的解析情况 检查一下httpd是否工作正常 #!/bin/bash # httpd-2.4 install yum groupinstall -y "Deve

编译安装httpd-2.4.10

httpd-2.4新特性 1).MPM支持在运行时加载 --enbale-mpms-shared=all --with-mpm=event 2)支持event 3)支持异步读写 4)在每模块及目录上指定日志级别 5)每请求配置:<IF>,<Elseif> 6)增强版的表达式分析器 7)毫秒级的keepalive timeout 8)基于FQDN的虚拟机主机不再需要NameVirtualHost指令 9)支持自定义变量 新增加了一下模块,mod_proxy_fcgi,mod_rate

源码编译安装 httpd2.4+MariaDB5.5+php5.4 全新的LAMP

操作环境: http主机,php主机,MariaDB主机,操作系统CentOS6.5 x86_64 全部安装包组:Development tools  ServerPlatform Development httpeth0 IP:172.16.32.11 MariaDBeth0 IP:172.16.32.10 phpeth0 IP:172.16.32.12 httpd2.4新特性:解释下面安装用到的几个 event不再是测试状态,而是可以直接编译进去,mpm模块可以动态装载卸载 分了多个配置文件

源码编译安装httpd2.4及虚拟主机

1.安装apr,apr-utils,pcre-devel和openssl-devel [[email protected] ~]# tar xf apr-1.5.1.tar.gz [[email protected] ~]# tar xf apr-util-1.5.3.tar.gz  [[email protected] apr-1.5.1]# cd apr-1.5.1 [[email protected] apr-1.5.1]# ./configure --prefix=/usr/local/

编译安装httpd-2.4,server-status,ssl

1.编译安装前准备 由于httpd-2.4依赖于1.4+的apr,所以编译安装apr和apr-util (1) 编译安装apr # tar xf apr-1.5.0.tar.bz2 # cd apr-1.5.0 # ./configure --prefix=/usr/local/apr # make && make install (2) 编译安装apr-util # tar xf apr-util-1.5.3.tar.bz2 # cd apr-util-1.5.3 # ./configu