[su]Linux下编译安装Apache httpd

来源:互联网 发布:dns 多域名 同一ip 编辑:程序博客网 时间:2024/05/28 23:10

一、    学习目标

掌握linux下apache httpd的源码安装全过程。

掌握apache httpd启动和停止命令。

二、    学习前提

了解linux中tar命令、netstat命令、linux源码编译等知识。

三、    学习内容

1、 Apache服务器简介

Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。

2、 安装环境说明

安装环境:centos6.5_64位。

安装版本:httpd-2.4.23、apr-1.5.2、apr-util-1.5.4、pcre-8.39(是pre1不是pre2)。

安装方式:源码编译安装。

按照用户:使用root安装

3、 httpd依赖关系

httpd依赖于apr, apr-util

apr全称为apache portable runtime,能实现httpd跨平台运行。

4、 apr安装

# tar zxvf apr-1.5.2.tar.gz

# cd apr-1.5.2

    # ./configure --prefix=/usr/local/apr   (--prefix指定apr安装的目录)

    # make

    # make  install

5、 apr-util安装

# tar zxvf apr-util-1.5.4.tar.gz

# cd apr-util-1.5.4

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

# make && make install

6、 pcre安装

# tar zxvf pcre-8.39.tar.gz

# cd pcre-8.39 

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

    # make && make install

7、 httpd安装

# tar zxvf httpd-2.4.23.tar.gz

        以下为几个主要的配置项

        --sysconfdir=/etc/httpd24  指定配置文件路径

        --enable-so  启动模块动态装卸载

        --enable-ssl 编译ssl模块

        --enable-cgi 支持cgi机制(能够让静态web服务器能够解析动态请求的一个协议)

        --enable-rewrite  支持url重写     --Author : Leshami

        --with-zlib  支持数据包压缩       --Blog   : http://blog.csdn.net/leshami

        --with-pcre  支持正则表达式

        --with-apr=/usr/local/apr  指明依赖的apr所在目录

        --with-apr-util=/usr/local/apr-util/  指明依赖的apr-util所在的目录

        --enable-modules=most      启用的模块

        --enable-mpms-shared=all   以共享方式编译的模块

        --with-mpm=prefork         指明httpd的工作方式为prefork

#cd httpd-2.4.23

[root@dream httpd-2.4.23]#./configure --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --with-pcre=/usr/local/pre1/bin/pcre-config --enable-so  --enable-ssl --enable-cgi --enable-rewrite--with-zlib --with-mpm=prefork --enable-modules=most --enable-mpms-shared=all 

或[root@dream httpd-2.4.23]# ./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr   --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre1/bin/pcre-config --enable-so

# make 

# make install

8、 配置http2.4启动

# service httpd start

9、 验证

访问http://192.168.21.10进行访问:

# echo "This is a apached 2.4.9 version">>/usr/local/apache/htdocs/index.html    

# curl http://192.168.21.10:80

<html><body><h1>It works!</h1></body></html> 

This is a apached 2.4.9 version



原创粉丝点击