ouzhoudijie 发表于 2018-11-20 07:32:46

Apache 简单实践

  # uname -rm          #检查内核版本
  2.6.32-358.el6.x86_64 x86_64
  # cat /etc/redhat-release#查看发行版本
  CentOS release 6.4 (Final)
  # rpm -qa gcc gcc-c++ #检查是否安装编译工具
  gcc-c++-4.4.7-3.el6.x86_64
  gcc-4.4.7-3.el6.x86_64
  # yum isntall gcc gcc-c++ -y #如未安装编译工具,就使用Yum安装
  #wget http://mirrors.aliyun.com/apache/httpd/httpd-2.2.31.tar.gz#下载apache
  #tar xf httpd-2.2.31.tar.gz #解压
  #cd httpd-2.2.31 #进入解压目录
  #./configure --prefix=/application/apache \#编译
  > --enable-deflate \
  > --enable-expires \
  > --enable-headers \
  > --enable-modules=most \
  > --enable-so \
  > --with-mpm=worker \
  > --enable-rewrite
  # make && make install
  # ln -s /application/apache2.2.31/ /application/apache #创建一个软连接
  #mkdir /var/html/{www,bbs} -p #准备测试html
  #for name in wwwbbs;do echo "http://$name.rosedata.com" >/var/html/$name/index.html;done
  # /application/apache/bin/apachectl start#启动apache服务
  httpd: apr_sockaddr_info_get() failed for client132
  httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  #这个报错暂时不用理会,编辑apache配置文件之后就会修正
  # vim /application/apache/conf/httpd.conf#修改配置文件

  Include conf/extra/httpd-mpm.conf
  Include conf/extra/httpd-vhosts.conf
  Include conf/extra/httpd-default.conf
  ServerName 127.0.0.1
  
  Options -Indexes FollowSymLinks
  AllowOverride None
  Order allow,deny
  Allow from all
  
  # vim /application/apache/conf/extra/httpd-vhosts.conf#编辑虚拟主机(基于域名访问)
  
  ServerAdmin webmaster@dummy-host.example.com
  DocumentRoot "/var/html/www"    #
  ServerNamewww.rosedata.com
  ServerAlias rosedata.com
  ErrorLog "logs/dummy-host.example.com-error_log"
  CustomLog "logs/dummy-host.example.com-access_log" common
  
  
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot "/var/html/bbs"
  ServerName bbs.rosedata.com
  ErrorLog "logs/dummy-host2.example.com-error_log"
  CustomLog "logs/dummy-host2.example.com-access_log" common
  
  #下载安装cronolog-1.6.2.tar.gz
  #tar xf cronolog-1.6.2.tar.gz
  #cd cronolog-1.6.2
  #./configure
  #make && make install
  

  # vim /application/apache/conf/extra/httpd-vhosts.conf#编辑修改log配置
  ErrorLog "|/usr/local/sbin/cronolog logs/wwww-error_%Y%m%d.log"
  CustomLog "|/usr/local/sbin/cronolog /application/apache/logs/www-access_%Y%m%d.log" combined
  # /application/apache/bin/apachectl graceful #平滑重启

  #在windows 主机上修改hosts文件
  #C:\Windows\System32\drivers\etc\hosts
  192.168.234.131 www.rosedata.com bbs.rosedata.com
  # more /application/apache/logs/www-access_20160525.log#查看访问log
  # awk '{print $1}' /app/logs/www-access_20140525.log |sort|uniq -c|sort -rn #对访问IP统计排序
  # vim include/ap_release.h#编辑该文件可以修改响应请求中的信息,但是需要在编译之前修改
  #define AP_SERVER_BASEVENDOR "Apache Software Foundation"
  #define AP_SERVER_BASEPROJECT "Apache HTTP Server"
  #define AP_SERVER_BASEPRODUCT "Apache"
  #define AP_SERVER_MAJORVERSION_NUMBER 2
  #define AP_SERVER_MINORVERSION_NUMBER 2
  #define AP_SERVER_PATCHLEVEL_NUMBER   31
  #define AP_SERVER_DEVBUILD_BOOLEAN    0
  




页: [1]
查看完整版本: Apache 简单实践