前言
之前在CentOS7安装php7.1的时候有遇到PHP源及PHP7.1不支持MySQL扩展问题,上午抽空安装了下终于解决了这两个问题,特此记录备忘。
简单安装(yum方式)
安装软件源
添加epel源
| [root@opstrip.com opt]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY* [root@opstrip.com opt]# rpm -Uvh http://mirrors.rit.edu/fedora/epel//7/x86_64/e/epel-release-7-9.noarch.rpm |
添加remi源
| [root@opstrip.com opt]# rpm -Uvh http://rpms.remirepo.net/enterprise/remi-release-7.rpm |
安装并更新软件
安装yum-config-manager实用程序
| [root@opstrip.com opt]# yum -y install yum-utils |
更新系统当前软件版本
| [root@opstrip.com opt]# yum -y update |
更新完成后,就可以安装所需要的PHP版本了。
安装PHP
以上准备工作完成后,就可以安装所需的PHP版本了。
对于PHP5.4
| [root@opstrip.com opt]# yum -y install php |
安装前可尝试yum search php54搜索可安装的软件包。
对于PHP7.0
| [root@opstrip.com opt]# yum-config-manager --enable remi-php70 [root@opstrip.com opt]# yum -y install php php-opcache |
安装前可尝试yum search php70搜索可安装的软件包。
对于PHP7.1
| [root@opstrip.com opt]# yum-config-manager --enable remi-php71 [root@opstrip.com opt]# yum -y install php php-opcache |
安装前可尝试yum search php71搜索可安装的软件包。
完成后还需要添加PHP常用扩展:
| [root@opstrip.com opt]# yum -y install php-mysql php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-soap curl curl-devel |
对于Nginx
| [root@opstrip.com opt]# yum -y install nginx nginx-mod-http-perl nginx-mod-stream nginx-filesystem nginx-mod-mail nginx-mod-http-image-filter nginx-all-modules nginx-mod-http-geoip nginx-mod-http-xslt-filter |
安装前仍建议尝试yum search nginx搜索可安装的软件包。
安装完成后配置PHP及Nginx并启动用以测试phpinfo页面,这时候应该能正常显示。
源码编译安装
安装前的准备
下载PHP安装包
| [root@opstrip.com opt]# wget -O php-7.1.5.tar.gz http://cn2.php.net/distributions/php-7.1.5.tar.gz |
解压
| [root@opstrip.com opt]# tar xf php-7.1.5.tar.gz |
安装依赖包
| [root@opstrip.com php-7.1.5]# yum install -y libxml2 libxml2-devel openssl openssl-devel bzip2 bzip2-devel libcurl libcurl-devel libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel gmp gmp-devel libmcrypt libmcrypt-devel readline readline-devel libxslt libxslt-devel |








