The aim of that quick and dirty tutorial is a fully functional web server running from any usb-drive on mac OS X (10.4) and maybe on other unix / linux distributions. For sure the following descripts seem to be very comlicated and confusing but it’s a step by step guid to build your own MAMP (MacApacheMysqlPhp) which will be a lot more flexible because it’s independet of any local settings. I call it portable MAMP or just pMAMP.
As MAMP it‘ not made to run a public web server because of a whole lot of outstanding security holes.
Also its a kind of unflexible because of the static path names (‚COMPSPINE‘) but it’s just a question of the right script (perl seems to be a good for me).
Status: Apache and PHP working perfect. MySQL not really.
– A USB Stick
– Mac OS 10.4 (10.3 not tested)
– Installation of Apple Developer Toolkit, available at: http://developer.apple.com/tools/download/
Folder structure on the USB-drive / USB stick
Get an USB-Stick, plug it into your Mac and open Disk Utility. It can be started in Finder in the folders Applications and then Utilities or simply by a Terminal command like that:
We want to partition a MS DOS drive which can be read by either win32 and Unix plattforms. Within the Disk Utility you should see a orange colored drive named like your USB-stick inside Finder. Select it and chose the ‚Partition‘ tab on the right hand side. Select MS DOS form the drop down menu and change the partition size if you want to. Finaly press ‚partition‘ and confirm it by clicking OK. Take care that you backup all your important data form your stick in advance because partitioning delets everything. As long as any application accesses the USB drive Disk Utility can’t unmount the drive which is necessarry before starting the partitioning process.
2. Install Apache on USB drive
Download Apache-2.0.58 on your Desktop from
Open your Terminal and type:
Your favorite editor should appear with the httpd configuration file. Search for the line „Listen 80“ and change it to „Listen 8080“ (use an other port if that on is used by an other application like tomcat e.g.). Replace line:
As well replace
Replace the line:
HTTPD=’/Volumes/COMPSPINE/mac/apache-2.0.58/httpd’Back in Terminal type:
If the URL ‚127.0.0.1:8080‘ appears within the adress line in your Safari your Apache2 is running.
3. Install PHP
Try to download PHP on your Desktop from (URL may change after a while): http://de3.php.net/get/php-5.2.5.tar.bz2/from/a/mirror
Extract the file on your Desktop and:
Stop the Apache to avoid conflicts
Do some hard coding as a work around (I could figure out which option flag of the following ./configure comand would be a better solution):
my $httpd = get_vars(„sbindir“) . „/“ . get_vars(„progname“);
my $httpd = „/Volumes/COMPSPINE/mac/apache-2.0.58“ . „/“ . get_varsNow we are going to configure a Makefile to compile PHP:
Compile your PHP
(I got a warning after ‚make‘)Now we need a php.ini file
Look for somethin similar like „LoadModule php5_module modules/“ an add the line
LoadModule php5_module modules/libphp5.soSearch for anything like „AddType application/“ and add the line
AddType application/x-httpd-php .php .phtml
(you can add other file endings as well)Now we have to sheet a little bit. Go to http://www.mamp.info/en/index.php and download a fresh copy of MAMP (don’t take the pro version). After mounting the .dmg file we going to borrow just one file:
After doing that you can unmount and delete MAMP
Start Apache again:
Finaly lets see if PHP is working. Therefor we need to have a test file.
An editor called ‚vi‘ appears within the terminal windos. Even if you don’t see anything type:
Now press escape once and type (again in the command mode of ‚vi‘) ZZ
Vi should closes and you will see all your terminal stuff again.
Replace the line:
$MYSQL = ‚/usr/local/mysql/bin/mysql‘; # path to mysql
$MYSQL = ‚/Volumes/COMPSPINE/mac/mysql-5.0.45/bin/mysql‘; # path to mysql
Safe and close the file.
Instead of ‚password root‘ you should be creative to chose your own password
For me this is not teh perfect way to start the mysql server but it should work. It would be better to use a different –socket path then /tmp. That means that we are accessing the local hard disc. The option –socket=/Volumes/COMPSPINE/mac/mysql-5.0.45/tmp/mysql.sock results in the following error:
071209 17:51:12 InnoDB: Started; log sequence number 0 43655
071209 17:51:12 [ERROR] Can’t start server : Bind on unix socket: Invalid argument
071209 17:51:12 [ERROR] Do you already have another mysqld server running on socket: /Volumes/COMPSPINE/mac/mysql-5.0.45/tmp/mysql.sock ?
071209 17:51:12 [ERROR] Aborting
I have multiple mysql servers on my system but none of them accesses that tmp folder. Its allmost caused by wrong priveleges but my tmp folder is owned by either mysql user and group. Also the bin/mysqld is owned by mysql and his group.
It’s often good to know how kill that particular process. Use:
Any suggestions to fix that?