如何安装php5

藏色散人
藏色散人 原创
2023-03-08 19:00:02 1457浏览

安装php5的方法:首先下载PHP5源码包;然后通过“make && make install”命令进行编译安装;接着拷贝一个文件做配置文件;最后查看PHP信息即可。

本文操作环境:windows7系统、PHP5版,DELL G3电脑

PHP5安装

进到src目录下 cd /usr/local/src

下载PHP5源码包wget http://cn2.php.net/distributions/php-5.6.37.tar.gz

解压下载的文件 tar -zxvf php-5.6.37.tar.gz

进入文件目录 cd php-5.6.37

configure ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-pdo-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-zlib-dir --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --with-iconv-dir --with-zlib-dir --with-bz2 --with-openssl-dir=/usr/include/openssl --with-mcrypt --enable-soap --enable-gd-native-ttf --enable-mbstring --enable-sockets --enable-exif

查看报错信息

checking for xml2-config path… 
configure: error: xml2-config not found. Please check your libxml2 installation.

解决办法如下,完成后再执行configure

yum install libxml2-devel -y 
yum install libxml2 -y

查看报错信息

configure:error: cannot find OpenSSL's <evp'h>

解决如下,完成后再执行configure时将--with-openssl 改为--with-openssl-dir=/usr/include/openssl。或者不更改命令,直接执行yum install -y openssl-devel 也可以。

export PHP_OPENSSL_DIR=yes

查看报错信息

configure:error:please reinstall the BZip2 distribution

解决如下,完成后继续configure

yum install bzip2-devel -y

查看报错信息

configure:error:jpeglib.h not found

解决如下,完成后继续configure

yum install libjpeg-devel -y

查看报错信息

png.h  not found

解决后继续configure

yum install libpng-devel

查看报错信息

freetype-config not found

解决后继续configure

yum install freetype-devel -y

查看报错信息

mcrypt.h not found please reinstall libmcrypt

解决后继续configure

yum install libmcrypt-devel -y

e228495e9208b8eb3a506da884c14d1.png

出现这个界面就可以编译安装了

make && make install

编译安装完之后需要拷贝一个文件做配置文件 ,源文件是在/usr/local/src/php-5.6.37下 ,cp php.ini-development /usr/local/php/etc/php.ini

查看是否加载配置文件,该命令可以查看PHP信息,包括编译参数,configure路径等。

/usr/local/php/bin/php -i |less

推荐学习:《PHP视频教程

以上就是如何安装php5的详细内容,更多请关注php中文网其它相关文章!

声明:本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn核实处理。