I would like to have installed WHMCS on my dedicated server. (I already have installed apache2)
How do I install PhP 5.4 as WHMCS not support PhP 5.5?
WHMCS System requirements: http://docs.whmcs.com/System_Requirements
I use ubuntu 14.04 & apache2
I would like to have installed WHMCS on my dedicated server. (I already have installed apache2)
How do I install PhP 5.4 as WHMCS not support PhP 5.5?
WHMCS System requirements: http://docs.whmcs.com/System_Requirements
I use ubuntu 14.04 & apache2
You can try https://github.com/CHH/phpenv
There is one more version manager https://github.com/wilmoore/php-version, but I would give a try to phpenv, because I am using rbenv and it works fine.
There are various methods of solving the issue you are encountering, you can try the following methods:
METHOD 1 :: FRESH INSTALL
sudo apt-get update
sudo apt-get upgrade
sudo apt-get remove --purge `dpkg -l | grep php | grep -w 5.5 | awk '{print $2}' | xargs`
sudo apt-get purge apache2 php5 libapache2-mod-php5
sudo sed -i.bak "s/trusty/precise/g" /etc/apt/sources.list
sudo apt-get update
sudo apt-get install apache2 apache2-suexec libapache2-mod-fcgid php5-cgi
sudo apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-xdebug
sudo sed -i "s/precise/trusty/g" /etc/apt/sources.list
dpkg --get-selections | egrep '^(apache|php)' | sed 's/install/hold/g' | sudo dpkg --set-selections
sudo apt-get update
sudo apt-get install mysql-client mysql-server phpmyadmin
This will install the following Packages:
Apache fcgid PHP 5.4 MySQL PHPMyAdmin and a few other software (including popular PHP Extensions)
METHOD 2 :: MULTIPLE PHP VERSIONS
This method assumes that you have Installed Git (and Nano) on your server
1) Install Dependencies (IF you haven't already):
sudo apt-get install build-essential git apache2-mpm-worker libapache2-mod-fastcgi php5-fpm
2) Install PHP Dependencies:
sudo apt-get build-dep php5
3) Download PHP Farm:
sudo git clone https://github.com/cweiske/phpfarm.git /opt/phpfarm
4) Navigate Directory:
cd /opt/phpfarm/src
5) Compile PHP Versions (of your choice):]
Full list of all versions is available here: http://museum.php.net
NOTE! Install location is /opt/phpfarm/inst/bin when finished.
PHP 5.4: sudo ./compile.sh 5.4.0
PHP 5.5: sudo ./compile.sh 5.5.0
PHP 5.6: sudo ./compile.sh 5.5.6
6) Enable FAST-CGI
sudo a2enmod actions fastcgi alias
7) Restart Apache
sudo service apache2 restart
8) Create FastCGIServer Config
sudo nano /etc/apache2/conf.d/php-cgisetup.conf
9) Edit FastCGIServer Config
You will need to have one line for each version of PHP that you created with PHPFarm, Use (CTRL+O) to save and (CTRL+X) to close.
#php-cgi setup
#used for multiple php versions
FastCgiServer /var/www/cgi-bin/php-cgi-5.4.0
FastCgiServer /var/www/cgi-bin/php-cgi-5.5.0
FastCgiServer /var/www/cgi-bin/php-cgi-5.5.6
ScriptAlias /cgi-bin-php/ /var/www/cgi-bin/
10) Create CGI-BIN
sudo mkdir /var/www/cgi-bin
11) Create PHP-CGI File (for Specific PHP Version)
For Example (for PHP 5.4):
sudo nano /var/www/cgi-bin/php-cgi-5.4.0
12) Edit PHP-CGI File
#!/bin/sh
PHP_FCGI_CHILDREN=3
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_MAX_REQUESTS
exec /opt/phpfarm/inst/bin/php-cgi-5.4.0
Note: If you wish to compile another version of PHP, then just replace the "php-cgi-5.4.0" on both step 11 and 12 with php-cgi-X.X.X", where X.X.X stands for the PHP Version your after
13) Set CGI-BIN Owner
sudo chown -R www-data:www-data /var/www/cgi-bin
14) Set CGI-BIN Permissions
sudo chmod -R 0744 /var/www/cgi-bin
15) Navigate to Directory
cd /etc/apache2/sites-available
16) Create Virtual Hosts
sudo nano php-dev
17) Edit Virtual Hosts
<VirtualHost *:80>
ServerName **PHP 5.4 HOSTNAME GOES HERE**
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.4.0
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName **PHP 5.5 HOSTNAME GOES HERE**
DocumentRoot /var/www
<Directory />virtual host
Options FollowSymLinks
AllowOverride All
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.5.0
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
<VirtualHost *:80>
ServerName **PHP 5.6 HOSTNAME GOES HERE**
DocumentRoot /var/www
<Directory />
Options FollowSymLinks
AllowOverride All
AddHandler php-cgi .php
Action php-cgi /cgi-bin-php/php-cgi-5.5.6
</Directory>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
</VirtualHost>
You will have to configure this to your needs.
18) Disable Default Website
sudo a2dissite default
19) Enable the New Website
sudo a2ensite php-dev
20) Navigate to the WWW Directory
cd /var/www
21) Reload Apache
sudo service apache2 reload
22) Remove Old Index
rm index.html
23) Create a Test PHP Page
sudo nano index.php
24) Edit the Test Page We've made
<?php
phpinfo();
?>
25) Get your Server IP Address
If you don't know how, use the following command:
ifconfig
26) Open the /etc/hosts file
sudo nano /etc/hosts
27) Edit the Hosts File
127.0.0.1 YOURWEBSITEURLFORPHP54.COM
127.0.0.1 YOURWEBSITEURLFORPHP55.COM
127.0.0.1 YOURWEBSITEURLFORPHP56.COM
and that's that, you can now save this, and Reload/Restart Apache if you need to and test your new websites, which run on different php versions!