zoukankan      html  css  js  c++  java
  • httpd编译安装

    Apache安装问题:configure: error: APR not found . Please read the documentation:

    Linux上安装Apache时,编译出现错误: 

    Java代码  收藏代码
    1. checking for APR... no  
    2. configure: error: APR not found .  Please read the documentation  

    安装APR,下载所需软件包,如果此时计算机可以上网,执行命令下载文件:

    Java代码  收藏代码
    1. wget http://archive.apache.org/dist/apr/apr-1.4.5.tar.gz  
    2. wget http://archive.apache.org/dist/apr/apr-util-1.3.12.tar.gz  
    3. wget http://jaist.dl.sourceforge.net/project/pcre/pcre/8.10/pcre-8.10.zip  

    apr not found问题

    Java代码  收藏代码
    1. tar -zxf apr-1.4.5.tar.gz  
    2. cd  apr-1.4.5  
    3. ./configure --prefix=/usr/local/apr  
    4. make && make install  

    APR-util not found问题

    Java代码  收藏代码
    1. tar -zxf apr-util-1.3.12.tar.gz  
    2. cd apr-util-1.3.12  
    3. ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config  
    4. make && make install  

    pcre问题

    Java代码  收藏代码
    1. unzip -o pcre-8.10.zip  
    2. cd pcre-8.10  
    3. ./configure --prefix=/usr/local/pcre  
    4. make && make install  

    最后编译Apache时加上:

    Java代码  收藏代码
    1. --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre  

     
    例如:

    Java代码  收藏代码
    1. ./configure --prefix=/usr/local/apache2 --enable-so --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre  

    ================

    1. httpd编译安装  
    2. ===========================================  
    3. 官网:http://httpd.apache.org/  
    4. 包:httpd-2.4.20.tar.bz2     
    5. 注释:此处只考虑 2.4+ 的安装与配置,基于CentOS 6 和 CentOS 7。  
    6.   
    7. (1)环境准备。  
    8.     ~]# yum -y install gcc gcc-c++ apr-devel apr-util-devel pcre pcre-devel openssl openssl-devel  
    9.     ~]# tar -axf httpd-2.4.20.tar.bz2  
    10.     ~]# cd httpd-2.4.20/  
    11.   
    12. (2)注意事项。  
    13.     CentOS 6:注意事项  
    14.         apr 与 apr-util 官网下载地址:http://apr.apache.org/download.cgi  
    15.         版本要求:  
    16.             (1) apr             version >= 1.4+  
    17.                 ~]# ./configure  --prefix=/usr/local/apr  
    18.                 ~]# make && make install  
    19.   
    20.             (2) apr-util        version >= 1.4+  
    21.                 ~]# ./configure  --prefix=/usr/local/apr-util  --with-apr=/usr/local/apr  
    22.                 ~]# make && make install  
    23.   
    24. (3)编译安装。  
    25.     CentOS 6:  
    26.             ~]# ./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  
    27.     CentOS 7:  
    28.             ~]#   ./configure --prefix=/usr/local/httpd --sysconfdir=/etc/httpd --enable-modules=all --enable-mpms-shared=all --with-pcre --with-libxml2 --enable-cgi  --with-mpm=prefork  
    29.   
    30.     ~]# make && make install  
    31.   
    32.     注释:  
    33.         (1)--enable-mods-shared=all --enable-mods-static=all 只能选择一个,选择了 shared 之后还可以选择部分 static。(非必选)  
    34.         (2) --enable-load-all-modules 开启所有的选项,不要使用,开启了所有的会存在一些冲突,当需要的时候手动开启即可。  
    35.         (2)--enable-cgi 为模块。--with-pcre --with-libxml2 为扩展。(非必选)  
    36.         (3)--with-mpm=prefork 指定默认工作模型。(非必选)  
    37.         (4)--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util  为 CentOS 6 系统的依赖。(CentOS 6 必选)  
    38.   
    39.     查看编译了那些模块:  
    40.             ~]# ls /usr/local/httpd/modules  
    41.   
    42.     查看加载了那些模块:  
    43.             ~]# /usr/local/httpd/bin/httpd -M  
    44. ===============================================  
    45. 常用选项解释:  
    46. Configuration:  
    47.     -h, --help             显示帮助文档并退出  
    48.   
    49. Installation directories:  
    50.   --prefix=PREFIX         指定安装路径  
    51.   
    52. Fine tuning of the installation directories:  
    53.     --sysconfdir=DIR        指定配置文件路径  
    54.   
    55. Optional Features:  
    56.   --enable-load-all-modules     开启所有的加载模块  
    57.   --enable-modules=MODULE-LIST  开启模块 | "all" |"most" | "few" | "none" | "reallyall"  
    58.   --enable-mods-shared=MODULE-LIST    共享模块 |"all" | "most" | "few" | "reallyall"  
    59.   --enable-mods-static=MODULE-LIST   静态模块 |"all" | "most" | "few" | "reallyall"  
    60.   --enable-ssl            SSL/TLS :构建 https  
    61.   --enable-mpms-shared=MPM-LIST    共享模块 | "all"  
    62.   --enable-rewrite        url 重写  
    63.   --enable-vhost-alias    虚拟主机  
    64.   --enable-proxy-fcgi     FastCGI 模块  
    65.   --enable-so            允许运行时加载DSO模块  
    66.   
    67. Optional Packages:  
    68.     --with-apr=PATH         prefix for installed APR or the full path to apr-config  
    69.     --with-apr-util=PATH    prefix for installed APU or the full path to  apu-config  
    70.     --with-mpm=MPM        指定apache默认工作模式:MPM={event|worker|prefork|winnt}  
    71.     --with-pcre=PATH        perl语言兼容正则表达式)是一个用C语言编写的正则表达式函数库。  
    72.     --with-libxml2=PATH     Libxml2 是一个xml c语言版的解析器,还支持c++、PHP、Pascal、Ruby、Tcl等语言的绑定  
    73.   
    74. ========================================================  
    75. 系统服务,启动,库,环境变量等设置。  
    76.   
    77. (1)测试是否正常。  
    78.         自带启动脚本:  
    79.             /usr/local/httpd/bin/apachectl (start | stop | restart | graceful | graceful-stop)  
    80.         查看端口80是否被监听:  
    81.             ss -tnl  
    82.   
    83. (2)加入环境变量  
    84.     临时生效:  
    85.         ~]# export PATH=/usr/local/httpd/bin:$PATH  
    86.   
    87.     永久生效:  
    88.         ~]# vim /etc/profile.d/httpd.sh  
    89.            export PATH=/usr/local/httpd/bin:$PATH  
    90.         ~]# source /etc/profile.d/httpd.sh  
    91.   
    92.     测试:(apachectl 现在是一个命令)  
    93.         ~]# apachectl (start | stop | restart | graceful | graceful-stop)  
    94.   
    95. (3)导出库文件:  
    96.         ~]# ln -s /usr/local/httpd/include /usr/include/httpd  
    97.   
    98. (4)导出man手册  
    99.     CentOS 6:  
    100.         ~]# vim /etc/man.config  
    101.     CentOS 7:  
    102.         ~]# vi /etc/man_db.conf  
    103.   
    104.     写入:  
    105.         MANPATH /usr/local/httpd/man  
    106.   
    107.   
    108. (5)服务脚本文件  
    109.     CentOS 6:新加启动脚本。  
    110. ~]# vi /etc/rc.d/init.d/httpd  
    111. -------------------------------------start----------------------------------------------  
    112. #!/bin/bash  
    113. #  
    114. # httpd        Startup script for the Apache HTTP Server  
    115. #  
    116. # chkconfig: - 85 15  
    117. # description: The Apache HTTP Server is an efficient and extensible    
    118. #          server implementing the current HTTP standards.  
    119. # processname: httpd  
    120. # config: /etc/httpd/conf/httpd.conf  
    121. # config: /etc/sysconfig/httpd  
    122. # pidfile: /var/run/httpd/httpd.pid  
    123. #  
    124. ### BEGIN INIT INFO  
    125. # Provides: httpd  
    126. # Required-Start: $local_fs $remote_fs $network $named  
    127. # Required-Stop: $local_fs $remote_fs $network  
    128. # Should-Start: distcache  
    129. # Short-Description: start and stop Apache HTTP Server  
    130. # Description: The Apache HTTP Server is an extensible server   
    131. #  implementing the current HTTP standards.  
    132. ### END INIT INFO  
    133.   
    134. # Source function library.  
    135. . /etc/rc.d/init.d/functions  
    136.   
    137. if [ -f /etc/sysconfig/httpd ]; then  
    138.         . /etc/sysconfig/httpd  
    139. fi  
    140.   
    141. # Start httpd in the C locale by default.  
    142. HTTPD_LANG=${HTTPD_LANG-"C"}  
    143.   
    144. # This will prevent initlog from swallowing up a pass-phrase prompt if  
    145. # mod_ssl needs a pass-phrase from the user.  
    146. INITLOG_ARGS=""  
    147.   
    148. # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server  
    149. # with the thread-based "worker" MPM; BE WARNED that some modules may not  
    150. # work correctly with a thread-based MPM; notably PHP will refuse to start.  
    151.   
    152. # Path to the apachectl script, server binary, and short-form for messages.  
    153. apachectl=/usr/local/httpd/bin/apachectl  
    154. httpd=${HTTPD-/usr/local/httpd/bin/httpd}  
    155. prog=httpd  
    156. pidfile=${PIDFILE-/usr/local/httpd/logs/httpd.pid}  
    157. lockfile=${LOCKFILE-/var/lock/subsys/httpd}  
    158. RETVAL=0  
    159. STOP_TIMEOUT=${STOP_TIMEOUT-10}  
    160.   
    161. # The semantics of these two functions differ from the way apachectl does  
    162. # things -- attempting to start while running is a failure, and shutdown  
    163. # when not running is also a failure.  So we just do it the way init scripts  
    164. # are expected to behave here.  
    165. start() {  
    166.         echo -n $"Starting $prog: "  
    167.         LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS  
    168.         RETVAL=$?  
    169.         echo  
    170.         [ $RETVAL = 0 ] && touch ${lockfile}  
    171.         return $RETVAL  
    172. }  
    173.   
    174. # When stopping httpd, a delay (of default 10 second) is required  
    175. # before SIGKILLing the httpd parent; this gives enough time for the  
    176. # httpd parent to SIGKILL any errant children.  
    177. stop() {  
    178.     echo -n $"Stopping $prog: "  
    179.     killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd  
    180.     RETVAL=$?  
    181.     echo  
    182.     [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}  
    183. }  
    184. reload() {  
    185.     echo -n $"Reloading $prog: "  
    186.     if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then  
    187.         RETVAL=6  
    188.         echo $"not reloading due to configuration syntax error"  
    189.         failure $"not reloading $httpd due to configuration syntax error"  
    190.     else  
    191.         # Force LSB behaviour from killproc  
    192.         LSB=1 killproc -p ${pidfile} $httpd -HUP  
    193.         RETVAL=$?  
    194.         if [ $RETVAL -eq 7 ]; then  
    195.             failure $"httpd shutdown"  
    196.         fi  
    197.     fi  
    198.     echo  
    199. }  
    200.   
    201. # See how we were called.  
    202. case "$1" in  
    203.   start)  
    204.     start  
    205.     ;;  
    206.   stop)  
    207.     stop  
    208.     ;;  
    209.   status)  
    210.         status -p ${pidfile} $httpd  
    211.     RETVAL=$?  
    212.     ;;  
    213.   restart)  
    214.     stop  
    215.     start  
    216.     ;;  
    217.   condrestart|try-restart)  
    218.     if status -p ${pidfile} $httpd >&/dev/null; then  
    219.         stop  
    220.         start  
    221.     fi  
    222.     ;;  
    223.   force-reload|reload)  
    224.         reload  
    225.     ;;  
    226.   graceful|help|configtest|fullstatus)  
    227.     $apachectl $@  
    228.     RETVAL=$?  
    229.     ;;  
    230.   *)  
    231.     echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"  
    232.     RETVAL=2  
    233. esac  
    234.   
    235. exit $RETVAL  
    236. ---------------------------------------------------end------------------------------------------------  
    237.   
    238.   
    239. CentOS 7 新加启动脚本:  
    240. ~]# vi   
    241. ---------------------------------------------------start------------------------------------------------  
    242.   
    243. ---------------------------------------------------end------------------------------------------------  
    244.   
    245.   
    246. (6)开机启动  
    247. CentOS 6:  
    248.     ~]# chkconfig --add httpd  
    249.     ~]# chkconfig --level 345 httpd on  
    250.     ~]# chkconfig --list httpd  
    251.         httpd          0:off   1:off   2:off   3:on    4:on    5:on    6:off  
    252.   
    253. CentOS 7:  
    254.       
    255.   
    256. (7)系统启动与停止  
    257.     CentOS 6:  
    258.         service httpd (start | stop | restart)  
    259.     CentOS 7:  
    260.         systemctl (start | stop | restart) httpd.service  
    261.   
    262. (7)语法测试  
    263.     httpd -t  
  • 相关阅读:
    docker 部署aps.net MVC到windows容器
    docker 搭建私有仓库 harbor
    解决关于:Oracle数据库 插入数据中文乱码 显示问号???
    ionic cordova build android error: commamd failed with exit code eacces
    cordova build android Command failed with exit code EACCES
    Xcode 10 iOS12 "A valid provisioning profile for this executable was not found
    使用remix发布部署 发币 智能合约
    区块链: 编译发布智能合约
    mac 下常用命令备忘录
    JQuery fullCalendar 时间差 排序获取距当前最近的时间。
  • 原文地址:https://www.cnblogs.com/moss_tan_jun/p/6597643.html
Copyright © 2011-2022 走看看