VPS how to install php 5.6

From Servage Wiki
Jump to: navigation, search

Installation PHP 5.6 on Debian Squeeze (6)


Replace content of /etc/apt/source.list (please delete all other lines) with:

deb http://archive.debian.org/debian/ squeeze main contrib non-free deb-src http://archive.debian.org/debian/ squeeze main

deb http://repo.liveconfig.com/debian/ squeeze php

deb http://packages.dotdeb.org squeeze all

—————

Get the Keyfiles for new repository:

wget --no-check-certificate -O - https://www.liveconfig.com liveconfig.key | apt-key add -

wget --no-check-certificate -O - https://www.dotdeb.org/dotdeb.gpg | apt-key add -


Update the Package list:

apt-get update 

Now we begin with Installation of PHP 5.6 Binares:

apt-get install php-5.6-opt

Now we install the Apache Modules:

apt-get install libapache2-mod-fastcgi apache2-mpm-worker apache2-suexec 

And activate them:

a2enmod actions fastcgi suexec

Now edit the File /etc/apache2/apache2.conf and add the block under the lines of „LogFormat“:

FastCgiServer /var/www/cgi-bin/php-cgi-5.6
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/

Create folder:

mkdir -p /var/www/cgi-bin/php-cgi-5.6

Create file in the folder we created /var/www/cgi-bin/php-cgi-5.6 and put follows content in it:

#!/bin/sh
PHPRC="/opt/php-5.6/etc/"
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php-5.6/bin/php-cgi

After file creation we have to make fix some permissions:

chown -R 33:33 /var/www
chmod +x /var/www/cgi-bin/php-cgi-5.6

Now we edit the VHOST which should use PHP 5.6 /etc/apache2/sites-available/000-default and add follows Block:

The Block has been in <VirtualHost>-Section:

AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.6
<FilesMatch "\.php$">
SetHandler php-cgi
</FilesMatch>

Just restart Apache:

/etc/init.d/apache2 restart


Now PHP 5.6 is active :)


Important: now activate the Servage-VPS Agent!:

dpkg -x /var/cache/apt/archives/servage-vpsagent_1.0-14_all.deb /


Additional Information:

This instruction also works for PHP 7 and we have to replace the Variables:

apt-get install php-7.0-opt

File: /etc/apache2/apache2.conf :

FastCgiServer /var/www/cgi-bin/php-cgi-7
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/

Filename /var/www/cgi-bin/php-cgi-7

#!/bin/sh
PHPRC="/opt/php-7/etc/"
export PHPRC
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/php-7/bin/php-cgi

Fix Permissions:

chmod +x /var/www/cgi-bin/php-cgi-7

File Apache VHOST /etc/apache2/sites-available/000-default:

AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-7
<FilesMatch "\.php$">
SetHandler php-cgi
</FilesMatch>
Personal tools
Navigation