???????? Most languages are programmed with code compatibility issues in different versions, test code compatibility, or debug old code, which requires a different language version environment.
???????? Ruby has Rbenv,rvm,nodejs also have NVM, of course, PHP should also have a similar phpenv, php-version, phpbrew to manage the PHP version, a simple look at the next three tools, I prefer to phpbrew some, In fact, I'd rather call it phpbrew.
If you are sure you need to use Phpbrew, please read this article carefully, then to practice, please note that there is a pit ahead (in fact, I would recommend Vagrant).
Brew & Manage PHP versions in pure PHP at HOME
1. Installing Phpbrew
Download :
Curl-l-o https://github.com/phpbrew/phpbrew/raw/master/phpbrewchmod +x phpbrewsudo mv Phpbrew/usr/bin/phpbrew
2. Simple to use
Run the init script for your shell environment:
Phpbrew Init
Set Environment variables:
sudo vi ~/.bashrc# file Finally, insert the following line of code for source ~/.phpbrew/bashrc# save exit: Wq
Show known versions:
Phpbrew known===> fetching Release list ... [==================================================================] 29.67/29.67kb 100%5.6:5.6.3, 5.6.2, 5.6.1, 5.6.0 ... 5.5:5.5.19, 5.5.18, 5.5.17, 5.5.16, 5.5.15, 5.5.14, 5.5.13, 5.5.12 ... 5.4:5.4.35, 5.4.34, 5.4.33, 5.4.32, 5.4.31, 5.4.30, 5.4.29, 5.4.28 ... 5.3:5.3.29, 5.3.28, 5.3.27, 5.3.26, 5.3.25, 5.3.24, 5.3.23, 5.3.22 ... You can run the ' phpbrew update ' to get a newer release list.
Show older versions:
Phpbrew known--old
Updated version list:
Phpbrew known--update
3. Compiling and installing PHP
Default configuration to install PHP:
Phpbrew Install 5.4.0 +default
Test installation:
Phpbrew Install--test 5.4.0
Display Debug Information:
phpbrew-d Install--test 5.4.0
To install an older version:
Phpbrew Install--old 5.2.13
To clean up the compiled directory:
Phpbrew Clean
4.PHP Compilation parameters
Show available Parameters:
phpbrew variantsvariants: all, apxs2, bcmath, bz2, calendar, cgi, cli, ctype, curl, dba, debug, dom, embed, exif, fileinfo, filter, fpm, ftp, gcov, gd, gettext, gmp, hash, iconv, icu, imap, inifile, inline, intl, ipc, ipv6, json, kerberos, libgcc, mbregex, mbstring, mcrypt, mhash, mysql, opcache, openssl, pcntl, pcre, pdo, pgsql, phar, phpdbg, Posix, readline, session, soap, sockets, sqlite, static, tidy, tokenizer, wddx, xml, xml_all, xmlrpc, zip, zlib, ztsVirtual Variants: dbs: sqlite, mysql, pgsql, pdo mb: mbstring, mbregex neutral: default: bcmath, bz2, calendar, cli, ctype, dom, Fileinfo, filter, ipc, json, mbregex, mbstring, mhash, mcrypt, pcntl, pcre, pdo, phar, posix, readline, sockets, tokenizer, xml, curl, openssl, ziusing variants to build php: phpbrew install php-5.3.10 +default phpbrew install php-5.3.10 +mysql +pdo phpbrew install php-5.3.10 +mysql +pdo +apxs2 Phpbrew install php-5.3.10 +mysql +pdo +apxs2=/usr/bin/apxs2
5. Additional configuration options
Phpbrew Install 5.3.10 +mysql +sqlite--\--enable-ftp--apxs2=/opt/local/apache2/bin/apxs
6. Use and switch
Temporary use:
Phpbrew Use 5.4.22
Switch version (set default version):
Phpbrew Switch 5.4.18
Shut down:
Phpbrew off
7. Display the version of PHP that has been installed
Phpbrew List
8. Managing FPM
???????? Nginx needs to be used in conjunction with PHP-FPM, so if you are using LNMP
or installing your own NGINX
+ PHP
operating environment, you need to add the module to the phpbrew when you install PHP +fpm
, to use phpbrew
the module management.
Phpbrew Install 5.6.3 +FPM
Start FPM:
Phpbrew FPM Start
Stop FPM
Phpbrew FPM Stop
To display the PHP-FPM module:
Phpbrew FPM Module
Test the configuration of the PHP-FPM
Phpbrew FPM Test
Configure PHP-FPM
Phpbrew FPM Config
More???? Extended Installation???? Enable extended???? Configure PHP???? Manage FPM???? Other components (Composer,phpunit).
????????
9. #实践笔记
OS x Notes:
Installation Preparation:
Brew Install Automake autoconf Curl pcre re2c mhash libtool icu4c gettext jpeg libxml2 mcrypt GMP libevent libpng freetype Brew Link Icu4cln-s/usr/local/include/freetype2/usr/local/include/freetype2/freetype
Install Phpbrew:
Curl-l-o https://github.com/phpbrew/phpbrew/raw/master/phpbrewchmod +x phpbrewsudo mv phpbrew/usr/bin/ Phpbrewphpbrew Initsource ~/.phpbrew/bashrcphpbrew Lookup-prefix Homebrew
To install the PHP version:
#同样的在其他系统平台也会出现类似库找不到的问题, you need to manually specify the path phpbrew install 5.3.29 +default +fpm +pdo +mysql +sqlite +gd----with-gd=shared--with- Jpeg-dir=/usr/local/cellar--with-png-dir=/usr/local/cellar--enable-gd-native-ttf--with-freetype-dir=/usr/local /cellar#print_r (Gd_info ());
Note : If there is an error when configuring or compiling, please check this page requirement
Install PHP version
Testing the default Config
Phpbrew Install 5.6.3--test +defaulttail-f/home/rming/.phpbrew/build/php-5.6.3/build.log
Default:
Phpbrew Install 5.6.3 +default +fpm +pdo +mysql +sqlite +gdtail-f/home/rming/.phpbrew/build/php-5.6.3/build.log
Streamline:
Phpbrew Install 5.6.3 +fpm +json +dbs +mb +curl +mcrypt +filtertail-f/home/rming/.phpbrew/build/php-5.6.3/build.log
+json
is because Phpbrew itself is a Phar package, and relies on PHP's JSON functions
+fpm
is for nginx
the phpbrew installed php-fpm default listen=127.0.0.1:9000
, so you need to change the previous LNMP configuration file fastcgi_pass
options 127.0.0.1:9000
;
+dbs
Because there is no installation mysqli extension, want to use a phpmyadmin is difficult, embarrassed;
+mb
is a multi-language encoded byte number problem, for Chinese character truncation and matching use
+curl
Curl extension, very common, you know
+mcrypt
phpMyAdmin need
+filter
Filter_var Filter function
Write a script to switch PHP-FPM:
function nginxenv () {phpbrew fpm stop &>/dev/null; Phpbrew Switch ${1}; Phpbrew fpm start &>/dev/null;}
???????? Save the file to ~/.phpbrew/nginxenv
, and then at the end of the ~/.bashrc
add source ~/.phpbrew/nginxenv
, then the command line can be used to nginxenv 5.3.29
switch versions.
Reference :
Phpbrew Cookbook
Manual
Requirement
Multi-version environment management for PHP