Skip to content

Instantly share code, notes, and snippets.

@edgarsandi
Forked from fluxsauce/gist:5282006
Last active August 31, 2022 18:23
Show Gist options
  • Save edgarsandi/6302898 to your computer and use it in GitHub Desktop.
Save edgarsandi/6302898 to your computer and use it in GitHub Desktop.
install from phpbrew
# Make sure the prerequisites are installed.
sudo apt-get -y install autoconf automake curl build-essential libxslt1-dev re2c libxml2-dev bison
# If don't have installed php use:
sudo apt-get install php5 php5-dev php-pear php5-mysql php5-intl php5-mcrypt php5-sqlite php5-xdebug php5-xmlrpc php5-xsl php5-xcache php5-memcache libxslt1-dev
# Install php archiver
sudo pear install PHP_Archive-alpha
# Install PHP 5 dependencies.
sudo apt-get -y build-dep php5
# Download phpbrew
curl -O https://raw.github.com/c9s/phpbrew/master/phpbrew
# Make phpbrew executable.
chmod +x phpbrew
# copy to /usr/local/bin
sudo cp phpbrew /usr/local/bin/phpbrew
# Initialize phpbrew.
phpbrew init
# Specify where versions of PHP will be installed.
echo "export PHPBREW_ROOT=/opt/phpbrew" >> /home/edgarsandi/.phpbrew/init
# Load phpbrew configuration by default.
echo "source /home/edgarsandi/.phpbrew/bashrc" >> /home/edgarsandi/.zshrc
# Load phpbrew configuration.
source ~/.bashrc
# Determine available versions.
phpbrew known --dsp | grep -i php-5.5
$ sudo mkdir /opt/phpbrew
$ sudo chmod 777 -R /opt/phpbrew/
$ sudo chown edgarsandi:edgarsandi /opt/phpbrew/
$ export PHPBREW_ROOT=/opt/phpbrew
cd ext
git clone https://github.com/krakjoe/pthreads.git
cd ..
rm configure
./buildconf --force
sudo apt-get install libicu-dev libpq-dev
# Install PHP 5.5.2 including default variants, database and multi-byte support, and finally opcache
# without-bz2 because a related problem in phpbrew community
phpbrew install php-5.5.2 +default +dbs +mb -- --enable-opcache --without-bz2 --enable-pcntl --enable-soap --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-shmop --enable-debug --enable-maintainer-zts
phpbrew install php-5.5.3 +default +dbs +mb -- --without-bz2 --with-fpm-user=www-data --with-fpm-group=www-data --enable-debug --enable-exif --enable-fpm --enable-ftp --enable-intl --enable-maintainer-zts --enable-mbstring --enable-opcache --enable-pcntl --enable-pthreads=static --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-sockets --enable-zip --enable-zend-signals
phpbrew install php-5.5.3 +default +dbs +mb -- --without-bz2 --with-fpm-user=www-data --with-fpm-group=www-data --with-gettext --with-gd --with-gmp --with-kerberos --with-libedit --with-mysqli --with-mysql --with-mhash --with-openssl --with-pdo-mysql --with-pdo-pgsql --with-pear --with-pgsql --with-pspell --with-readline --with-regex=php --with-snmp --with-t1lib --with-xsl --with-zlib --enable-bcmath --enable-calendar --enable-debug --enable-exif --enable-fpm --enable-ftp --enable-gd-native-ttf --enable-gd-jis-conv --enable-intl --enable-maintainer-zts --enable-mbstring --enable-opcache --enable-pcntl --enable-pthreads=static --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-sockets --enable-zip --enable-zend-signals
## Funcionou:
phpbrew install php-5.5.3 +default +dbs +mb -- --without-bz2 --with-fpm-user=www-data --with-fpm-group=www-data --enable-debug --enable-exif --enable-fpm --enable-ftp --enable-intl --enable-maintainer-zts --enable-mbstring --enable-opcache --enable-pcntl --enable-pthreads=static --enable-shmop --enable-soap --enable-sockets --enable-sysvsem --enable-sysvshm --enable-sysvmsg --enable-sockets --enable-zip --enable-zend-signals
# Use PHP 5.5.2 for this session.
phpbrew use php-5.5.2
# Enable opcache, configure date
nano -w /home/edgarsandi/.phpbrew/php/php-5.5.2/etc/php.ini
# - Search for date.timezone
date.timezone = America/Sao_Paulo
# - Search for opcache, add:
zend_extension=opcache.so
# - Edit:
opcache.enable=1
opcache.enable_cli=1
# Then, the question is how you want Apache to use it. I needed a parallel installation for 5.3 along with 5.5,
# which I did by using FastCGI.
# Create wrapper for FastCGI support
sudo nano -w /usr/lib/cgi-bin/php552-cgi
#!/bin/sh
PHPRC="/home/edgarsandi/.phpbrew/php/php-5.5.2/etc/"
export PHPRC
PHP_FCGI_CHILDREN=4
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/phpbrew/php/php-5.5.2/bin/php-cgi
# Make the wrapper executable.
sudo chmod +x /usr/lib/cgi-bin/php552-cgi
# Create PHP 5.5 configuration for Apache.
sudo nano -w /etc/apache2/php552.conf
---
<FilesMatch "\.php">
SetHandler application/x-httpd-php5
</FilesMatch>
ScriptAlias /php55-cgi /usr/lib/cgi-bin
AddHandler application/x-httpd-php5 php
Action application/x-httpd-php5 /php55-cgi/php552-cgi
---
# Add the following to whatever VirtualHost is going to use PHP 5.5.2:
Include php552.conf
# Install FastCGI support.
sudo apt-get install libapache2-mod-fastcgi
sudo a2enmod actions
sudo service apache2 restart
# Install pecl libevent
sudo pecl install libevent-beta
# Activate pecl libevent in phpbrew
phpbrew ext enable libevent
# Install pecl pthreads
-- install zsh and oh-my-zsh
$ ~ git clone git://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
$ cp ~/.zshrc ~/.zshrc.orig
$ cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
$ chsh -s /bin/zsh
# Passo 1 – instalar RVM:
$ \curl -L https://get.rvm.io | bash -s stable
$ source ~/.rvm/scripts/rvm
$ rvm -v
#in .zshrc
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# INSTALL PSYSH - Debug interactive PHP
git clone https://github.com/bobthecow/psysh.git
cd psysh
./bin/psysh
# Adding my user into www-data group
sudo usermod -a -G www-data vgite
id vgite
groups vgite
# habilitar módulos apache
sudo a2enmod actions
sudo a2enmod rewrite
## INSTALL RVM
# Now that you're all set up, install RVM itself. This is done via a shell script which you can download and run directly with a single command.
$ bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
# Append the following line to your ~/.bashrc file.
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # This loads RVM
# And then reload your bash environment (or close the terminal window and open a new one).
$ source ~/.bashrc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment