Apache编译安装

Apache编译安装

官网下载Apache的源码包,http://httpd.apache.org/

libphp7.so提取码:ybvh

复制这段内容后打开百度网盘手机App,操作更方便哦
tar -jxvf httpd-2.4.18.tar.bz2
cd httpd-2.4.18
./configure --prefix=/usr/apache24
到这里发现出了个错误,提示没有APR这个组件,apr的作用就是维护相应的软件安装库,已解决相应的平台缺陷等,之前Apache老版本不会出现这个问题,所以首先安装apr,网址是:http://apr.apache.org/,这里包括apr、apr-util、apr-iconv这三个包

$ tar -zxvf apr-1.5.2.tar.gz
$ cd apr-1.5.2
$ ./configure --prefix=/usr/local/apr
$ make
$ make install

$ tar -zxvf apr-util-1.5.4.tar.gz
$ cd apr-util-1.5.4
$ ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
$ make
$ make install

./configure --prefix=/usr/apache24 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util

这里报错
xml/apr_xml.c:35:19: fatal error: expat.h: 没有那个文件或目录
compilation terminated.
/etc/httpd/apr-util-1.6.0/build/rules.mk:206: recipe for target ‘xml/apr_xml.lo’ failed
make[1]: *** [xml/apr_xml.lo] Error 1
make[1]: Leaving directory ‘/etc/httpd/apr-util-1.6.0’
/etc/httpd/apr-util-1.6.0/build/rules.mk:118: recipe for target ‘all-recursive’ failed
make: *** [all-recursive] Error 1
解决办法就是安装libexpat1-dev
sudo apt-get install libexpat1-dev

上面配置参数的–with-apr表示apr-util安装需要依赖apr,所以指定apr的安装目录,到这里apr-util也安装完成了
然后配置依赖安装Apache:
在这里插入图片描述
可以看出,少了程序pcre,需要去http://pcre.org/ 获取,那么现在应该访问这个网站下载,进去网站之后很容易就找到下载链接:ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/

这里下载pcre-8.38.zip这个版本即可,其他的也是没问题的

下载成功,安装pcre:

$ unzip pcre-8.38.zip
$ cd pcre-8.38
$ ./configure --prefix=/usr/local/pcre
$ make
$ make install
  到现在,pcre也安装成功了

现在开始安装apache,进入源码包目录,执行命令:

$ ./configure --prefix=/usr/apache24 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
$ make
$ make install
apache与php的关联

PHP安装成功后会在apache的modules目录下生成一个libphp.so动态库文件,在apache的配置文件httpd.conf里自动增加一行。

vi /etc/httpd/httpd.conf
LoadModule php7_module modules/libphp7.so
在Apache的配置文件httpd.conf的块里增加一行

AddType application/x-httpd-php .php
配置index.php为默认执行的文件

DirectoryIndex index.html index.php

/usr/apache24/bin/apachectl start
服务器的默认根目录在/usr/apache24/htdocs/

解决pcre问题>>>>>>>>>
unzip -o pcre-8.10.zip
cd pcre-8.10
./configure --prefix=/usr/local/pcre
make && make install
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-apr-iconv=/usr/local/pcre
make && make install

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值