安装PHP5和PHP7php安装
11.10-11.12 安装PHP5
- PHP官网www.php.net
- 当前主流版本为5.6/7.1
- cd /usr/local/src/
- 下载
- 解压
- 进入到php-5.6.30目录里
- yum安装支持库
- 安装
第1个报错:
翻译: 对不起,我不能运行apxs。可能的原因: 1 .工作Perl是没有安装 2。apx型没有发现。尝试通过使用- apxs2=/path/to/ apxs来传递路径 3 .产品Apache并没有使用- enable -所以(apxs使用页面被显示) /usr/local/apache2.4/bin/apxs的输出如下: ./configure: /usr/local/apache2.4/bin/apxs: /replace/with/path/to/perl/interpreter:没有这样的文件或目录 配置:错误:异常终止
解决步骤:
1、根据不能run apxs 。cd 到apache的bin目录下运行./apxs 运行结果
[root@localhost bin]# ./apxs -bash: ./apxs: /replace/with/path/to/perl/interpreter: 坏的解释器: 没有那个文件或目录2、vim apxs文件 找“/replace/with/path/to/perl/interpreter”关键字
在第一个行 :#!/replace/with/path/to/perl/interpreter -w
根据perl的安装目录 /usr/bin/perl
修改为:#! /usr/bin/perl -w
3、运行第一步。或者直接 ./configure ^^^^^
第2个报错
checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation.解决方法:
#查找libxml2 [root@localhost php-5.6.30]# yum list |grep libxml2 #yum安装libxml2库 [root@localhost php-5.6.30]# yum -y install libxml2-devel第3个报错
checking for pkg-config... /usr/bin/pkg-config configure: error: Cannot find OpenSSL's <evp.h>解决方法:
[root@localhost php-5.6.30]# yum install -y openssl-devel第4个报错
checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution解决方法:
[root@localhost php-5.6.30]# yum install -y bzip2-devel第5个报错
checking whether to enable JIS-mapped Japanese font support in GD... no If configure fails try --with-vpx-dir=<DIR> configure: error: jpeglib.h not found.解决方法:
[root@localhost php-5.6.30]# yum -y install libjpeg-devel第6个报错
checking for jpeg_read_header in -ljpeg... yes configure: error: png.h not found.解决方法:
[root@localhost php-5.6.30]# yum -y install libpng-devel第7个报错
If configure fails try --with-xpm-dir=<DIR> configure: error: freetype-config not found.解决方法:
[root@localhost php-5.6.30]# yum -y install freetype-devel第8个报错
checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt.解决方法:
[root@localhost php-5.6.30]# yum install -y epel-release [root@localhost php-5.6.30]# yum install -y libmcrypt-devel安装完毕!
开始编译与安装
- make && make install
查看一下PHP文件
[root@localhost php-5.6.30]# ls /usr/local/php/bin/ pear peardev pecl phar phar.phar php php-cgi php-config phpize #查看一下文件大小 [root@localhost php-5.6.30]# du -sh /usr/local/php/bin/php 36M /usr/local/php/bin/php [root@localhost php-5.6.30]# du -sh /usr/local/apache2.4/modules/ 37M /usr/local/apache2.4/modules/ #php是通过文件结合起来 #查看PHP所加载的模块命令,并且全部都是静态的 [root@localhost php-5.6.30]# /usr/local/php/bin/php -m- 开配置配置文件
11.13 安装PHP7
第一个报错:
Configuring SAPI modules checking for Apache 2.0 handler-module support via DSO through APXS... Sorry, I cannot run apxs. Possible reasons follow: 1. Perl is not installed 2. apxs was not found. Try to pass the path using --with-apxs2=/path/to/apxs 3. Apache was not built using --enable-so (the apxs usage page is displayed) The output of /usr/local/apache2.4/bin/apxs follows: ./configure: line 6199: /usr/local/apache2.4/bin/apxs: No such file or directory configure: error: Aborting解决方法: 安装apache,安装方法请查看http://blog.皇冠云.com/3622288/2051242
第二个报错:
checking libxml2 install dir... yes checking for xml2-config path... configure: error: xml2-config not found. Please check your libxml2 installation.解决方法:
[root@localhost php-7.1.6]# yum -y install libxml2-devel第三个报错:
checking for pkg-config... /usr/bin/pkg-config configure: error: Cannot find OpenSSL's <evp.h>解决方法:
[root@localhost php-7.1.6]# yum -y install openssl-devel第四个报错:
checking for BZip2 in default path... not found configure: error: Please reinstall the BZip2 distribution解决方法:
[root@localhost php-7.1.6]# yum -y install bzip2-devel第五个报错:
If configure fails try --with-webp-dir=<DIR> configure: error: jpeglib.h not found.解决方法:
[root@localhost php-7.1.6]# yum -y install libjpeg-devel第六个报错:
checking for jpeg_read_header in -ljpeg... yes configure: error: png.h not found.解决方法:
[root@localhost php-7.1.6]# yum -y install libpng-devel第七个报错:
If configure fails try --with-xpm-dir=<DIR> configure: error: freetype-config not found.解决方法:
[root@localhost php-7.1.6]# yum -y install freetype-devel第八个报错:
checking for mcrypt support... yes configure: error: mcrypt.h not found. Please reinstall libmcrypt.解决方法:
[root@localhost php-7.1.6]# yum -y install epel-release #安装libtomcrypt-devel之前必须安装epel-release,原因是依赖关系 [root@localhost php-7.1.6]# yum -y install libtomcrypt-devel第九个报错:
mysql_config not found configure: error: Please reinstall the mysql distribution解决方法:
安装mysql数据库 mysql的安装文档链接如下 http://blog.皇冠云.com/3622288/2050823
#安装完成后执行 [root@localhost php-7.1.6]# ./configure --prefix=/usr/local/php7 --with-apxs2=/usr/local/apache2.4/bin/apxs --with-config-file-path=/usr/local/php7/etc --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-libxml-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif配置成功!
最后执行 make && make install 如果不确定有没有编译安装好,可以在执行命令之后 用echo $? 检查命令是否出错。
安装完毕!
8. 把php7的参考配置文件复制到php7的配置文件目录下
[root@taoyun php-7.1.6]# cp php.ini-production /usr/local/php7/etc/php.ini [root@taoyun php-7.1.6]# ls /usr/local/php7/etc/ pear.conf php.ini