孤独雪鹰 发表于 2018-11-19 12:53:47

编译安装apache-11624315

  CentOS 下编译安装Apache
  卸载原有的apache
  首先从 http://httpd.apache.or 下载apache源码包httpd-2.4.4.tar.gz
  然后从 http://apr.apache.org 下载apr-1.4.6.tar.gz和apr-util-1.5.1.tar.gz
  然后从 http://sourceforge.net/ 下载pcre-8.32.tar.gz和pcre-devel-8.32.tar.gz
  先装gcc和make
  yum -y install gcc
  yum -y install make
  yum -y install gcc-c++ 没有这个gcc-c++一会编译不prce
  切到下载好的源码包目录,本人是~/Download
  安装apr:
  tar -zvxf apr-1.4.6.tar.gz
  cd apr-1.4.6
  ./configure --prefix=/usr/local/apr
  make && make install
  安装apr-util
  tar -zvxf apr-util-1.5.1.tar.gz
  cd apr-util-1.5.1
  ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
  make && make install
  安装pcre
  tar -zvxf pcre-8.32.tar.gz
  cd pcre-8.32
  ./configure
  make && make install
  安装pcre-devel
  如果已经安装好了pcre 一定要安装
  tar –zxvf pcre-devel-8.32.tar.gz
  cd pcre-devel-8.32
  ./configure
  make && make install
  安装apache 一定要先装上面那三个不然编译不了
  tar -zvxf httpd-2.4.4.tar.gz
  cd httpd-2.4.4
  ./configure --prefix=/usr/local/apache –with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util
  make && make install
  配置/usr/local/apache/conf下的http.conf文件(先备份)。
  1、服务器
  #ServerName www.example.com:80 前的#号删除。
  2、目录访问权限
  
  Options FollowSymLinks
  AllowOverride None
  Order deny,allow
  Allow from all #修改为此样
  
  3、默认字符集
  AddDefaultCharset utf-8 #指定默认字符集
  4、启动httpd
  cd bin/
  ./apachectl start | restart | stop
  将httpd添加为系统服务
  cp apachectl /etc/init.d/httpd
  /etc/init.d/
  编辑httpd,在第二行加入如下信息:
  # chkconfig: 345 85 15
  # description: Activates/Deactivates Apache Web Server
  以上两句必须添加,否则会提示“httpd服务不支持”;第一行3个数字参数意义分别为:哪些Linux级别需要启动httpd(3,4,5);启动序号(85);关闭序号(15)。
  添加启动信息(Ubuntu与CentOS有区别)
  chkconfig –add httpd
  查看是否添加成功
  chkconfig --list
  服务器控制
  service httpd start | restart | stop

页: [1]
查看完整版本: 编译安装apache-11624315