我是靠谱客的博主 诚心宝马,最近开发中收集的这篇文章主要介绍编译安装httpd服务,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

编译安装httpd服务


    首先,编译安装http,需要有它的源码包,这里提供官方下载:http://httpd.apache.org

我使用的是httpd-2.4.4.tar.bz2软件包

 

在进行源码编译安装之前,我们需要设定一下安装环境


 

1、安装开发包组:

# yum groupinstall "Development tools" "Server Platform Development" "Desktop Platform Development" "Compatibility libraries"

这四个包组,最好都安装下。

2、安装apr

APR(Apache portable Run-time libraries,Apache可移植运行库)的目的如其名称一样,主要为上层应用程序提供一个可以跨越操作系统平台使用的底层支持接口库。

因为http2.4版本需要apr的版本是1.4以上,原来1.3的不能用了。


# tar xf apr-1.4.6.tar.bz2 

# cd apr-1.4.6

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

# make ; make install


# tar xf apr-util-1.5.2.tar.bz2 

# cd apr-util-1.5.2

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

# make && make install

安装完成

 

3、安装httpd-2.4.6

# tar xf httpd-2.4.6.tar.bz2 

# cd httpd-2.4.6

# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event

简略解释选项含义:

--enable-so 启用动态支持

--with-zlib 使用zlib压缩库,将数据压缩再传输

--enable-modules=most 启用哪些模块

--enable-mpms-shared=all  把哪些模块做成动态共享模块

--with-mpm=event 默认启用的mpm


安装过程中提示了缺少pcre,故安装了pcre的devel包

# yum -y install pcre-devel

# make && make install

 

配置初始化参数:

# vim /etc/profile.d/httpd.sh

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

# . /etc/profile.d/httpd.sh 

# /usr/local/apache/bin/apachectl start

 

查看已经安装的各个模块:

# httpd -D DUMP_MODULES

Loaded Modules:

 core_module (static)

 so_module (static)

 http_module (static)

 authn_file_module (shared)

 authn_core_module (shared)

 authz_host_module (shared)

 authz_groupfile_module (shared)

 authz_user_module (shared)

 authz_core_module (shared)

 access_compat_module (shared)

 auth_basic_module (shared)

 reqtimeout_module (shared)

 filter_module (shared)

 mime_module (shared)

 log_config_module (shared)

 env_module (shared) 

 headers_module (shared)

 setenvif_module (shared)

 version_module (shared)

 mpm_event_module (shared)  event模型

 unixd_module (shared)

 status_module (shared)

 autoindex_module (shared)

 dir_module (shared)

 alias_module (shared)

httpd服务工作在event模型下的,安装时我们指定的。

 

4、配置主配置文件

# vim /etc/httpd24/httpd.conf

# Virtual hosts

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

若想启用虚拟主机,先注释

#DocumentRoot "/usr/local/apache/htdocs"

然后启用虚拟主机选项

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

 

# vim extra/httpd-vhosts.conf

<VirtualHost *:80>

        ServerName www.a.com

        DocumentRoot "/apache/host1"

        CustomLog /var/log/httpd/httpd_a_access_log combined

        <Directory "/apache/host1">

               Options None

                AllowOverride none

                Require all granted 

         </Directory>

</VirtualHost>

 

然后启动httpd即可,用客户端进行访问。

 

 

 

 

 

 

转载于:https://blog.51cto.com/gaolingxu/1437880

最后

以上就是诚心宝马为你收集整理的编译安装httpd服务的全部内容,希望文章能够帮你解决编译安装httpd服务所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(54)

评论列表共有 0 条评论

立即
投稿
返回
顶部