Showing posts with label Mac. Show all posts
Showing posts with label Mac. Show all posts

Thursday, November 18, 2010

Mac Commands, ./configure

What is ./configure!?
I first saw this when I was configuring my PHP and it took me some googling to understand what ‘ ./ ‘ and ‘configure’ means.

Here is the answer.
In terminal, When you are at a specific folder named /usr/, ‘ ./ ‘  just means inside this specific folder and ‘configure’ is the Unix Executable File name.

In summary, it means that there must be an Unix Executable File called configure in the folder /usr/.

Mac Directory: /usr/

As a new Mac user, I was never exposed to Linux or Unix style commands. There is this particular thing that really frustrates me whenever I try to google for instructions on how to perform certain actions on my mac.
This is it: /usr/

I spend a long time trying to find this directory but I cant even find the /usr/ folder!! So where and what is it?! Is this some form of shortform?!
After some intensive googling, I found out that /usr/ is a folder which is “hidden” in the new Mac systems. In order to view it, either we use the terminal to view the file or activate the “Show All Files in Finder” so that all the hidden files can be seen.

All you have to do is to open your terminal and paste this codes:
defaults write com.apple.Finder AppleShowAllFiles YES
It is that simple.. =)

PHP 5.3.2, MySQL 5.1.49, Apache 2.2.16 on MAC OS X 10.6.4

I need to compile PHP, MySQL and Apache on my Macbook Pro. It is really not easy! Besides trying to follow the numerous out-dated posts in the entire internet, I have to contend with a lot of technical and software issues with regards to my MAC (I am a new Mac user).
The versions in which I used are
PHP 5.3.2
MySQL 5.1.49
Apache 2.2.16
on Mac OS X 10.6.4
There are some websites which I have referred to and I will definitely recommend you to read.
  1. Sean Coates’ Blog – I figure out how to download PHP and Apache using the terminal PLUS the installation of libiconv-1.13.1. The file iconv caused such a great headache when I tried to compile things using MAMP. He also solved another headache by teaching how to download libpng, libjpg, libxml2, … All these took me several days to solve.
  2. Zero Inverse’s Blog – I require IMAP-SSL so that I am able to use Gmail from my PHP. Initially, I am using MAMP. But MAMP does not support IMAP-SSL. (It supports IMAP and OpenSSL but you need to recompile the Apache to enable IMAP-SSL support).
Here are my installation steps:
  • Download and install Xcode. You need Xcode to enable the Make command (and many other developer tools).
  • Install Homebrew. I am not using Macports.
  1. $ curl http://gist.github.com/raw/323731/572b315c4f7ee78244de70e7ad703c8ae324da7a/install_homebrew.rb > install_homebrew.rb
  2. $ ruby install_homebrew.rb
  • Install your own iconv. Although Apple does provide, I faced a lot of problems when I tried to use it.
  1. $ curl http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.13.1.tar.gz | tar -zx -
  2. $ cd libiconv-1.13.1
  3. $ ./configure –prefix=/opt && make && make install
  4. $ cd ..
  • Download and install Apache-HTTPD
  1. $ curl http://apache.mirror.iweb.ca/httpd/httpd-2.2.16.tar.bz2 | tar -jxf -
  2. $ cd httpd-2.2.16/
  3. $ ./configure –enable-rewrite –enable-ssl && make && make install
  4. $ cd ..
  • Install PHP dependencies using Homebrew
  1. $ echo “gd jpeg libpng libxml2 libzzip mcrypt mysql” | xargs brew install
  2. $ echo “libpng libxml2 readline” | xargs brew link
  • Install PHP from source. A patch is required else the iconv won’t work.
  1. $ curl -L http://ca2.php.net/get/php-5.3.2.tar.bz2/from/this/mirror | tar -jxf -
  2. $ cd php-5.3.2
  3. $ curl http://www.php.net/~scoates/patches/php-5.3.1-Makefile.global-iconv.patch | patch -p0
  4. $ ./configure –prefix=/usr/local –with-xsl –with-gd –with-zlib-dir –enable-sockets –enable-exif –with-mcrypt –enable-soap –enable-embedded-mysqli –with-mysqli=mysqlnd –with-mysql –with-pdo-mysql –with-curl –with-libedit –with-apxs2=/usr/local/apache2/bin/apxs –enable-mbstring –with-openssl –with-imap –with-imap-ssl –with-iconv=/opt && make && make install
  5. $ cd ..
  • Configure Apache
  1. Make sure that the module is loaded. It should be loaded by default.
    LoadModule php5_module modules/libphp5.so
  2. In /usr/local/apache2/conf/httpd.conf, add these:
    If you are using terminal, type this: cd /usr/local/apache2/conf/ [enter] and pico httpd.conf [enter]. Under LoadModule php5_module modules/libphp5.so
    AddType application/x-httpd-php .php
    AddType application/x-httpd-php-source .phps DirectoryIndex index.html index.php
  3. Before checking phpinfo, it is a must to check whether there are any other applications using the default port 80. My port 80 was occupied by the built in apache and cannot be accessed. I solved it by switching to port 8888. Here are the 2 lines which I edited in my HTTPD.conf file.
    Listen 8888 and ServerName localhost:8888
  4. Now test Apache + PHP by creating php.info().        $ echo “<?php phpinfo(); ?>” > /usr/local/apache/htdocs/index.php
    $ ln -s /usr/local/apache2/bin/apachectl /usr/local/bin/apachectl
    $ sudo /usr/local/bin/apachectl restart
  5. Now visit localhost:8888/index.php. You should see this:

Most importantly, I saw this…

Hooray! My IMAP-SSL is up!!