1. 程式人生 > >yum安裝新版php7.0

yum安裝新版php7.0

更新一下,之前寫的是安裝7.0,現在可以安裝7.2了,參考連結:

https://webtatic.com/packages/php72/

直接更新php70為php72

yum install yum-plugin-replace
yum replace php-common --replace-with=php72w-common

It will likely give you a message “WARNING: Unable to resolve all providers …“. This is normal, and you can continue by tying “y”. You will be given a chance to see what packages will be installed and removed before again being given a chance to confirm.


這兩天又裝了一下虛擬機器,又要編譯lnmp,還要弄各種拓展,很麻煩,能不能直接yum安裝呢?答案是可以的!

1、首先要更新yum源,不然肯定是老版本,一般都在5.6及以下,但是php7都出來好久了,效能提升50%以上!

按照系統更新yum源,我的是centos7,所以我執行下面的程式碼!

CentOS/RHEL 7.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

如果是centos6,那麼執行以下程式碼:
CentOS/RHEL 6.x:

rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el6/latest.rpm

然後就可以直接yum安裝php7.0了,可以安裝的拓展如下:

yum install php70w-common php70w-fpm php70w-opcache php70w-gd php70w-mysqlnd php70w-mbstring php70w-pecl-redis php70w-pecl-memcached php70w-devel

就這一條命令,就可以安裝了下面的拓展了!

php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib

激動吧?別急,還有更牛的!一般都要安裝memcached,gd,mysql,等等是吧?

安裝包			提供的拓展
php70w			mod_php	, php70w-zts
php70w-bcmath		
php70w-cli		php-cgi, php-pcntl, php-readline
php70w-common	php-api, php-bz2, php-calendar, php-ctype, php-curl, php-date, php-exif, php-fileinfo, php-filter, php-ftp, php-gettext, php-gmp, php-hash, php-iconv, php-json, php-libxml, php-openssl, php-pcre, php-pecl-Fileinfo, php-pecl-phar, php-pecl-zip, php-reflection, php-session, php-shmop, php-simplexml	, php-sockets, php-spl, php-tokenizer, php-zend-abi, php-zip, php-zlib
php70w-dba		
php70w-devel		
php70w-embedded		php-embedded-devel
php70w-enchant		
php70w-fpm		
php70w-gd		
php70w-imap		
php70w-interbase		php_database, php-firebird
php70w-intl		
php70w-ldap		
php70w-mbstring		
php70w-mcrypt		
php70w-mysql		php-mysqli, php_database
php70w-mysqlnd		php-mysqli, php_database
php70w-odbc		php-pdo_odbc, php_database
php70w-opcache		php70w-pecl-zendopcache
php70w-pdo		php70w-pdo_sqlite, php70w-sqlite3
php70w-pdo_dblib		php70w-mssql
php70w-pear		
php70w-pecl-apcu	
php70w-pecl-imagick	
php70w-pecl-memcached	
php70w-pecl-mongodb	
php70w-pecl-redis	
php70w-pecl-xdebug	
php70w-pgsql		php-pdo_pgsql, php_database
php70w-phpdbg		
php70w-process		php-posix, php-sysvmsg, php-sysvsem, php-sysvshm
php70w-pspell		
php70w-recode		
php70w-snmp		
php70w-soap		
php70w-tidy		
php70w-xml		php-dom, php-domxml, php-wddx, php-xsl
php70w-xmlrpc	

譬如你要加裝xml,那麼可以直接,別懷疑就是這麼簡單:

yum install php70w-xml

2、檢驗一下成果:

檢視一下php版本:

php -v

這裡寫圖片描述

檢視一下php拓展:

php -m

這裡寫圖片描述

看到了吧?基本上會用的拓展都齊了吧?要啥自己去yum一下就好了!再也不用去糾結各種依賴問題了!

使用國內yum源:http://blog.csdn.net/zhezhebie/article/details/73484695
安裝redis和memcached,直接yum安裝即可:

yum install -y memcached redis

memcached說明: http://blog.csdn.net/zhezhebie/article/details/73471519
redis說明: http://blog.csdn.net/zhezhebie/article/details/73470134

到這裡還沒結束,還需要配置一下php的配置檔案和nginx的配置檔案。
參考連結:http://php.net/manual/en/install.unix.nginx.php

webtatic參考連結:https://webtatic.com/packages/php70/

配置php解析.php檔案:
http://php.net/manual/en/install.unix.nginx.php