记一次在centOS7下用源码安装apache服务器

下载C编译器,用来编译代码

  • yum install -y gcc

下载apache依赖的三个文件

apr

  1. 下载

    cd ~
    curl -O http://mirrors.shu.edu.cn/apache//apr/apr-1.6.5.tar.gz
    

2.解压

tar -zxvf apr-1.6.5.tar.gz

3.安装运行

cd apr-1.6.5
./configure --prefix=/usr/local/apr            #这个命令的作用是将某文件安装在某地,下同
make && make install

apr-util

1.下载

cd ~
curl -O http://mirrors.shu.edu.cn/apache//apr/apr-util-1.6.1.tar.gz

2.解压

tar -zxvf apr-util-1.6.1.tar.gz

3.安装运行

cd apr-util
./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/apr-util
make && make install

这里的第二行代码你可能会遇到这样的错误

/apr_xml.c:35:19: 致命错误:expat.h:没有那个文件或目录

原因是没有安装expat-devel
我们使用yum命令安装上就好了

yum -y expat-devel

pcre

1.下载

cd ~
curl -O https://ftp.pcre.org/pub/pcre/pcre-8.00.tar.gz

2.解压

tar -zxvf pcre-8.00.tar.gz

3.安装运行

cd prce-8.00
./configure --prefix=/usr/local/apr-util -with- apr=/usr/local/pcre
make && make install

处理apache原码

  • cd ~
    
  • 下载:
  • curl - O http://mirror.bit.edu.cn/apache//httpd/httpd-2.4.38.tar.gz
    
  • 解压
  • tar -zxvf  httpd-2.4.38.tar.gz
    
  • 安装
  • cd httpd-2.4.38.tar.gz
    
  • ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
    

配置服务器文件

cd /usr/local/apache2/bin
./apachectl restart               #这个命令时用来重启服务器

关闭防火墙

  • 与centOS6不同的是centOS7中不再使用iptables,所以关闭的方法是

     systemctl stop firewalld
    

这里贴上一张图片
上图来自 https://blog.csdn.net/c233728461/article/details/52679558

猜你喜欢

转载自blog.csdn.net/qq_42568693/article/details/88094486