Archive for January, 2008

Compiling Apache / PHP for mac 0

Interestingly enough most of the pre-packaged solutions for Apache/PHP/MySQL like MAMP and XAMPP have some or the other limitations, and while experimenting with mashups and other not your usual day development you find out how limited these packages are and even worse they dont provide you the interface to add new modules to it or provide you the modules separately. I might provide a package like this at some point of time but for now, i am just documenting my steps so that i can refer to it at a later point of time if i need too.

Apache 2.2.8
Link:http://mirrors.dedipower.com/ftp.apache.org/httpd/httpd-2.2.8.tar.gz

rpandit$ ./configure --prefix=/apache2 --enable-module=most \
--enable-sharad=max --enable-rewrite
rpandit$ make
rpandit$ sudo make install

the argument --enable-rewrite was required as i quite often use url re-writing and mod_rewrite is an excellent way of doing that. The --prefix argument of the configure script is for the directory where you would like to install the compiled version,

That should have your apache compiled and installed in the folder specified in the --prefix
Starting Apache:

rpandit$ /apache2/bin/apachectl start

If there is no other web server running on your machine (on the default port 80) then you should be able to get it working property. You can verify it by opening up a browser and typing

http://localhost/

and it should come up with the excellent message ‘It Works’

PHP 5.2.5
So i needed to have jpeg and png support in php to be able to create images using php so before i go ahead and compile php i had to get the environment ready. So this is what i did.

libpng

1. Download the library source code from libpng.org.
2. Untar it: $ tar -xjvf libpng-1.2.8.tar.bz2
3. Go into the libpng-1.2.8 directory, and copy the makefile.darwin out
$ cd libpng-1.2.8
$ cp scripts/makefile.darwin makefile
4. Run make: $ make (It's gonna take a while)
5. Install the compiled library into appropriate place:
$ make install

libjpg

1. tar zxvf jpegsrc.v6b.tar.gz
2. cd jpeg-6b
3. cp /usr/share/libtool/config.sub .
4. cp /usr/share/libtool/config.guess .
5. ./configure --enable-shared --enable-static
6. make
7. sudo make install
8. sudo ranlib /usr/local/lib/libjpeg.a

And then finally time to compile php as well (i needed the curl and openssll module as well so i added it with the arguments, you can also add more by looking at options with the ./configure --help argument)

 rpandit$:~/cfarm/php-5.2.5 rpandit$ ./configure --prefix=/apache2/php5/ --with-zlib \
 --with-gd --with-mysql=/usr/local/mysql --with-apxs2=/apache2/bin/apxs  \
--with-jpeg-dir=/usr/local/ --with-png-dir=/usr/local/ --with-pear=/apache2/php5/pear \
--with-openssl-dir=/usr/bin/ --enable-soap --with-curl \
--with-curlwrappers --with-xsl --with-mysqli

and then the usual.

rpandit$ make
rpandit$ sudo make install

Once the compilation bit is over, you need to tell apache about php by adding the following lines:

LoadModule php5_module modules/libphp5.so
AddType application/x-httpd-php .php
AddType application/x-httpd-source .phps

and then restart apache to pick up the new configurations.

rpandit$ /apache2/bin/apachectl restart

In the prefix option i have provided the path where i want to install php, i usually like to keep it in the same folder as apache but you can configure it whichever way you prefer. Now all that you need to do is to drop a script in your htdocs folder (/apache2/htdocs) and test its all working fine.

I usually have a folder in my home directory where i keep all the source code, its useful to go back to it and re-run configure script if i need something more and then then do the usual make, make install

First Post… finally 1

After having not blogged for almost a year (my last post being on the Dec ‘06) I havent had the time to do anything else other than just usual work. However as a resolution for this year, i would try and post as regularly as possible on this blog.
I intend to use this blog for posts related to what I do, technical learnings and related time management and GTD stuff that i read about.