安装步骤
1.重新编译apache
- 进入apache的源文件目录 cd Downloads/httpd-2.4.23
- ./configure –prefix=/usr/local/httpd –enable-so
- make
- sudo make install
2.下载libiconv并编译安装
- 到http://www.gnu.org/software/libiconv/
下载,解压文件 - cd libiconv-1.14 -> ./configure –prefix=/usr/local -> make,因为操作系统为ubuntu16所以在编译的时候会出一个error
- 解决error: cd libiconv-1.14/srclib->vim stdio.h找到gets is a security hole所在的行,把这行删掉,替换成
- 再重新make,就不会有问题了 -> sudo make install -> sudo ldconfig
- cd /usr/local/lib,就能找到libiconv.so
3.重新编译php
- 进入php的源文件目录 cd Downloads/php-7.0.11
- make clean先将上次编译的结果清除掉
- ./configure –prefix=/usr/local/php7 –with-config-file-path=/usr/local/php7/etc –with-apxs2=/usr/local/httpd/bin/apxs –with-iconv-dir=/usr/local/lib
- make ZEND _EXTRA _LIBS=’-liconv’
- sudo make install
4.对apache的配置文件做一下修改
重新编译完apache和php后,cd /usr/local/httpd/modules
就会出现cd /usr/local/httpd/conf -> vim httpd.conf
就会出现实现了php作为apache的模块与它“共结连理”
- 还要在apache的配置文件中加入
5.重启apache并查看apache加载的模块
- cd /usr/local/httpd/bin -> sudo ./apachectl restart
- ./apachectl -t -D DUMP_MODULESphp作为apache的一个模块被成功加载了
6.写一个php程序并通过浏览器访问
- cd /usr/local/httpd/htdocs
- vim abc.php ->在里面写简单的php语句 <?php echo phpinfo();?>
- 通过浏览器localhost/abc.php能够正确访问