Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Upgrading PHP in XAMPP for linux?

Tags:

linux

php

xampp

How can I upgrade my current php (only) in xampp?

I need to upgrade from 5.3.1 to 5.4.0

like image 664
Imran Omar Bukhsh Avatar asked Dec 01 '22 06:12

Imran Omar Bukhsh


2 Answers

Download PHP's source code and extract it in /usr/src:

cd ~/downloads
wget http://snaps.php.net/php5.4-latest.tar.gz
tar -xzf php5.4-latest.tar.gz 
sudo mv php5.4 /usr/src/php-5.4

You need to find the configuration of already installed version , so you can use it and install the new version with the exact same configuration

/opt/lampp/bin/php --info | grep "Configure Command"

You should see something like this as result :

./configure '--prefix=/opt/lampp' '--with-apxs2=/opt/lampp/bin/apxs' '--with-config-file-path=/opt/lampp/etc' '--with-mysql=mysqlnd' '--enable-inline-optimization' '--disable-debug' 

Actually, list should probably be much more longer. Copy and store it as you will need to use it as a whole later.

Make a backup of the current installation, in case if anything goes wrong

sudo cp -r /opt/lampp /opt/lampp.bak

Now that you have configuration options, review it and then use it to compile the new version.

cd /usr/src/php-5.4/
./configure  --prefix=/opt/lampp --with-apxs2=/opt/lampp/bin/apxs --with-config-file-path=/opt/lampp/etc --with-mysql=mysqlnd --enable-inline-optimization --disable-debug 
make 
make install

Run /opt/lampp/bin/php -v in order to make sure you have correct php version installed. It should be 5.4.0 Beta.

like image 117
altern Avatar answered Dec 04 '22 04:12

altern


Just want to complement @altern answer....

When I tried all the indications exactly in line of

make install

I had an error in the output

Installing PHP SAPI module:       apache2handler
/opt/lampp/build/instdso.sh SH_LIBTOOL='/opt/lampp/build/libtool' libphp7.la /opt/lampp/modules
/opt/lampp/build/libtool --mode=install install libphp7.la /opt/lampp/modules/
/opt/lampp/build/libtool: 3215: /opt/lampp/build/libtool: install_prog+=install: not found
/opt/lampp/build/libtool: 3235: /opt/lampp/build/libtool: files+= libphp5.la: not found
libtool: install: you must specify an install program
libtool: install: Try `libtool --help --mode=install' for more information.
apxs:Error: Command failed with rc=65536

After looking for information to solve, I found a japanese link: http://d.hatena.ne.jp/Kenji_s/touch/searchdiary?word=*%5BUbuntu%5D

What I did to solve it after trying to understand this japanese solution was simply:

sudo nano /opt/lampp/build/libtool

And when the editor was opened I changed the first line, instead of:

#! /bin/sh

I wrote:

#! /bin/bash

After that I tried again

make install

And voila it compiled!

Hope It helps someone

like image 35
WindSaber Avatar answered Dec 04 '22 03:12

WindSaber