冰恋 发表于 2018-11-21 12:29:37

构建Apache WEB服务器三部曲之一 源码安装

        Apache是世界使用排名第一的Web服务器软件。它可以运行在几乎所有广泛使用的计算机平台上,由于其跨平台和安全性被广泛使用,是最流行的Web服务器端软件之一。下图为
  全球主流Web服务器份额:

  
  Apache工作模式有多种,其中最常用的有两种:
      Prefork模式:PreforkMPM 使用多个子进程,每个子进程只有一个线程。每个进程在某个确定的时间只能维持一个连接。
      在大多数平台上,Prefork MPM在效率上要比Worker MPM要高,但是内存使用大得多。prefork的无线程设计在某些情况下将比worker更有优势:它可以使用那些没有处理好线程安全的第三方模块,并且对于那些线程调试困难的平台而言,它也更容易调试一些。
      Worker模式:WorkerMPM 使用多个子进程,每个子进程有多个线程。每个线程在某个确定的时间只能维持一个连接。通常来说,在一个高流量的HTTP服务器上,Worker MPM是个比较好的选择,因为Worker MPM的内存使用比Prefork MPM要低得多。
Worker MPM也由不完善的地方,如果一个线程崩溃,整个进程就会连同其所有线程一起"死掉".由于线程共享内存空间,所以一个程序在运行时必须被系统识别为"每个线程都是安全的"。
  环境:
  CentOS 6.5 x86_64
  Server IP:192.168.1.2
  安装Apache服务器
  http://apache.dataguru.cn/httpd/httpd-2.2.27.tar.gz
  安装之前需要安装 gcc、apr、apr-util
  
# cd /software/
# ls
httpd-2.2.27.tar.gz
# tar -zxf httpd-2.2.27.tar.gz
# ls
httpd-2.2.27 httpd-2.2.27.tar.gz
#
./configure --prefix=/usr/local/apache2 &&make && make install
# echo $?
0
启动Apache服务
# /usr/local/apache2/bin/apachectlstart
httpd: apr_sockaddr_info_get() failed for jacken
httpd: Could not reliably determine the server'sfully qualified domain name, using 127.0.0.1 for ServerName  
  
  之所以启动Apache的时候报
  httpd: apr_sockaddr_info_get() failed for jacken
  httpd: Could not reliably determine the server'sfully qualified domain name, using 127.0.0.1 for ServerName
  这不能属于一个错误,因为这个不影响服务的正常运行,但我看着就是不爽。
  原因:这个问题应该是没有在 httpd.conf 中设定 ServerName
  解决办法:
  
# vim /usr/local/apache2/conf/httpd.conf
# cat/usr/local/apache2/conf/httpd.conf | grep ^ServerName
ServerName localhost:80
# /usr/local/apache2/bin/apachectlstop
# /usr/local/apache2/bin/apachectlstart
#
# netstat -ntl | grep 80
tcp       0      0 :::80                     :::*                        LISTEN      
#  Apache安装成功。
  添加自启动脚本

  
# cp -p/usr/local/apache2/bin/apachectl /etc/init.d/httpd
# vim /etc/init.d/httpd
在文件头部加入如下内容
###
# Comments to support chkconfig on RedHatLinux
# chkconfig: 2345 90 90
# description:http server
###
# chkconfig --add httpd
# chkconfig --level 35httpd on
# chkconfig | grep httpd
httpd            0:off1:off2:on3:on4:on5:on6:off
# /etc/init.d/httpd stop
# /etc/init.d/httpd start
# /etc/init.d/httpd status
#  




页: [1]
查看完整版本: 构建Apache WEB服务器三部曲之一 源码安装