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

[经验分享] 基于Centos6.2的Apache2.4.2编译安装

[复制链接]

尚未签到

发表于 2018-11-25 14:45:07 | 显示全部楼层 |阅读模式
Apache,目前世界排名第一的web服务器,虽说nginx发展迅猛,但是在一段时间以内还是很难撼动Apache的老大地位的,一直以来都是yum安装,方便,快速,但是不够灵活,所以花了点时间编译安装体验一把,遂记录之,留作以后存档参考
截止2012819日,Apache的最新版本是2.4.2,而编译安装Apache所需的aprapr-util的最新版本分别是apr-1.4.6.tar.gzapr-util-1.4.1.tar.gz
1、首先安装Apache所需的gcc,一般我们配好yum源,直接yum –y install gcc即可
[root@centos6 ~]# yum install gcc
Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
…………..
…………..
Installed:
  gcc.x86_64 0:4.4.6-4.el6

Dependency Installed:
  cloog-ppl.x86_64 0:0.15.7-1.2.el6              cpp.x86_64 0:4.4.6-4.el6      glibc-devel.x86_64 0:2.12-1.80.el6_3.4     glibc-headers.x86_64 0:2.12-1.80.el6_3.4
  kernel-headers.x86_64 0:2.6.32-279.5.1.el6     mpfr.x86_64 0:2.4.1-6.el6     ppl.x86_64 0:0.10.2-11.el6

Dependency Updated:
glibc.x86_64 0:2.12-1.80.el6_3.4          glibc-common.x86_64 0:2.12-1.80.el6_3.4          libgcc.x86_64 0:4.4.6-4.el6          libgomp.x86_64 0:4.4.6-4.el6

Complete!
2、下载所需的软件包
[root@centos6 src]# pwd
/usr/local/src
[root@centos6 src]# wget http://mirror.bit.edu.cn/apache/httpd/httpd-2.4.2.tar.gz
[root@centos6 src]# wget http://mirror.bit.edu.cn/apache/apr/apr-util-1.4.1.tar.gz
[root@centos6 src]# wget http://mirror.bit.edu.cn/apache/apr/apr-1.4.6.tar.gz
[root@centos6 src]# ls
apr-1.4.6.tar.gz  apr-util-1.4.1.tar.gz  httpd-2.4.2.tar.gz
3、开始编译安装
3.1 首先编译安装apr-1.4.6
tar zxf apr-1.4.6.tar.gz
   42  cd apr-1.4.6
   43  mkdir /usr/local/apr-1.4.6
   44  ./configure --prefix=/usr/local/apr-1.4.6/
   45  make
   46  make install
   47  history
3.2 编译安装apr-util-1.4.1
mkdir /usr/local/apr-util-1.4.1
   49  cd -
   50  tar zxf apr-util-1.4.1.tar.gz
   51  cd apr-util-1.4.1
   52  ./configure --prefix=/usr/local/apr-util-1.4.1/  -with-apr=/usr/local/apr-1.4.6/bin/apr-1-config
   53  make
   54  make install
3.3 编译安装Apache2.4.2
[root@centos6        httpd-2.4.2]#./configure \
--prefix=/usr/local/httpd-2.4.2/ \
-with-apr=/usr/local/apr-1.4.6/ \
-with-apr-util=/usr/local/apr-util-1.4.1/
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

Configuring Apache Portable Runtime library ...

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"
  setting LDFLAGS to " "

Configuring Apache Portable Runtime Utility library...

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... false
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/

解决安装pcre,目前pcre最新版本是pcre-8.31,去http://pcre.org下载
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
winscp拷贝到Centos6.2/usr/local/src
unzip -o pcre-8.31.zip
   65  ls
   66  cd pcre-8.31
   67  ls
   68  mkdir /usr/local/pcre-8.31
   69  ./configure --prefix=/usr/local/pcre-8.31/
   70  make—编译失败,因为前边只安装了gcc,没有安装gcc++等软件包
   71  yum install gcc gcc-c++ gcc-g77
   72  ./configure --prefix=/usr/local/pcre-8.31/
   73  make
   74  make install
OK!编译安装成功,再次编译安装Apache2.4.2
cd /usr/local/src/httpd-2.4.2
   77  ./configure --prefix=/usr/local/httpd-2.4.2/ -with-apr=/usr/local/apr-1.4.6/ -with-apr-util=/usr/local/apr-util-1.4.1/ -with-pcre=/usr/local/pcre-8.31/
   78  make
   79  make install
   80  cd ../..
   81  ln -s httpd-2.4.2 apache2

Usage: /usr/local/httpd-2.4.2//bin/httpd [-D name] [-d directory] [-f file]
                                         [-C "directive"] [-c "directive"]
                                         [-k start|restart|graceful|graceful-stop|stop]
                                         [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
Options:
  -D name         : define a name for use in  directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"      : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules
  -M                 : a synonym for -t -D DUMP_MODULES
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check
  -X                 : debug mode (only one worker, do not detach)
查看版本及启动服务
[root@centos6 local]# /usr/local/apache2/bin/apachectl -v
Server version: Apache/2.4.2 (Unix)
Server built:   Aug 19 2012 10:39:28
[root@centos6 local]# /usr/local/apache2/bin/apachectl --help
AH00557: httpd: apr_sockaddr_info_get() failed for centos6.2
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@centos6 local]# ps -ef | grep httpd
root     27732     1  0 10:48 ?        00:00:00 /usr/local/httpd-2.4.2//bin/httpd --help
daemon   27733 27732  0 10:48 ?        00:00:00 /usr/local/httpd-2.4.2//bin/httpd --help
daemon   27734 27732  0 10:48 ?        00:00:00 /usr/local/httpd-2.4.2//bin/httpd --help
daemon   27735 27732  0 10:48 ?        00:00:00 /usr/local/httpd-2.4.2//bin/httpd --help
root     27859 24392  0 10:56 pts/0    00:00:00 grep httpd

先把进程kill
[root@centos6 local]# ps -ef | grep httpd | awk '{print $2}'| while read line
> do
> kill -9 $line
> done
然后,再修改下配置文件vim /usr/local/apache2/conf/httpd.conf,将ServerName前的“#”去掉~~
再次重启服务
[root@centos6 local]# /usr/local/apache2/bin/apachectl -k start
[root@centos6 local]#
OK!没报错
检查一下
[root@centos6 ~]# netstat -lnt | grep 80
tcp       0      0 :::80                       :::*                        LISTEN
[root@centos6 ~]# lsof -i tcp:80
COMMAND  PID   USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
httpd   1911   root    4u  IPv6  14787      0t0  TCP *:http (LISTEN)
httpd   1912 daemon    4u  IPv6  14787      0t0  TCP *:http (LISTEN)
httpd   1913 daemon    4u  IPv6  14787      0t0  TCP *:http (LISTEN)
httpd   1942 daemon    4u  IPv6  14787      0t0  TCP *:http (LISTEN)
把防火墙和selinux关掉
浏览器访问
http://file:///C:UsersJIAXIN~1AppDataLocalTempmsohtmlclip11clip_image002.jpg
至此,编译安装成功!
后续会继续写下web优化类的文章!

本人水平优先,如有错误之处,请提出更正,共同学习,共同进步,谢谢!




运维网声明 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-639492-1-1.html 上篇帖子: 查看apache连接数 下篇帖子: Webbech比Apache自带的ab压力测试工具好
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

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

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

扫描微信二维码查看详情

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


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


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


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



合作伙伴: 青云cloud

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