Skip to content

Instantly share code, notes, and snippets.

@fluxsauce
Created March 31, 2013 21:08
Show Gist options
  • Save fluxsauce/5282006 to your computer and use it in GitHub Desktop.
Save fluxsauce/5282006 to your computer and use it in GitHub Desktop.
Compile and install PHP 5.5 beta 2 with opcache on Ubuntu 12.04.2 LTS 64-bit using phpbrew
sudo -i
# Make sure the prerequisites are installed.
apt-get -y install autoconf automake curl build-essential libxslt1-dev re2c libxml2-dev
# Install PHP 5 dependencies.
apt-get -y build-dep php5
# Download phpbrew
cd /usr/bin
curl -O https://raw.github.com/c9s/phpbrew/master/phpbrew
# Make phpbrew executable.
chmod +x phpbrew
# Initialize phpbrew.
phpbrew init
# Specify where versions of PHP will be installed.
echo "export PHPBREW_ROOT=/opt/phpbrew" >> ~/.phpbrew/init
# Load phpbrew configuration by default.
echo "source /root/.phpbrew/bashrc" >> ~/.bashrc
# Load phpbrew configuration.
source ~/.bashrc
# Determine available versions.
phpbrew known --dsp | grep -i php-5.5
# Install PHP 5.5 including default variants, database and multi-byte support, and finally opcache
phpbrew install php-5.5.0beta2 +default +dbs +mb -- --enable-opcache
# Use PHP 5.5 for this session.
phpbrew use php-5.5.0beta2
# Enable opcache, configure date
nano -w /opt/phpbrew/php/php-5.5.0beta2/etc/php.ini
# - Search for date.timezone
date.timezone = America/Los_Angeles
# - 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
nano -w /usr/lib/cgi-bin/php55-cgi
#!/bin/sh
PHPRC="/opt/phpbrew/php/php-5.5.0beta2/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.0beta2/bin/php-cgi
# Make the wrapper executable.
chmod +x /usr/lib/cgi-bin/php55-cgi
# Create PHP 5.5 configuration for Apache.
nano -w /etc/apache2/php55.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/php55-cgi
---
# Add the following to whatever VirtualHost is going to use PHP 5.5:
Include php55.conf
# Install FastCGI support.
sudo apt-get install libapache2-mod-fastcgi
sudo a2enmod actions
sudo service apache2 restart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment