centos6.5&7源码包安装apache

简单介绍下源码包安装apache

1. 下载包及依赖包

  • wget http://mirrors.hust.edu.cn/apache//httpd/httpd-2.4.25.tar.gz
  • wget http://mirrors.cnnic.cn/apache//apr/apr-1.5.2.tar.gz
  • wget http://mirrors.cnnic.cn/apache//apr/apr-util-1.5.4.tar.gz
  • wget http://downloads.sourceforge.net/project/pcre/pcre/8.39/pcre-8.39.tar.gz

2. 安装apr

  • sudo mkdir /usr/local/apache/apr
  • tar -zxvf apr-1.5.2.tar.gz
  • cd apr-1.5.2
  • ./configure --prefix=/usr/local/apache/apr/
  • sudo make
  • sudo make install

3. 安装apr-util

  • tar -zxvf apr-util-1.5.4.tar.gz
  • cd apr-util-1.5.4
  • sudo mkdir /usr/local/apache/apr-util
  • ./configure --prefix=/usr/local/apache/apr-util/ --with-apr=/usr/local/apache/apr/
  • sudo make
  • sudo make install

4. 安装 pcre

  • tar -zxvf pcre-8.39.tar.gz
  • cd pcre-8.39
  • sudo mkdir /usr/local/apache/pcre
  • ./configure --prefix=/usr/local/apache/pcre/
  • sudo make
  • sudo make install

5. 安装apache

  • tar -zxvf httpd-2.4.25.tar.gz
  • cd httpd-2.4.25
  • ./configure --prefix=/usr/local/apache/ --with-apr=/usr/local/apache/apr/ --with-apr-util=/usr/local/apache/apr-util/ --with-pcre=/usr/local/apache/pcre/
  • sudo make
  • sudo make install

6. 添加到服务中

  • cp /usr/local/apache/bin/apachectl /etc/init.d/httpd
  • vim /etc/init.d/httpd 添加如下:

# chkconfig: 345 85 15
# description: Activates/Deactivates Apache Web Server

  • chmod +x /etc/init.d/apache
  • chkconfig --add apache
  • chkconfig --list 查看

恭喜你成功了!

你可能感兴趣的:(centos6.5&7源码包安装apache)