MampConfiguration
From PikaDocs
By Matthew Friedlander
Pika Software (http://www.pikasoftware.com/)
| Table of contents |
What is MAMP?
Mac OSX, Apache, MySql, PHP (MAMP)
Recently I needed to delve into the nuts and bolts of setting up a PHP development and Pika Server environment on Mac OSX Leopard. To start, OSX Leopard (10.5.5 as of this writing) ships with PHP 5.26 and Apache 2.2.1. However, PHP is disabled by default. Here is a walkthrough on how I installed all of the necessary items for Pika in Leopard.
PHP
Leopard ships with a pre-compiled version of 5.24 and since the Leopard 10.5.5 patch they have upgraded this to PHP 5.26. This install is disabled within the Apache2 httpd.conf file and needs to be re-enabled.
In httpd.conf on line 114, uncomment the LoadModule php5_module directive (remove the # - pound symbol) so that it appears as below:
LoadModule bonjour_module libexec/apache2/mod_bonjour.so LoadModule php5_module libexec/apache2/libphp5.so #LoadModule fastcgi_module libexec/apache2/mod_fastcgi.so
To test that everything is working open the OSX System Preferences->Sharing and start (or restart) Web Sharing
stub-image websharing
Then add the following code to a php file named info.php to either /Library/Webserver/Documents or /Users/**your username**/Sites.
<?php phpinfo(); ?>
If all is well you should see the PHP Information screen listing all of the details of the version of PHP you have installed.
Now that we have PHP working its time to install the MySQL database server.
MySQL
First you need to download the MySQL 5.0 community server located at the following link:
MySQL Community Server 5.0 (OSX package) download (http://dev.mysql.com/downloads/mysql/5.0.html#macosx_dmg)
- Note - Download the 32-bit application not the x86_64 64-bit application.
As of this writing the most recent 5.0 release is 5.0.67. Mount the downloaded package file in finder and run the mysql-5.0.67-osx10.5-x86.pkg. The installer wizard will walk you through installing MySQL on your system. Once you have completed that run the MySQLStartupItem.pkg and the MySQL.prefPane. This will make sure that MySQL starts when the system is rebooted and the prefPane will be added to OSX System Preferences enabling you to start and stop the system easily.
stub osx_mamp_mysql_pkg stub osx_mamp_mysql_prefpane
If the server isn't already running please go to the System Settings->Mysql and start the server.
Getting PHP to find MySQL
Now that you have MySQL and PHP up and running you need to make a slight change in order for them to talk to one another. By default the PHP install looks for the MySQL socket file (mysql.sock) in the /tmp directory, which is incorrect. In order for the MySQL drivers in PHP to work properly it will need to be able to find this file.
PHP's default configuration file is under /etc/php.ini.default. It will need to be copied to php.ini.changed.
From the terminal:
cd /etc sudo cp php.ini.default php.ini sudo nano php.ini
In php.ini on line 760.
mysql.default_socket = /var/mysql/mysql.sock
Once this step is complete restart MySQL and Web Sharing. You are now ready to install Pika CMS.
Document Full-Text Search
Once Pika CMS is installed you may want to enable full-text searching for documents under the Pika Search function. This will strip text out of uploaded files in order to facilitate locating documents pertaining to a subject more easily.
For most files the default strings program can accomplish this, however, for pdf files strings doesn't always work and can end up populating the text search for that file with gibberish rather than usable text.
In older versions of Pika the program for extracting from pdf files was ps2ascii which is part of ghostscript. Mac OSX doesn't include this program by default (although most linux distributions do). The simplest way that I've found to install ghostscript is by using Macports. Macports is the OSX equivalent of yum/apt-get/update from the linux world and is simply a package manager tailored specifically to OSX.
- Install MacPorts (http://www.macports.org)
Once you have downloaded and installed the Macports. Enter the following commands to install ghostscript.
From the terminal:
sudo /opt/local/bin/port install ghostscript
Macports will then download and install ghostscript and all of its dependencies (this will probably take a while if this is your first time installing)
Once it is complete you will need to create a link to the ps2ascii and gs programs in order for Apache & Pika to locate it. This is due to the fact that Macports puts its installations under the /opt/local directory tree which is not in the PATH environment variable when Apache runs (Apache only knows about /usr, /usr/bin, /usr/local/bin, etc. - you can verify this under the phpinfo screen).
From the terminal:
sudo ln /opt/local/bin/gs /usr/bin/gs sudo ln /opt/local/bin/ps2ascii /usr/bin/ps2ascii
Adding additional Modules to PHP5
Beware: If you are uncomfortable compiling software from source on the command line then it is best to not attempt this proceedure. I am documenting this for the intrepid PHP5 users out there that may need specific compiled modules that Apple neglected to include in the stock PHP5 that ships with Leopard
First make a backup of your system.
Now that that is out of the way, here are the steps involved in re-compiling PHP5:
- Install XCode Developer Tools - From Leopard install disks
- Install X11 - From Leopard install disks
- Install MacPorts (http://www.macports.org) if it isn't already installed
Note: Due to a bug with the Apache server that shipped with OSX Leopard it is necessary to recompile Apache in order for PHP's linking to work properly
- Download (http://httpd.apache.org/download.cgi) the latest version of Apache (2.2.10 as of this writing).
- Gunzip and un-tar the source into the /tmp directory.
- Stop Web Sharing under System Settings
someone@macmini:~% sudo su Password: sh-3.2# cd /tmp sh-3.2# gunzip httpd-2.2.10.tar.gz sh-3.2# tar -xf httpd-2.2.10.tar sh-3.2# cd httpd-2.2.10 sh-3.2# ./configure --enable-layout=Darwin --enable-mods-shared=all sh-3.2# make install
From Macports install the following from the terminal:
sh-3.2# port install wget +ssl jpeg sh-3.2# port install openssl
And then, finally, recompile PHP5. In this example I am adding the SOAP, GD, and SSL modules. For other modules you will have to refer to the PHP documentation at PHP.net (http://php.net)
sh-3.2# MACOSX_DEPLOYMENT_TARGET=10.5
CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe -no-cpp-precomp"
CCFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe"
CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -pipe"
LDFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -bind_at_load"
sh-3.2# ./configure --prefix=/usr
--mandir=/usr/share/man --infodir=/usr/share/info --disable-dependency-tracking
--with-apxs2=/usr/sbin/apxs --with-ldap=/usr --with-kerberos=/usr --enable-cli
--with-zlib-dir=/usr --enable-trans-sid --with-xml --enable-exif --enable-ftp
--enable-mbstring --enable-mbregex --enable-dbx --enable-sockets
--with-iodbc=/usr --with-curl=/usr --with-config-file-path=/etc
--sysconfdir=/private/etc --with-mysql-sock=/var/mysql
--with-mysqli=/usr/local/mysql/bin/mysql_config --with-mysql=/usr/local/mysql
--with-openssl=shared,/opt/local --with-iconv=shared,/opt/local
--with-xmlrpc --with-xsl=/usr --without-pear --with-mime-magic=/etc/apache2/magic
--with-gd --with-png-dir=/usr/X11R6 --with-xpm-dir=/usr/X11R6
--enable-gd-native-ttf --with-jpeg-dir=/opt/local
--enable-pdo --with-pdo-mysql=/usr/local/mysql/bin/mysql_config
--enable-soap
sh-3.2# make
sh-3.2# make install
