httpd编译安装
Apache安装问题:configure: error: APR not found . Please read the documentation:
Linux上安装Apache时,编译出现错误:
- checking for APR... no
- configure: error: APR not found . Please read the documentation
安装APR,下载所需软件包,如果此时计算机可以上网,执行命令下载文件:
- wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz
- wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz
- wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip
apr not found问题
- tar -zxf apr-1.4.5.tar.gz
- cd apr-1.4.5
- ./configure --prefix=/usr/local/apr
- make && make install
APR-util not found问题
- tar -zxf apr-util-1.3.12.tar.gz
- cd apr-util-1.3.12
- ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
- make && make install
pcre问题
- unzip -o pcre-8.10.zip
- cd pcre-8.10
- ./configure --prefix=/usr/local/pcre
- make && make install
最后编译Apache时加上:
- --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
例如:
- ./configure --prefix=/usr/local/apache2 --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
================
- httpd编译安装
- ===========================================
- 官网:http://httpd.apache.org/
- 包:httpd-2.4.20.tar.bz2
- 注释:此处只考虑 2.4+ 的安装与配置,基于CentOS 6 和 CentOS 7。
- (1)环境准备。
- ~]# yum -y install gcc gcc-c++ apr-devel apr-util-devel pcre pcre-devel openssl openssl-devel
- ~]# tar -axf httpd-2.4.20.tar.bz2
- ~]# cd httpd-2.4.20/
- (2)注意事项。
- CentOS 6:注意事项
- apr 与 apr-util 官网下载地址:http://apr.apache.org/download.cgi
- 版本要求:
- (1) apr version >= 1.4+
- ~]# ./configure --prefix=/usr/local/apr
- ~]# make && make install
- (2) apr-util version >= 1.4+
- ~]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
- ~]# make && make install
- (3)编译安装。
- CentOS 6:
- ~]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=all --enable-mpms-shared=all --with-pcre --with-libxml2 --enable-cgi --with-mpm=prefork
- CentOS 7:
- ~]# ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-modules=all --enable-mpms-shared=all --with-pcre --with-libxml2 --enable-cgi --with-mpm=prefork
- ~]# make && make install
- 注释:
- (1)--enable-mods-shared=all --enable-mods-static=all 只能选择一个,选择了 shared 之后还可以选择部分 static。(非必选)
- (2) --enable-load-all-modules 开启所有的选项,不要使用,开启了所有的会存在一些冲突,当需要的时候手动开启即可。
- (2)--enable-cgi 为模块。--with-pcre --with-libxml2 为扩展。(非必选)
- (3)--with-mpm=prefork 指定默认工作模型。(非必选)
- (4)--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 为 CentOS 6 系统的依赖。(CentOS 6 必选)
- 查看编译了那些模块:
- ~]# ls /usr/local/httpd/modules
- 查看加载了那些模块:
- ~]# /usr/local/httpd/bin/httpd -M
- ===============================================
- 常用选项解释:
- Configuration:
- -h, --help 显示帮助文档并退出
- Installation directories:
- --prefix=PREFIX 指定安装路径
- Fine tuning of the installation directories:
- --sysconfdir=DIR 指定配置文件路径
- Optional Features:
- --enable-load-all-modules 开启所有的加载模块
- --enable-modules=MODULE-LIST 开启模块 | "all" |"most" | "few" | "none" | "reallyall"
- --enable-mods-shared=MODULE-LIST 共享模块 |"all" | "most" | "few" | "reallyall"
- --enable-mods-static=MODULE-LIST 静态模块 |"all" | "most" | "few" | "reallyall"
- --enable-ssl SSL/TLS :构建 https
- --enable-mpms-shared=MPM-LIST 共享模块 | "all"
- --enable-rewrite url 重写
- --enable-vhost-alias 虚拟主机
- --enable-proxy-fcgi FastCGI 模块
- --enable-so 允许运行时加载DSO模块
- Optional Packages:
- --with-apr=PATH prefix for installed APR or the full path to apr-config
- --with-apr-util=PATH prefix for installed APU or the full path to apu-config
- --with-mpm=MPM 指定apache默认工作模式:MPM={event|worker|prefork|winnt}
- --with-pcre=PATH perl语言兼容正则表达式)是一个用C语言编写的正则表达式函数库。
- --with-libxml2=PATH Libxml2 是一个xml c语言版的解析器,还支持c++、PHP、Pascal、Ruby、Tcl等语言的绑定
- ========================================================
- 系统服务,启动,库,环境变量等设置。
- (1)测试是否正常。
- 自带启动脚本:
- /usr/local/httpd/bin/apachectl (start | stop | restart | graceful | graceful-stop)
- 查看端口80是否被监听:
- ss -tnl
- (2)加入环境变量
- 临时生效:
- ~]# export PATH=/usr/local/httpd/bin:$PATH
- 永久生效:
- ~]# vim /etc/profile.d/httpd.sh
- export PATH=/usr/local/httpd/bin:$PATH
- ~]# source /etc/profile.d/httpd.sh
- 测试:(apachectl 现在是一个命令)
- ~]# apachectl (start | stop | restart | graceful | graceful-stop)
- (3)导出库文件:
- ~]# ln -s /usr/local/httpd/include /usr/include/httpd
- (4)导出man手册
- CentOS 6:
- ~]# vim /etc/man.config
- CentOS 7:
- ~]# vi /etc/man_db.conf
- 写入:
- MANPATH /usr/local/httpd/man
- (5)服务脚本文件
- CentOS 6:新加启动脚本。
- ~]# vi /etc/rc.d/init.d/httpd
- -------------------------------------start----------------------------------------------
- #!/bin/bash
- #
- # httpd Startup script for the Apache HTTP Server
- #
- # chkconfig: - 85 15
- # description: The Apache HTTP Server is an efficient and extensible \
- # server implementing the current HTTP standards.
- # processname: httpd
- # config: /etc/httpd/conf/httpd.conf
- # config: /etc/sysconfig/httpd
- # pidfile: /var/run/httpd/httpd.pid
- #
- ### BEGIN INIT INFO
- # Provides: httpd
- # Required-Start: $local_fs $remote_fs $network $named
- # Required-Stop: $local_fs $remote_fs $network
- # Should-Start: distcache
- # Short-Description: start and stop Apache HTTP Server
- # Description: The Apache HTTP Server is an extensible server
- # implementing the current HTTP standards.
- ### END INIT INFO
- # Source function library.
- . /etc/rc.d/init.d/functions
- if [ -f /etc/sysconfig/httpd ]; then
- . /etc/sysconfig/httpd
- fi
- # Start httpd 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/httpd.worker in /etc/sysconfig/httpd 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/httpd/bin/apachectl
- httpd=${HTTPD-/usr/local/httpd/bin/httpd}
- prog=httpd
- pidfile=${PIDFILE-/usr/local/httpd/logs/httpd.pid}
- lockfile=${LOCKFILE-/var/lock/subsys/httpd}
- RETVAL=0
- STOP_TIMEOUT=${STOP_TIMEOUT-10}
- # The semantics of these two functions differ from the way apachectl does
- # things -- attempting to start while running is a failure, and shutdown
- # when not running is also a failure. So we just do it the way init scripts
- # are expected to behave here.
- start() {
- echo -n $"Starting $prog: "
- LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && touch ${lockfile}
- return $RETVAL
- }
- # When stopping httpd, a delay (of default 10 second) is required
- # before SIGKILLing the httpd parent; this gives enough time for the
- # httpd parent to SIGKILL any errant children.
- stop() {
- echo -n $"Stopping $prog: "
- killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd
- RETVAL=$?
- echo
- [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
- }
- reload() {
- echo -n $"Reloading $prog: "
- if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then
- RETVAL=6
- echo $"not reloading due to configuration syntax error"
- failure $"not reloading $httpd due to configuration syntax error"
- else
- # Force LSB behaviour from killproc
- LSB=1 killproc -p ${pidfile} $httpd -HUP
- RETVAL=$?
- if [ $RETVAL -eq 7 ]; then
- failure $"httpd shutdown"
- fi
- fi
- echo
- }
- # See how we were called.
- case "$1" in
- start)
- start
- ;;
- stop)
- stop
- ;;
- status)
- status -p ${pidfile} $httpd
- RETVAL=$?
- ;;
- restart)
- stop
- start
- ;;
- condrestart|try-restart)
- if status -p ${pidfile} $httpd >&/dev/null; then
- stop
- start
- fi
- ;;
- force-reload|reload)
- reload
- ;;
- graceful|help|configtest|fullstatus)
- $apachectl $@
- RETVAL=$?
- ;;
- *)
- echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"
- RETVAL=2
- esac
- exit $RETVAL
- ---------------------------------------------------end------------------------------------------------
- CentOS 7 新加启动脚本:
- ~]# vi
- ---------------------------------------------------start------------------------------------------------
- ---------------------------------------------------end------------------------------------------------
- (6)开机启动
- CentOS 6:
- ~]# chkconfig --add httpd
- ~]# chkconfig --level 345 httpd on
- ~]# chkconfig --list httpd
- httpd 0:off 1:off 2:off 3:on 4:on 5:on 6:off
- CentOS 7:
- (7)系统启动与停止
- CentOS 6:
- service httpd (start | stop | restart)
- CentOS 7:
- systemctl (start | stop | restart) httpd.service
- (7)语法测试
- httpd -t
httpd编译安装的更多相关文章
- httpd编译安装php
wget http://hk1.php.net/distributions/php-5.6.31.tar.gz yum groupinstall "Development Tools&quo ...
- 编译安装HTTPD 2.4.9版本
编译安装HTTPD 2.4.9版本 服务脚本:/etc/rc.d/init.d/httpd 脚本配置文件路径:/etc/sysconfig/httpd 运行目录:/etc/httpd ...
- 把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理
把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理 1 编译安装httpd 把httpd编译安装在/app/httpd/目录下. 2 在/etc/rc.d/init ...
- 编译安装的httpd实现服务脚本,通过service和chkconfig进行管理
把编译安装的httpd 实现服务脚本,通过service和chkconfig 进行管理 1 编译安装httpd 把httpd编译安装在/app/httpd/目录下. 2 在/etc/rc.d/init ...
- LAMP环境之编译安装httpd服务
“Apache HTTP Server”是开源软件项目的杰出代表,它基于标准的 HTTP 网络协议提供网页浏览服务. 在配置 Apache 网站服务之前,需要正确安装好 httpd 服务器软件.htt ...
- 编译安装基于 fastcgi 模式的多虚拟主机的wordpress和discuz的LAMP架构
目录 实现CentOS 7 编译安装基于 fastcgi 模式的多虚拟主机的wordpress和discuz的LAMP架构 准备环境: 准备软件版本: 主机名修改用以区分 数据库服务器 实现数据库二进 ...
- 转-httpd 2.4.4 + mysql-5.5.28 + php-5.4.13编译安装过程
一.编译安装apache 1.解决依赖关系 httpd-2.4.4需要较新版本的apr和apr-util,因此需要事先对其进行升级.升级方式有两种,一种是通过源代码编译安装,一种是直接升级rpm包.这 ...
- CentOS 6.4源码编译安装httpd并启动测试
今天来总结一下在Linux中软件安装,通常我们应该知道,安装软件有两种方法:一种是软件包的安装,也就是rpm包的安装,就是指这些软件包都是 已经编译好的二进制rpm包,我们通过rpm安装工具和yum安 ...
- CentOS下编译安装Apache(httpd)
官网下载最新版本的apache, apr, apr-util http://httpd.apache.org/download.cgi#apache24 http://apr.apache.org/d ...
随机推荐
- supervisor初试
Supervisor (http://supervisord.org) 是一个用 Python 写的进程管理工具,可以很方便的用来启动.重启.关闭进程(不仅仅是 Python 进程).除了对单个进程的 ...
- 20145326蔡馨熠 实验三 "敏捷开发与XP实践"
20145326蔡馨熠 实验三 "敏捷开发与XP实践" 程序设计过程 一.实验内容 使用 git 上传代码 使用 git 相互更改代码 实现代码的重载 1.git上传代码 首先我通 ...
- calcite介绍
前言 calcite是一个可以将任意数据查询转换成基于sql查询的引擎,引擎特性也有很多,比如支持sql树的解析,udf的扩展,sql执行优化器的扩展等等.目前已经被很多顶级apache项目引用,比如 ...
- shell 判断字符串长度是否不为0
test.sh #!/bin/bash s1="" if test $s1 ;then echo "length is not zero" else echo ...
- json.dump()和json.load()
import json,time # save data to json file def store(data): with open('data.json', 'w') as fw: # 将字典转 ...
- JVM知识总结-运行时区域划分
区域简介 JVM运行时区域有些随着虚拟机进程的启动而存在,有些依赖于用户线程的启动和结束而建立和销毁,大致分为以下几类:方法区,虚拟机栈,本地方法栈,堆,程序计数器,概念图如下(源于<深入理解J ...
- android平台蓝牙编程
Android平台支持蓝牙网络协议栈,实现蓝牙设备之间数据的无线传输. 本文档描述了怎样利用android平台提供的蓝牙API去实现蓝牙设备之间的通信,蓝牙设备之间的通信主要包括了四个步骤:设置蓝牙设 ...
- 原生js实现ajax的文件异步提交功能、图片预览功能.实例
采用html5使得选择图片改变时,预览框中图片随之改变.input文件选择框美化.原生js完成文件异步提交 效果图: 代码如下,可直接复制并保存为html文件打开查看效果 <html> & ...
- tp5集成淘宝,微信,网易,新浪等第三方登录
tp5集成淘宝,微信,网易,新浪等第三方登录 一.总结 一句话总结: 接口 链接 实现的话就是这些平台给的一个接口(链接),你通过这些接口登录进去之后,它会给你返回用户名,头像之类的信息,我们的网站存 ...
- zentaoPHP框架是做什么的(整理)
zentaoPHP框架是做什么的(整理) 一.总结 一句话总结:应该是主要用作项目管理的(暂时没用过) 项目管理 看了下面的两篇资料,感觉没啥特色 看了文件目录结构,感觉就是一个标准的mvc框架 看了 ...