码迷,mamicode.com
首页 > Web开发 > 详细

编译安装apache

时间:2017-12-04 20:33:58      阅读:334      评论:0      收藏:0      [点我收藏+]

标签:编译 安装 apache

apache 全称: Apache  Http Server 是一款功能强大性能卓越的Web服务器端软件之一。

简单的编译安装步骤如下:以centos7为例

第一步:

      准备开发工具包组件:Deve Lopment Tools(可以使用yum install Deven Lopment Tools 安装);pcre*   openssl*

第二部: 

      从官网下载apache源码包 tar.bz2  或者 tar.gz  格式 (wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.29.tar.bz2)下载至当前目录 

使用解压做命令:tar zxf httpd-2.4.29.tar.bz2    

cd进httpd-2.4.29.tar.bz2 

技术分享图片第二步:

       执行 ./configure之前建议阅读README与INSTALL文件或者 ./configure --help 查看其支持的功能选项及其参数;生产环境可以根据需要指定功能即可。这里是测试环境所以我们只需要简单指定安装目录及配置文件的安装位置;

./configure --prefix=/usr/local/apache2  --sysconfdir=/etc/apache2

技术分享图片

这里出现报错缺少“APR”这个包通常缺的是 -devel的包直接用yum -list “APR*” 然后 yum -y install  apr-devel 直接安装即可;

技术分享图片

[root@CentOS7 /app/httpd-2.4.29 139]#./configure --prefix=/usr/local/apache2 --sysconfdir=/etc/apache2

checking for chosen layout... Apache

checking for working mkdir -p... yes

checking for grep that handles long lines and -e... /usr/bin/grep

checking for egrep... /usr/bin/grep -E

checking build system type... x86_64-pc-linux-gnu

checking host system type... x86_64-pc-linux-gnu

checking target system type... x86_64-pc-linux-gnu

configure: 

configure: Configuring Apache Portable Runtime library...

configure: 

checking for APR... yes

  setting CC to "gcc"

  setting CPP to "gcc -E"

  setting CFLAGS to "  -pthread"

  setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE"

  setting LDFLAGS to " "

configure: 

configure: Configuring Apache Portable Runtime Utility library...

configure: 

checking for APR-util... yes

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

checking how to run the C preprocessor... gcc -E

checking for gcc option to accept ISO C99... -std=gnu99

checking for pcre-config... /usr/bin/pcre-config

configure: Using external PCRE library from /usr/bin/pcre-config

  setting PCRE_INCLUDES to ""

  setting PCRE_LIBS to "-lpcre"

configure: 

configure: Configuring Apache httpd...

configure: 

  setting INCLUDES to "-I."

  adding "-I$(top_srcdir)/os/$(OS_DIR)" to INCLUDES

  adding "-I$(top_srcdir)/include" to INCLUDES

  adding "-I/usr/include/apr-1" to INCLUDES

configure: 

configure: Applying OS-specific hints for httpd...

configure: 

  forcing SINGLE_LISTEN_UNSERIALIZED_ACCEPT to "1"

  forcing AP_NONBLOCK_WHEN_MULTI_LISTEN to "1"

checking for rm... /usr/bin/rm

checking for pkg-config... /usr/bin/pkg-config

checking for rsync... /usr/bin/rsync

config.status: creating docs/conf/extra/httpd-ssl.conf

config.status: creating docs/conf/extra/httpd-userdir.conf

config.status: creating docs/conf/extra/httpd-vhosts.conf

config.status: creating docs/conf/extra/proxy-html.conf

config.status: creating include/ap_config_layout.h

config.status: creating support/apxs

config.status: creating support/apachectl

config.status: creating support/dbmmanage

config.status: creating support/envvars-std

config.status: creating support/log_server_status

config.status: creating support/logresolve.pl

config.status: creating support/phf_abuse_log.cgi

config.status: creating support/split-logfile

config.status: creating build/rules.mk

config.status: creating build/pkg/pkginfo

config.status: creating build/config_vars.sh

config.status: creating include/ap_config_auto.h

config.status: executing default commands

configure: summary of build options:


    Server Version: 2.4.29

    Install prefix: /usr/local/apache2

    C compiler:     gcc -std=gnu99

    CFLAGS:           -pthread  

    CPPFLAGS:        -DLINUX -D_REENTRANT -D_GNU_SOURCE  

    LDFLAGS:           

    LIBS:             

    C preprocessor: gcc -E(输出信息太多截取部分检查安装环境configure脚本)

第三步:开始编译  执行   mak 

dules -module -avoid-version  mod_rewrite.lo 

make[4]: Leaving directory `/app/httpd-2.4.29/modules/mappers'

make[3]: Leaving directory `/app/httpd-2.4.29/modules/mappers'

make[2]: Leaving directory `/app/httpd-2.4.29/modules'

make[2]: Entering directory `/app/httpd-2.4.29/support'

make[2]: Leaving directory `/app/httpd-2.4.29/support'


make[1]: Leaving directory `/app/httpd-2.4.29'

输出信息太多截取部分。这一步没有提示错误接下来可以执行下一条命令

第四步:

makeinstall(这一步基本都是cp文件到各个目录)

Installing configuration files

mkdir /etc/apache2

mkdir /etc/apache2/extra

mkdir /etc/apache2/original

mkdir /etc/apache2/original/extra

Installing HTML documents

mkdir /usr/local/apache2/htdocs

Installing error documents

mkdir /usr/local/apache2/error

Installing icons

mkdir /usr/local/apache2/icons

mkdir /usr/local/apache2/logs

Installing CGIs

mkdir /usr/local/apache2/cgi-bin

Installing header files

mkdir /usr/local/apache2/include

Installing build system files

mkdir /usr/local/apache2/build

Installing man pages and online manual

mkdir /usr/local/apache2/man

mkdir /usr/local/apache2/man/man1

mkdir /usr/local/apache2/man/man8

mkdir /usr/local/apache2/manual

make[1]: Leaving directory `/app/httpd-2.4.29'

编译安装基本算是完成;接下来我们需要导出头文件; 库文件;PATH环境变量;帮助文件  编译安装没有PATH环境变量bash会无法找到

导出二进制程序目录至PATH环境变量中:

  编辑文件/etc/profile.d/NAME.sh

export PATH=/usr/local/apache2/bin:$PATH(不在配置文件中配置),它仅仅对当前shell进程生效

导出库文件路径

编辑/etc/ld.so.conf.d/NAME.conf        /usr/local/apache2/lib,添加库文件路径到随便一个文件名.conf中;

然后让系统重新生成缓存: ldconfig [-v]       //-v显示生成缓存过程

导出头文件

 /usr/local/apache2/include应该放置/usr/include里面来,创建链接就可以实现了,ln -sv,创建符号链接

              ln –sv

导出帮助手册编辑/etc/man.config文件  

按照相同格式补上路径即可

第五步:

关闭防火墙:键入本机ip就可以测试

启动服务测试













编译安装apache

标签:编译 安装 apache

原文地址:http://blog.51cto.com/37003839/2047320

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!