设为首页 收藏本站
查看: 1066|回复: 0

[经验分享] 编译安装apache 2.4.12

[复制链接]

尚未签到

发表于 2018-11-21 11:28:23 | 显示全部楼层 |阅读模式
  一、环境
  系统:CentOS 6.4x64最小化安装

  IP:192.168.3.54

  

  二、下载软件包
  apache官网www.apache.org上有提供源码下载
[root@httpd ~]# wget http://mirrors.cnnic.cn/apache/httpd/httpd-2.4.12.tar.gz  三、安装

  解压并安装

[root@httpd ~]# tar xf httpd-2.4.12.tar.gz
[root@httpd ~]# cd httpd-2.4.12
[root@httpd httpd-2.4.12]# ./configure \
> --prefix=/usr/local/apache-2.4.12 \
> --enable-deflate \            #压缩
> --enable-expires \            #缓存
> --enable-headers \
> --enable-modules=most \
> --enable-so \
> --with-mpm=worker \            #worker模型
> --enable-rewrite \             #rewrite重写规则
> --with-apr=/usr/local/apr \
> --with-apr-util=/usr/local/apr-util
> --enable-ssl                    #支持ssl
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.
#结果显示我们需要安装apr apr-util,pcre-devel,openssl-devel
#下载apr和apr-util
[root@httpd ~]# wget http://mirrors.hust.edu.cn/apache//apr/apr-1.5.2.tar.gz
[root@httpd ~]# wget http://mirrors.hust.edu.cn/apache//apr/apr-util-1.5.4.tar.gz
#先安装pcre-devel,apr
[root@httpd httpd-2.4.12]# yum install pcre-devel  openssl-devel -y
[root@httpd ~]# tar xf apr-1.5.2.tar.gz
[root@httpd ~]# cd apr-1.5.2
[root@httpd apr-1.5.2]# ./configure --prefix=/usr/local/apr
[root@httpd apr-1.5.2]# make && make install
#安装apr-util
[root@httpd ~]# tar xf apr-util-1.5.4.tar.gz
[root@httpd ~]# cd apr-util-1.5.4
[root@httpd apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
[root@httpd apr-util-1.5.4]# make && make install
#再次安装httpd
[root@httpd httpd-2.4.12]# ./configure --prefix=/usr/local/apache-2.4.12 --enable-deflate --enable-expires --enable-headers --enable-modules=most --enable-so --with-mpm=worker --enable-rewrite --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
[root@httpd httpd-2.4.12]# make && make install  安装完成后,创建软连接,方便管理

[root@httpd ~]# ln -s /usr/local/apache-2.4.12/ /usr/local/apache  创建httpd启动脚本文件,httpd的启动脚本可以将/usr/local/apache/bin/apachectl复制到/etc/init.d目录下。这里我们选择手动创建启动脚本文件
[root@httpd ~]# vim /etc/init.d/httpd
#!/bin/bash
#
# Startup script for the Apache Web Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#              HTML files and CGI.
# processname: httpd
# pidfile: /usr/local/apache2/logs/httpd.pid
# config: /usr/local/apache2/conf/httpd.conf
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/httpd ]; then
        . /etc/sysconfig/httpd
fi
# This will prevent initlog from swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
INITLOG_ARGS=""
# Path to the apachectl script, server binary, and short-form for messages.
apachectl=/usr/local/apache/bin/apachectl
httpd=/usr/local/apache/bin/httpd
pid=$httpd/logs/httpd.pid
prog=httpd
RETVAL=0

# 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: "
        daemon $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
        echo -n $"Stopping $prog: "
        killproc $httpd
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
        echo -n $"Reloading $prog: "
        killproc $httpd -HUP
        RETVAL=$?
        echo
}
# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status $httpd
        RETVAL=$?
        ;;
  restart)
        stop
        start
        ;;
  condrestart)
        if [ -f $pid ] ; then
                stop
                start
        fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
        ;;
  *)
        echo $"Usage: $prog {start|stop|restart|condrestart|reload|status"
        echo $"|fullstatus|graceful|help|configtest}"
        exit 1
esac
exit $RETVAL
#启动httpd服务
root@httpd ~]# /etc/init.d/httpd start
Starting httpd: AH00557: httpd: apr_sockaddr_info_get() failed for httpd
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
                                                           [  OK  ]
#提示有FQDN错误,解决如下
[root@httpd ~]# echo "ServerName localhost:80" >>/usr/local/apache/conf/httpd.conf
#重新启动httpd服务
[root@httpd ~]# /etc/init.d/httpd stop
Stopping httpd:                                            [  OK  ]
[root@httpd ~]# /etc/init.d/httpd start
Starting httpd:                                            [  OK  ]
[root@httpd ~]# netstat -anpt |grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      59398/httpd  在客户端访问httpd服务

DSC0000.jpg

  

  通过以上步骤apache已成功安装,服务也正常启动,最后将httpd服务添加到开机自动启动

[root@httpd ~]# chkconfig --add httpd
[root@httpd ~]# chkconfig httpd on
[root@httpd ~]# chkconfig |grep http
httpd          0:off1:off2:on3:on4:on5:on6:off  





运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-637734-1-1.html 上篇帖子: CentOS5.4下安装和配置Apache、PHP、MySql、PHPMyAdmin 下篇帖子: centos配置apache+subversion
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表