使用PHPBrew管理PHP版本

INSTALL

curl -L -O https://github.com/phpbrew/phpbrew/raw/master/phpbrew
chmod +x phpbrew

# Move phpbrew to somewhere can be found by your $PATH
sudo mv phpbrew /usr/local/bin/phpbrew

使用

phpbrew init
将下面添加到 ~/.bashrc中

source /home/work/.phpbrew/bashrc
export PHPBREW_SET_PROMPT=1
export PHPBREW_RC_ENABLE=1

通过PHPBrew安装PHP

// 个性化安装PHP
phpbrew variants

/**
install example:
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
*/
Example

phpbrew install php-7.1.9 +default+pdo+openssl+fpm
output

Congratulations! Now you have PHP with 7.1.9 as php-7.1.9

* To configure your installed PHP further, you can edit the config file at
    /home/work/.phpbrew/php/php-7.1.9/etc/php.ini

To use the newly built PHP, try the line(s) below:

    $ phpbrew use php-7.1.9

Or you can use switch command to switch your default php to php-7.1.9:

    $ phpbrew switch php-7.1.9

即,如果想使用刚刚新安装的PHP版本,那么使用命令

phpbrew use php-7.1.9

此时,在命令行模式下使用,看效果

php -v

PHP-FPM如何使用

如果当前已经选定使用php 7.1.9版本后,那么默认php-fpm也是这个版本,只需要使用命令来启动fpm即可

phpbrew fpm start

另外

phpbrew fpm stop

Installing Extra Apps

Installing composer

phpbrew app get composer

Installing phpunit

phpbrew app get phpunit

其他使用方法

https://github.com/phpbrew/phpbrew/wiki/Quick-Start

// Fetch the release list from official php site...
phpbrew update

// List available releases
phpbrew known

// Set 7.0-dev as default php and switch to it.
phpbrew switch 7.0-dev

// Install some extensions for php7, please note the command below are for php7
phpbrew --debug ext install xdebug 2.4.0
phpbrew --debug ext install github:krakjoe/apcu
phpbrew --debug ext install github:php-memcached-dev/php-memcached php7 -- --disable-memcached-sasl
phpbrew --debug ext install github:phpredis/phpredis php7

// Install php 5.6 with the same variant options like 7.0
phpbrew install 5.6 as 5.6-dev like 7.0-dev
使用PHPBrew管理PHP版本

发表评论

电子邮件地址不会被公开。 必填项已用*标注