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为默认执行的文件
/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
本文详细介绍了从源码编译安装Apache的过程,包括解决依赖问题,如APR、apr-util、pcre的安装,以及如何配置Apache与PHP的关联。
1037

被折叠的 条评论
为什么被折叠?



