Friday, April 15, 2011

Ubuntu PHP 5.3.6 installation from source in a system with existing PHP 5.2 and Apache 2

I have been contemplating on installing PHP 5.3 on my Ubuntu box since it takes awhile for Ubuntu to upgrade their APT packages but Im afraid of messing around with the install cause i got important live web files in my server and don't want to ruin the perfectly working PHP 5.2 version.

In either case, I finally summoned the guts to install PHP 5.3 from source and bit the bullet. I did it from source because I dont want to depend on the Ubuntu packages on PHP anymore and want the ability to upgrade easily in the next major PHP release.

1.) So I downloaded PHP 5.3.6 from php.net and did all the untarring.
$> wget http://www.php.net/get/php-5.3.6.tar.gz/from/a/mirror
$> tar -xzvf php-5.3.6.tar.gz

2.) Then I have a bunch of library dependencies that I need to install. Here apt-get works a charm.
$> apt-get install libxml2-dev
$> apt-get install libbz2-dev
$> apt-get install libcurl4-openssl-dev
$> apt-get install libjpeg-dev
$> apt-get install libpng12-dev
$> apt-get install libXpm-dev
$> apt-get install libfont-freetype-perl
$> apt-get install libfreetype6-dev
$> apt-get install libxslt-dev

I got a little bit more than the above library dependencies but their pretty easy to install with apt-get so I didn't bother to document them.

*For those who are new to compiling, note that the above packages are depending upon your build. I have to install the libraries above because if you look at my build configure below, I enabled this feature in PHP. If you do not know what libraries you are required to have then just run configure with your build options, then the script will halt if it cannot find the libraries. From there you can see your requirements although this takes time especially if you are enabling a bunch of feature. There also maybe much more efficient way in doing this though.

Another problem I cannot figure out was the --with-snmp, I keep getting the
error: SNMP sanity check failed.
My solution was to remove it from the build for now since I do not use. Feel free to suggest a solution though.

UPDATE: I solved this problem by installing package libsnmp-dev.
Look here in my blog for details: http://kelmadics.blogspot.com/2011/06/php-install-problems-with-snmp.html

TIP: One command I use if apt cannot find the package is search for it, for example:
apt-cache search freetype

Also, since I installed Apache differently before, the --with-apxs2=PATH will not work. I have to remove the threaded version and install Apache prefork:
$> sudo apt-get remove apache2-threaded-dev
$> sudo apt-get install apache2-prefork-dev

3.) Build time! Here is what I used to build:
$> cd php-5.3.6
$> ./configure \
--prefix=/usr/local/lib/php5.3.6 \
--with-apxs2=/usr/bin/apxs2 \
--with-mysql=/usr/local/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pear=/usr/local/lib/php5.3.6/lib/php \
--with-tidy \
--with-curl \
--with-curlwrappers \
--with-openssl-dir \
--with-xpm-dir \
--with-pdo-mysql \
--with-xsl \
--with-ldap \
--with-xmlrpc \
--with-iconv-dir \
--with-bz2 \
--with-mcrypt \
--with-jpeg-dir \
--with-png-dir \
--with-zlib-dir \
--with-freetype-dir \
--with-gd \
--with-snmp \
--enable-mbstring \
--enable-zip \
--enable-exif \
--enable-calendar


A thing to note here. I used --prefex=PATH to install it from a different location since I already have an existing PHP 5.2 and don't want to overwrite anything.

4.) Ok, finally done with the build, time for "make & make install".
$> make
$> make install

Hit a minor snag though. I got this error:
chmod 755 /usr/lib/apache2/modules/libphp5.so
apxs:Error: Activation failed for custom /etc/apache2/httpd.conf
file..
apxs:Error: At least one `LoadModule' directive already has to exist..
make: *** [install-sapi] Error 1 

Quick googling and the fix is just adding a dummy place holder on whichever file it is looking for. In the case above it is httpd.conf so just add or append in httpd.conf the following code:
# Dummy LoadModule directive to aid module installations
#LoadModule dummy_module /usr/lib/apache2/modules/mod_dummy.so


Take note of the "#". That is included!

Reference: Here's where I got the solution from for the above problem: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=231134

Please note that doing "make install" will overwrite your php5 module in /usr/lib/apache2/modules/libphp5.so so if you want to have a backup do it BEFORE you do "make install"

After adding the dummy text, do make install again.
$> make install

5.) Optional. After that I copied my existing php.ini from /etc/apache2/php5 to where ever I installed my php5.3 library. In my case this is /usr/local/lib/php5.3.6/lib
$> cp /etc/apache2/php5/php.ini /usr/local/lib/php5.3.6/php.ini

6.) Restart apache and you have php5.3 installed. I didn't even have down time!
$> sudo apache2ctl restart

IMPORTANT: One more final note since we placed a dummy module line in httpd.conf, this caused
the install to write a line: LoadModule php5_module /usr/lib/apache2/modules/libphp5.so
in httpd.conf but since you may already have this line in /etc/apache2/mods-available/php5.load if you  have Apache installed already through aptitude, restarting apache will warn that you have a duplicate module!

Solution is to simply remove the extra generated line from httpd.conf and everything should work!!!

17 comments:

Vince D said...

Thank you for this guide, it was very helpful.

Unknown said...

Sergei , October 22, 1970 Born in Christian Louboutin Bois Dore Moscow State Ozherelye. Perhaps influenced by Cheap LV Handbags their parents worship warrior army, join the army in cheap jordans 1989, and into the elite airborne military service. 1991, by the influence of the Soviet Union, the uggs on sale Russian christian louboutin army general lack of funds, a large number ugg australia of Air Jordan 11 Gamma Blue soldiers seeking veterans, but under extremely difficult conditions still dedicated, praise superiors, and soon was sent to the famous christian louboutin shoes Ryazan Higher ugg Airborne Command School studies. After graduating in 1994, entered the famous Pskov 76th Guards Airborne discount christian louboutin Division, served as discount nike jordans the reconnaissance platoon, reconnaissance ugg soldes deputy company commander, company commander, battalion airborne regiment scouting director and other duties.From 2000 to Cheap Louis Vuitton Handbags 2004, where the forces have repeatedly ordered war with Chechen militants. Because of their opponents in order to form the squad activity and haunted impermanence, the Russians had to ugg boots mobilize elite troops set up large uggs outlet number of small units, "a Discount Louis Vuitton small wholesale jordan shoes play small" Implementation siege. commanding troops in Chechnya, Christian Louboutin Daffodile Ingushetia and other places over the mountains, to track the militants fled. Discount LV Handbags Although the militants were extremely vigilant, but as long as the task has never had outsmarted.August 8, 2008, Georgia suddenly invade South Ossetia (Russian peacekeepers stationed ugg pas cher there), the Russian military to respond quickly, including including the 76th Guards Airborne Division, more than christian louboutin remise 50% 3,000 people were immediately delivered to the pro-Russian Abkhazia, Georgia cheap nike jordan shoes Army contain two infantry brigades, effectively coordinate the cheap christian louboutin direction of the Russian Bags Louis Vuitton troops in South Ossetia.

Unknown said...

new york giants jerseys
juicy couture outlet
chanel outlet
ray ban sunglasses
robert griffin jersey,joe theismann jersey,andre roberts jersey,sonny jurgensen jersey,art monk jersey,bashaud breeland jersey,barry cofield jersey,perry riley jersey,e.j. biggers jersey,duke ihenacho jersey,josh morgan jersey
mizuno shoes
seahawks jersey
stuart weitzman sale
nike free,nike free run,free running,free run,nike running
five fingers shoes
tory burch outlet online
uggs outlet
cheap oakley sunglasses
cheap jordans
mizuno running shoes
derrick rose jersey
cowboys jerseys
barcelona soccer jersey
bottega veneta wallet
nike roshe
chanel outlet,chanel handbags,chanel bags,chanel outlet,chanel 2.55
supra shoes
giants jersey
stephen curry jersey
miami dolphins jerseys
bottega veneta outlet
indianapolis colts jerseys
nike air max 2015
ray ban outlet
arizona cardinals jerseys
the north face clearance
coach outlet store
nike trainers
chelsea jersey
washington redskins jerseys
zhuweiming0627

chenlina said...

chenlina20150711
ray ban sunglasses
imitation watches
louis vuitton handbags
abercrombie store
chanel bags
chanel handbags
air max 90
soccer cleats
louis vuitton
coach outlet
michael kors uk
concords 11
chanel outlet
oakley sunglasses
gucci handbags
true religion sale
hollister clothing
cheap chanel handbags
insanity dvd
lebron 11
michael kors uk
louboutin
fendi handbags
louis vuitton handbags
louis vuitton
coach outlet store online
longchamp outlet
toms shoes
hollister
ray ban glasses
cheap jerseys wholesale
mulberry handbags
chanel outlet
louis vuitton outlet
coach outlet online
fitflop sale
michael kors outlet
ray ban outlet
louboutin
michael kors handbags

Unknown said...

15.07.20fangyanting
soccer jerseys for sale
abercrombie & fitch
kate spade handbags
air jordan uk
longchamp outlet online
pandora charms
rolex watches for sale
coach outlet store online
coach outlet
true religion jeans outlet
pandora bracelets
oakley sunglasses wholesale
ralph lauren polo shirts
kate spade bags
coach outlet
snapbacks hats
toms shoes for women
soccer shoes for sale
ray bans
beats headphones
hollister kids
gucci handbags
cheap oakley sunglasses
replica watches for sale
coach factory outlet
gucci borse
gucci belt
cheap snabacks
hollister outlet
tory burch outlet
kate spade bags
michael kors
air max 2015
longchamp pliage pas cher
mcm outlet online

Unknown said...

2015-09-16 zhengjx
Up To 70% Off Air Retro Jordan 8s
michael kors handbags
michael kors outlet
Coach Factory Outlet Discount Online
Abercrombie And Fitch Clothing Outlet at New York
uggs outlet
Michael Kors Outlet Factory Online Store
Cheap Jordan 13 Shoes For Sale Free Shipping
ralph lauren
canada goose jackets
toms shoes
Abercrombie And Fitch New York Outlet Store
fitflops
coach outlet
coach factory outlet
Louis Vuitton Outlet Handbags Pursers In USA
Michael Kors Outlet Online Store Clearance
Coach Factory Outlet Online Sale Discount
Original Michael Kors Handbags Outlet Online
Coach Outlet Store Online Clearance
Cheap Michael Kors Handbags On Sale
Official Cheap Michael Kors Handbags Outlet
ugg boots
louis vuitton
cheap nfl jerseys
Louis Vuitton Outlet Store Locations
abercrombie & fitch
Coach Factory Outlet Official Website
louis vuitton outlet
michael kors

Unknown said...

cheng0928
louis vuitton handbags, http://www.louisvuittonhandbag.us/
hermes birkin, http://www.hermesbirkin.org/
mbt shoes, http://www.mbtshoesoutlet.us.com/
swarovski outlet, http://www.swarovski-outlet.co.uk/
hogan, http://www.scarpehogan-outlet.it/
ray ban, http://www.occhiali-rayban.it/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
nba jerseys, http://www.nbajerseys.us.com/
longchamp handbags, http://www.longchamphandbag.us.com/
cheap nhl jerseys, http://www.nhljerseys.us.com/
cheap mlb jerseys, http://www.cheapmlbjerseys.net/
north face jackets, http://www.thenorthfaces.in.net/
cheap snapbacks, http://www.cheapsnapbacks.us.com/
adidas wings, http://www.adidaswings.net/
basketball shoes, http://www.basketballshoes.us.com/
lebron james shoes, http://www.lebronjamesshoes.in.net/
lacoste polo shirts, http://www.lacostepoloshirts.cc/
vans shoes, http://www.vans-shoes.cc/
ugg boots, http://www.uggboot.com.co/
hermes belt, http://www.hermesbelts.us/

Unknown said...

ray ban sunglasses, http://www.raybansunglassesonline.us.com/
nike trainers, http://www.niketrainers.me.uk/
gucci handbags, http://www.guccihandbags-outlet.co.uk/
herve leger, http://www.herveleger.us.com/
timberland boots, http://www.timberlandboots.name/
coach outlet online, http://www.coachoutletonline-store.us.com/
michael kors outlet, http://www.michaelkorsoutletcanada.in.net/
juicy couture outlet, http://www.juicycoutureoutlet.net/
calvin klein underwear, http://www.calvinklein.in.net/
ray ban sunglasses, http://www.raybansunglass.us.com/
prada outlet, http://www.pradaoutlet.us/
lululemon outlet, http://www.lululemonoutletstore.in.net/
tory burch shoes, http://www.toryburchshoesoutlet.com/
michael kors outlet, http://www.michaelkorsoutlet.org.uk/
replica watches, http://www.replicawatchesforsale.us.com/
pandora jewelry, http://www.pandorajewelryoutlet.us.com/
nfl jerseys wholesale, http://www.nfljerseys-wholesale.us.com/
michael kors outlet, http://www.michaelkorsoutletonlinstore.us.com/
oakley outlet, http://www.oakleyoutlet.in.net/
oakley sunglasses, http://www.oakleysunglasses-outlet.us.com/
michael kors bags, http://www.michaelkorsbags.uk/
ray ban sunglasses, http://www.ray-bansunglasses.eu.com/
oakley sunglasses, http://www.oakley.in.net/
air max 2015, http://www.airmax2015.in.net/
the north face uk, http://www.thenorthfaces.org.uk/
swarovski outlet, http://www.swarovski-outlet.co.uk/
pandora jewelry, http://www.pandora.eu.com/
chanel handbags, http://www.chanelhandbags-outlet.co.uk/
1002maoqiuyun

chenlina said...

chenlina20151127
uggs boots
canada goose jackets
ugg outlet
louis vuitton handbags
gucci shoes
ray ban outlet store
mont blanc legend
michael kors handbags
ray ban sunglasses
louis vuitton handbags
cheap uggs
hollister co
kobe 9
adidas superstars
hollister
north face jackets
tory burch sale
ugg australia
louis vuitton handbags
timberland outlet
michael kors outlet online
canada goose jackets
louis vuitton outlet
hollister co,hollister jeans,hollister.com,hollister ca
coach outlet store online
michael kors outlet
louis vuitton purses
michael kors outlet
uggs on sale
adidas originals
louis vuitton
louis vuitton handbags
michael kors outlet online
giuseppe zanotti
nike roshe run women
ugg boots on sale
michaek kors outlet online
nike huarache shoes
canada goose jackets
nike trainers uk
as

Unknown said...

nike blazer pas cher
reebok outlet store
adidas nmd runner
longchamp handbags
adidas uk
uggs outlet
abercrombie and fitch
michael kors handbags
coach outlet
michael kors handbags
michael kors outlet online
ray ban sunglasses
longchamp solde
prada sunglasses
swarovski jewelry
hollister uk
ugg boots
football shirts
ugg australia
canada goose jackets
cheap ugg boots
lacoste pas cher
uggs outlet
michael kors outlet online
michael kors handbags
toms shoes
uggs outlet
coach outlet
coach outlet clearance
dior sunglasses
adidas wings
lululemon outlet
louis vuitton outlet
the north face jackets
true religion uk
chanyuan0913

Unknown said...

tiffany and co
louis vuitton outlet
clarisonic
true religion jeans
timberland outlet
true religion outlet
louis vuitton outlet
cheap uggs
coach outlet
true religion outlet
mlb jerseys
oakley sunglasses
adidas outlet
michael kors outlet
longchamp handbags
beats by dre
rolex watches
ray ban sunglasses
ugg boots
ugg australia
moncler uk
ray ban sunglasses
louis vuitton paris
toms shoes
louis vuitton handbags
coach factory outlet
moncler uk
gucci outlet
canada goose outlet
adidas nmd
timberland boots
juicy couture
burberry outlet
ugg boots
the north face jackets
timberland boots
new york knicks jerseys
nike outlet store
ugg sale
ugg italia
201611.5wengdongdong

Unknown said...

nike huarache
north face
michael kors outlet
lebron james shoes
ralph lauren outlet
michael kors handbags sale
new balance shoes
supra shoes sale
michael kors handbags
michael kors handbags

Unknown said...

adidas outlet
nike air max 90
gucci outlet
ugg boots
timberland boots
nike store
pandora jewelry
yeezy boost 350
fitflops shoes
polo outlet
mt0718

Unknown said...

20180412xiaoke
birkenstock outlet
louis vuitton outlet store
pandora charms sale clearance
michael kors handbags
pandora outlet
replica rolex
ugg outlet
ugg boots clearance
christian louboutin shoes
oakley sunglasses sale

zzyytt said...

lebron 14
damian lillard shoes
off white jordan 1
michael kors handbags
tory burch shoes
adidas shoes
adidas tubular x
jordan retro 13
air max 90
real jordans for sale cheap

5689 said...

zzzzz2018.11.6
ugg boots clearance
canadian goose
pandora charms
ugg boots clearance
pandora outlet
pandora outlet
ralph lauren uk
mbt shoes
louboutin shoes
nike outlet

amc stars said...

ابزار وبلاگ