广告:宝塔Linux面板高效运维的服务器管理软件 点击【 https://www.bt.cn/p/uNLv1L 】立即购买
推荐(免费):PHP7
安装PHP5
下载解压二进制包
[root@test-a src]# cd /usr/local/src/[root@test-a src]# wget http://cn2.php.net/distributions/php-5.6.32.tar.bz2[root@test-a src]# tar jxvf php-5.6.32.tar.bz2登录后复制编译安装PHP
./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache2.4/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-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#报错:...configure: error: Cannot find OpenSSL's <evp.h># 安装openssl[root@test-a php-5.6.32]# yum install openssl-devel -y...Total size: 14 MTotal download size: 151 kDownloading packages:Delta RPMs disabled because /usr/bin/applydeltarpm not installed.libselinux-utils-2.5-12.el7.x8 FAILEDhttp://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not SatisfiableTrying other mirror.Error downloading packages: libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try.# 安装过程报错,需要安装deltarpm[root@test-a php-5.6.32]# yum install deltarpm...Downloading packages:No Presto metadata available for baselibselinux-utils-2.5-12.el7.x8 FAILEDhttp://mirrors.163.com/centos/7/os/x86_64/Packages/libselinux-utils-2.5-12.el7.x86_64.rpm: [Errno 14] HTTP Error 416 - Requested Range Not SatisfiableTrying other mirror.Error downloading packages: libselinux-utils-2.5-12.el7.x86_64: [Errno 256] No more mirrors to try.# 还是报错,由于之前用的Base源是163的,换回默认的Base源再试就OK了... :(# 继续初始化配置过程,报错...checking for BZip2 support… yes checking for BZip2 in default path… not found configure: error: Please reinstall the BZip2 distribution [root@test-a php-5.6.32]# yum -y install bzip2-devel# 继续报错...checking for stdarg.h... (cached) yeschecking for mcrypt support... yesconfigure: error: mcrypt.h not found. Please reinstall libmcrypt.# 继续报错[root@test-a php-5.6.32]# yum install -y libmcrypt-devel#继续报错...checking for MySQL support... yeschecking for specified location of the MySQL UNIX socket... noconfigure: error: Cannot find libmysqlclient_r under /usr/local/mysql.Note that the MySQL client library is not bundled anymore!# PHP默认是去/usr/local/mysql/lib/mysql/搜索,没有找到报错,复制或者做个软连接就行.[root@test-a php-5.6.32]# cp /usr/local/mysql/lib/libmysqlclient.so /usr/local/mysql/lib/mysql/libmysqlclient_r.so# 再次安装,苍了个天,看见Thank you...啦 成功!...Thank you for using PHP.config.status: creating php5.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands# 编译[root@test-a php-5.6.32]# make...Build complete.Don't forget to run 'make test'.# 安装[root@test-a php-5.6.32]# make install登录后复制查看php的模块(都是静态的)
[root@test-a php-5.6.32]# /usr/local/php/bin/php -m[PHP Modules]bz2CorectypedatedomeregexiffileinfofiltergdhashiconvjsonlibxmlmbstringmcryptmysqlmysqliopensslpcrePDOpdo_mysqlpdo_sqlitePharposixReflectionsessionSimpleXMLsoapsocketsSPLsqlite3standardtokenizerxmlxmlreaderxmlwriterzlib[Zend Modules]# 拷贝配置文件[root@test-a php-5.6.32]# cp php.ini-production /usr/local/php/etc/php.ini# 查看php信息[root@test-a php-5.6.32]# /usr/local/php/bin/php -i登录后复制
安装PHP7
下载安装包解压[root@test-a src]# wget http://cn2.php.net/distributions/php-7.1.6.tar.bz2[root@test-a src]# tar jxvf php-7.1.6.tar.bz2登录后复制配置初始化
[root@test-a src]# cd php-7.1.6/[root@test-a 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# 出错....checking for mysql_set_server_option in -lmysqlclient_r... noconfigure: error: wrong mysql library version or lib not found. Check config.log for more information.# 由于php已经带了这个模块,所以编译时不指定mysqli的路径,继续[root@test-a 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 --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#出错...checking for mysql_commit in -lmysqlclient_r... (cached) noconfigure: error: PDO_MYSQL configure failed, MySQL 4.1 needed. Please check config.log for more information.#编译时不指定pdo的路径,继续root@test-a 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 --with-mysqli --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...Thank you for using PHP.config.status: creating php7.specconfig.status: creating main/build-defs.hconfig.status: creating scripts/phpizeconfig.status: creating scripts/man1/phpize.1config.status: creating scripts/php-configconfig.status: creating scripts/man1/php-config.1config.status: creating sapi/cli/php.1config.status: creating sapi/cgi/php-cgi.1config.status: creating ext/phar/phar.1config.status: creating ext/phar/phar.phar.1config.status: creating main/php_config.hconfig.status: executing default commands登录后复制编译安装
[root@test-a php-7.1.6]# make[root@test-a php-7.1.6]# make install[root@test-a php-7.1.6]# ls /usr/local/apache2.4/modules/libphp*/usr/local/apache2.4/modules/libphp5.so /usr/local/apache2.4/modules/libphp7.so登录后复制
更多其他相关学习敬请关注PHP7教程栏目~
以上就是CentOS如何安装PHP5和PHP7的详细内容,更多请关注9543建站博客其它相关文章!
发表评论