12

I'm actually stuck with a little problem. I want to use Laravel on my pi but it requires at least PHP 5.5.9.

But actually, the latest version of PHP that I am able to install (via the official repository) is the 5.4

How can I upgrade to 5.6 (or 5.5.9) ?

goldilocks
  • 58,859
  • 17
  • 112
  • 227
Germain
  • 222
  • 1
  • 2
  • 7

2 Answers2

10

These are the steps you can follow.

  1. Grab latest source from this site. (http://php.net/downloads.php) Choose your nearest mirror. For example, I did "wget https://www.php.net/distributions/php-5.6.10.tar.bz2"
  2. Unpack it: tar -xvjf php-5.6.10.tar.bz2
  3. cd php-5.6.10
  4. ./configure
  5. make -j4 (if you're compiling it on Rpi 2) else just make
  6. sudo make install
  7. Test it by firing php -v

It should be now upgraded to 5.6

Hope it helps.

dhruvvyas90
  • 2,853
  • 3
  • 19
  • 32
  • Thank you for you post but for the very first time I'm not able to install it with this method. I don't know why but I think I've got a bug with the ./configure, it seems it does not work correctly because I am not able to use "make" (makefile is not created).

    Log file here

    – Germain Jun 21 '15 at 23:42
  • You will have to install related dependencies. See the error. Pi is missing libxml2. To install that, "sudo apt-get update && sudo apt-get install libxml2". Try configuring again. You may face other dependencies issues. You will have to install each on using "sudo apt-get install" before you can proceed with make. Hope it helps. – dhruvvyas90 Jun 22 '15 at 03:36
  • When I try to install libxml2, it says that it's already installed ... How is it possible ? – Germain Jun 22 '15 at 18:23
  • 1
    Try : sudo apt-get install libxml2-dev – dhruvvyas90 Jun 22 '15 at 18:31
  • 1
    Thank you very much it worked well and I was able to execute make & then install ;) – Germain Jun 22 '15 at 21:07
  • One more question, I think I've got a little problem with nginx. Actually, php 5.4 is still used on my website but when I use php -v it tells me that php 5.6 is running, maybe a config file to edit ? http://i.imgur.com/xt1Zhqy.png – Germain Jun 23 '15 at 18:38
  • 1
    Locate old php.ini file by "sudo find / -name php.ini" and copy the new one from php-5.6 directory by "sudo cp php.ini-production /path/to/php.ini" That should do, I guess. – dhruvvyas90 Jun 23 '15 at 19:23
  • https://downloads.php.net/~ab/ – user956584 Oct 12 '15 at 21:00
  • Did anyone manage to check whether the compile includes php5-mbstring? – brianlmerritt Dec 15 '15 at 07:37
  • @brianlmerritt: You should check the other answer. – dhruvvyas90 Dec 15 '15 at 07:44
  • I have edited that answer, awaiting peer review. The correct way to get php_mbstring on any debian based OS is apt-get install libapache2-mod-php5 – brianlmerritt Dec 15 '15 at 08:14
  • @Germain67 I am having the same issue that php -v tells me the 5.6 version but apache2 still using the old php5.4. I did exactly you suggested that copied the php.ini-production file to the /etc/php5/apache2/ folder to replace the old one and then restarted apache2 but still showing the old php5.4. Can some help me pointing out what maybe I'm doing wrong here? – Humayun Mar 10 '16 at 16:08
  • @Humayun Have you tried to rename "php.ini-production" to "php.ini" ? Then try to restart apache2, hope it will do the trick ;) – Germain Mar 13 '16 at 16:10
5

At the time of this writing (november 2015), raspbian is built on Debian Jessie. The installable PHP version is in the 5.6 branch.

However, for Laravel projects you will need a number of PHP extensions. Most of these are available in the Raspbian repositories (or out of the box), but the php_mbstring extension cannot be loaded via apt-get.

Instead, to get php5_mbstring run apt-get install libapache2-mod-php5 which includes it (reference comments in http://php.net/manual/en/mbstring.installation.php)

derjoachim
  • 201
  • 3
  • 4