您的位置:首页 > 理论基础 > 计算机网络

build 源码编译安装httpd

2014-03-22 22:35 671 查看
众所周知,编译安装可以获得最新的软件,比较安全,bug比较少;可以自己定义开启哪功能,安装到哪里;但是安装起来依赖关系较多,所以比较麻烦。我以安装httpd为例谈一谈自己对编译安装的拙见。
1.下载所需要的压缩文件或目录
从网站apache.org 下载httpd



2.解压
[root@teacher lianxi]# tar xf httpd-2.4.9.tar.bz2

3.进入目录
[root@teacher lianxi]# cd httpd-2.4.9
[root@teacher httpd-2.4.9]# ls
ABOUT_APACHE CHANGES InstallBin.dsp README
acinclude.m4 config.layout LAYOUT README.platforms
Apache-apr2.dsw configure libhttpd.dsp ROADMAP
Apache.dsw configure.in LICENSE server
apache_probes.d docs Makefile.in srclib
ap.d emacs-style Makefile.win support
build httpd.dsp modules test
BuildAll.dsp httpd.spec NOTICE VERSIONING
BuildBin.dsp include NWGNUmakefile
buildconf INSTALL os
[

[root@teacher httpd-2.4.9# ./configure --help 可以查看那些功能可以开启,那些功能默认情况,那些默认不开,指定安装路径等等
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
===
以--enable开头的选项说明默认情况下不开启,需要我们使用这个选项去打开这个功能
以--disable开头的选项说明默认情况下开启,需要我们使用这个选项去关闭这个功能
--enable-authn-anon anonymous user authentication control
--disable-authz-host host-based authorization control
--disable-version determining httpd version in config files
需要开启ssl功能指定相关OpenSSL软件的路径
--with-ssl=PATH OpenSSL installation directory
--with-apr=/usr/local/apr/
====
了解软件的安装和使用请阅读,
(1) README文档
(2) INSTALL文档
INSTALL文件里说明的步骤
$ ./configure --prefix=PREFIX
$ make
$ make install
$ PREFIX/bin/apachectl start

====
4,Simply; 经典步骤

(1) ./configure --prefix=/desired/path/of/apr
编译前的配置
[root@teacher httpd-2.4.9]# ./configure --prefix=/usr/local/apache9 --enable-cache --enable-so 配置安装的目录,同时开启缓存功能和动态加载模块的功能
作用是生成Makefile文件,后面的make(编译)会根据这个文件里的要求去执行
[root@localhost httpd-2.4.9]# ./configure --prefix=/usr/local/apache9 --enable-so --enable-cache
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... no 缺包
configure: error: APR not found. Please read the documentation.
[root@localhost httpd-2.4.9]# vim INSTALL
[root@localhost httpd-2.4.9]#
=====
[root@vm-build apr-1.5.0]# make 缺make包
-bash: make: command not found
[root@vm-build apr-1.5.0]# yum install make
===
[root@teacher httpd-2.4.9# ./configure --prefix=/usr/local/apache9
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking build system type... i686-pc-linux-gnu
checking host system type... i686-pc-linux-gnu
checking target system type... i686-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 " -g -O2 -pthread"
setting CPPFLAGS to " -DLINUX=2 -D_REENTRANT -D_GNU_SOURCE -D_LARGEFILE64_SOURCE"
setting LDFLAGS to " "
configure:
configure: Configuring Apache Portable Runtime Utility library...
configure:
checking for APR-util... no 缺APR-util软件
configure: error: APR-util not found. Please read the documentation.
安装缺APR-util软件




(2) make 编译(是将c语言写的程序编译成二进制文件)

(3) make install (将编译好的二进制文件复制到相应的目录下)

=====

三,安装pcre的错误,及解决方法
source='pcrecpp.cc' object='pcrecpp.lo' libtool=yes \
DEPDIR=.deps depmode=none /bin/sh ./depcomp \
/bin/sh ./libtool --tag=CXX --mode=compile -DHAVE_CONFIG_H -I. -c -o pcrecpp.lo pcrecpp.cc
libtool: compile: unrecognized option `-DHAVE_CONFIG_H'
libtool: compile: Try `libtool --help' for more information.
make[1]: *** [pcrecpp.lo] 错误 1
make[1]: Leaving directory `/root/pcre-8.21'
make: *** [all] 错误 2
[root@wuhanVMware pcre-8.21]# yum install libtool 安装libtool软件
[root@wuhanVMware pcre-8.21]# yum instal gcc-c++* 安装gcc-c++相关的包
===

[root@vm-build httpd-2.4.9]# ./configure --prefix=/usr/local/apache9 --enabled-so --enable-cache 配置,指定安装路径
[root@vm-build httpd-2.4.9]#make ;make install 编译和编译安装

=========
A-->B--->C--->D
安装httpd-2.4.9版本
1.安装apr---》apr-utils------》pcre---》httpd-2.4.9
apr-1.5.0.tar.gz
apr-util-1.5.3.tar.gz
pcre-8.21.tar.bz2
httpd-2.4.9.tar.bz2
=====

四,httpd安装好后的使用
[root@vm-build bin]# ./apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for vm-build.sxkeji.com
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
[root@vm-build bin]# /usr/local/apache9/bin/apachectl start
AH00557: httpd: apr_sockaddr_info_get() failed for vm-build.sxkeji.com
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1. Set the 'ServerName' directive globally to suppress this message
httpd (pid 44056) already running
[root@vm-build bin]#
[root@vm-build apache9]# ls
bin cgi-bin error icons logs manual
build conf htdocs include man modules
[root@vm-build apache9]# cd conf
[root@vm-build conf]# ls
extra httpd.conf magic mime.types original

1关闭rpm的80端口
[root@vm-build conf]# vim httpd.conf
ServerName www.feng.com:80 去掉189行前面的注释,让服务器使用www.feng.com这个域名提供服务
fully qualified domain name (FQDN 完全符合要求的域名 www.baidu.com)
[root@vm-build conf]# /usr/local/apache9/bin/apachectl restart 重新启动服务
[root@vm-build conf]# /usr/local/apache9/bin/apachectl restart
[root@vm-build conf]# /usr/local/apache9/bin/apachectl stop 停止服务
[root@vm-build conf]# /usr/local/apache9/bin/apachectl start 启动服务
[root@vm-build conf]#

===
先停用rpm方式安装的httpd软件
[root@vm-build httpd-2.4.9]## service httpd stop
Stopping httpd: [ OK ]
[root@vm-build httpd-2.4.9]##
[root@vm-build httpd-2.4.9]## /usr/local/apache9/bin/apachectl stop
停止编译安装的httpd服务
[root@vm-build httpd-2.4.9]## /usr/local/apache9/bin/apachectl start
启动编译安装的httpd服务
===
2 清除防火墙规则
[root@vm-build conf]# iptables -F 作用就是让防火墙失效。
[root@vm-build conf]# ip add 查看服务器ip地址
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:24:a9:3d brd ff:ff:ff:ff:ff:ff
inet 10.0.0.133/16 brd 10.0.255.255 scope global eth0
inet6 fe80::20c:29ff:fe24:a93d/64 scope link
valid_lft forever preferred_lft forever
[root@vm-build conf]#

3 使用浏览器去访问 (firefox 、elinks)在firefox中输入ip地址10.0.0.99 或 10.0.0.199 或 10.0.0.191

====
4 简单制作网站
[root@teacher htdocs]# pwd
/usr/local/apache9/htdocs 真正存放网站的目录,你可以将网站存放在此
[root@teacher htdocs]# ls
index.html
[root@teacher htdocs]#
[root@teacher htdocs]# vim index.html 修改网站的首页文件
[root@teacher htdocs]# cat index.htm
====
(1)




注意图片dou.jpg存放在htdocs目录下
====
(2)




====
(3)





===
(4)
也可以在htdocs目录下新建文件夹download,存放些软件给其他人下载
访问路径为http://10.0.0.133/download





===

(5)最后的效果


内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息