Posts Tagged ‘php’

Installing PHP5.3 beta on Ubuntu 8.10

Friday, March 6th, 2009

I wanted to try out the new feature available in PHP 5.3 a while ago. And ran into a few obstacles trying get it installed. Since then I’ve installed it a few times successfully.

In each case I already has apache, php and mysql installed according to the instructions in the Ubuntu Documentation.

Download the latest release candidate or snapshot of PHP 5.3. Extract the source.

The first issue I had was with apxs2, to get PHP installed for Apache. I didn’t have the expected apxs2 file. To resolve this I installed apache2-threaded-dev
sudo apt-get install apache2-threaded-dev

Then I was ready to run (with any addition options you need/want)
./configure --with-apxs2=usr/bin/apxs2 --with-mysql

I got the error “xml2-config not found. Please check your libxml2 installation.”
I needed to install libxml2-dev
sudo apt-get install libxml2-dev

Running the configure command again, it succeeded.

Next to run the make file sudo make
Followed by sudo make install
However it alerts you that you need to have at least one LoadModule in your httpd.conf. Ubuntu doesn’t use httpd.conf to load modules so unless you have added something already, then your httpd.conf will be blank. All you need to do is add a LoadModule line. It doesn’t matter if the module exists or not. I simply added LoadModule whatever.

Now the install should work. Finally you might need to enable the php5 module, and restart apache.
a2enmod php5
apache2ctl restart

Checking phpinfo(), you should now be running PHP 5.3

Apple Releases Security Update 2008-007 and Breaks my Apache

Saturday, October 11th, 2008

As soon as I installed the Apple Security Update 2008-007 this afternoon, restarted and re-opened firefox to all my previous tabs I knew something was up  when my localhost suddenly wasn’t responding.

According to Apple, this fix updates to a new version of Apache 2:

Apache is updated to version 2.2.9 to address several vulnerabilities, the most serious of which may lead to cross site request forgery.

In order to get Apache Running, the first thing I tried was openening System Preferences and enabling/disabling web sharing a couple of times – which did nothing.

Second thing was trying to run httpd from the command line. Again, no success but it gave me some useful errors. For some reason it was attempting to load some old set of config files that I hadn’t used for ages – so I promptly removed those and solved those ’syntax errors’ (cleanups are good!)

Once my config files were in order, I was back to square one with this error…

httpd: Syntax error on line 116 of /private/etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/libphp5.so into server: dlopen(/usr/libexec/apache2/libphp5.so, 10): no suitable image found.  
Did find:\n\t/usr/libexec/apache2/libphp5.so: mach-o, but wrong architecture

All this meant was that the compiled version of PHP5.3 I had (see my other post on running php 5.3) was compiled at 32bit, and Apple had set Apache back to 64Bit. Two commands solved this problem…

sudo cp /usr/sbin/httpd /usr/sbin/httpd-fat
sudo lipo /usr/sbin/httpd -thin i386 -output /usr/sbin/httpd

Note that the first command simply backs up httpd.

Since I’ve got web-sharing enabled, I assume that there’s some system that keeps track of the httpd processes, – as soon as killed the running 64bit httpd processes in Activity Monitor, it all seemed to be working again.

Just one note here: I did re-compile PHP again with the command line I posted earlier. There were no errors, and no differences so I don’t think that it was necessary, but I did try it.

Installing PHP 5.3 on Mac OS X Leopard

Monday, October 6th, 2008

After many frustrating hours and three separate attempts I am finally running PHP 5.3.0alpha3 on my MacBook Pro using the default Leopard Apache installation (the one you can turn on/off with web sharing). This post is as much a summary for my own records as it is how-to to people in the same boat. I’d like to point out that I’m not very experienced with compiling software from source, and for some reason I was determined to utilise the default Leopard installation of Apache.

The problem with the whole process was the Apple compiled version of Apache runs at 64Bit, and at present it’s not possible to compile the  PHP 5.3 Apache module to be compatible. The solution is to cut the Apache binary back to run at 32Bit. That can be done quite simply and is explained by Tony Bibbs back in June with PHP 5.3 on Mac OS X 10.5.

Once you’ve cut Apache back to 32Bit, you just need to install MySQL. Before I read Tony’s post I went to all the effort of compiling MySQL 5.1RC in 64Bit, then found out that PHP wasn’t compatible with the 64bit. Installing a released version of MySQL is simple, and in my opinion not worth going through the effort of compiling from source (unless you need some special functionality). I just took the latest release from the MySQL download site and installed it (after removing numerious other versions first, see below).

After MySQL was running, I downloaded the latest snapshot of PHP 5.3 from snaps.php.net , extracted, then ran the following configure command.

./configure --prefix=/usr/local/php53 \
--with-apxs2=/usr/sbin/apxs --with-config-file-scan-dir=/usr/local/php53/php.d \
--with-iconv --with-openssl=/usr --enable-ftp --enable-sockets \
--enable-mbstring --enable-calendar --enable-bcmath \
--with-curl=shared,/usr/local/php53 --with-zlib-dir=/usr  \
--with-mysqli=/usr/local/mysql/bin/mysql_config

Note my use of –prefix=/usr/local/php53 – this was my choice, as I didn’t want it to potentially overwrite my php 5.2 installation that was there.

The important elements here are –prefix and –with-mysqli

Also – I’m not 100% on what –with-config-file-scan-dir does, but it caused no problems.

After configure succeeds I ran

sudo make

Then after a cofee/beer I ran

sudo make install

From what I could gather, the install procedure created the libphp5.so file inside the /libexec/apache2/ directory (overwriting the one that was previously there), and also added the ‘loadModule’ line within the apache config file @ /private/etc/apache2/httpd.conf. If I did this again, I would backup previous php libraries.

Finally, a sudo apachectl restart restarts the apache server and I was on my way.

Footnotes:

Here’s some locations I found useful

Apache’s Httpd.conf is @ /private/etc/apache2/httpd.conf

The APXS libraries are @ /usr/sbin/apxs

PHP & MySQL (by default) install to /usr/local/

MySQL

Throughout this whole trial and error process, I think I installed MySQL about three different times. Before finally just downloading the latest 5.0 release I took some steps to remove the previous installations. If you’ve installed MySQL many times (like I did) and you’re a bit conscious about having junk all over the place then best place to start looking for information on what’s installed where is the Readme.txt file that comes with the OS X package installer, and also the Mysql Installation notes for OS X

An article I found that also helped me search for some lost MySQL installs, and shed some light on what to do was this post titled Removing MySql – by Lee Hambly.