|
Written by Kirby
|
|
Friday, 20 June 2008 13:38 |
MAMP is great. Almost everyone I know who works on a Mac and does development runs MAMP.
That said, getting certain things to work on MAMP seems to be a black art. There are plenty of posts in the forums with the theme of "uh, that didn't work for me...". Just to add to the body of dubious information, I'm posting my MAMP techniques that may or may not work for you.
Before continuing with this, do one thing right now. Backup your httpd.conf. Do it now before you possibly butcher it, kill your MAMP install and try to contact me with your virulent all-caps inspired hatred. Copying it to httpd.bak.conf is good. Copying it to httpd.yearmonthday.conf works too. Just do yourself a favor and back it up.
OK, next. The techniques described in this article are for your development machine. Yeah, I guess you might find a line or two that will help you on a production server. But, the bottom line is that these are quick and dirty techniques to get multiple sites and ssl running on your MAMP install. If you are planning on replacing your production httpd.conf with what's described here, you'd be playing Russian Roulette with your site.
Caveats aside, first the multiple sites thing. This isn't too tough. All I had to do was add the following to httpd.conf:
NameVirtualHost *
DocumentRoot /Applications/MAMP/trunk
ServerName www.sometremendoussite.com
ErrorLog logs/host.sometremendoussite.com-error_log
TransferLog logs/host.sometremendoussite.com-access_log
DocumentRoot /Applications/MAMP/someotherdirectory
ServerName www.stuffonmycatepillar.com
ErrorLog logs/host.stuffonmycatepillar.com-error_log
TransferLog logs/host.stuffonmycatepillar.com-access_log
I have a script that replaces my /etc/hosts and runs:
sudo kill -HUP `cat /var/run/lookupd.pid`
(I just found out that the above line only works up until Leopard, which requires: sudo dscacheutil -flushcache)
I'm assuming you have your own favorite technique for tricking your Mac into thinking it runs various domains.
Alright, easy stuff out of the way. The signing stuff took me a while. I followed some instructions I found on MAMP forums but had mixed results.
For the most part I followed the key generation steps on Apple's mod_ssl page.
However, I had some significant departures:
- I placed the generated files in different directories, /Applications/MAMP/conf/apache/ssl.key/ and /Applications/MAMP/conf/apache/ssl.crt/server.crt
- There were several directives that failed under MAMP. I'm providing my httpd.conf in this article. You can do your own comparison.
- After getting all this sorted out, I still got this error message in my Apache error log:
[Fri Jun 20 08:28:17 2008] [error] Init: Unable to read pass phrase [Hint: key introduced or changed before restart?]
[Fri Jun 20 08:28:17 2008] [error] SSL Library Error: 218710120 error:0D094068:asn1 encoding routines:d2i_ASN1_SET:bad tag
[Fri Jun 20 08:28:17 2008] [error] SSL Library Error: 218529960 error:0D0680A8:asn1 encoding routines:ASN1_CHECK_TLEN:wrong tag
[Fri Jun 20 08:28:17 2008] [error] SSL Library Error: 218595386 error:0D07803A:asn1 encoding routines:ASN1_ITEM_EX_D2I:nested asn1 error
[Fri Jun 20 08:28:17 2008] [error] SSL Library Error: 218734605 error:0D09A00D:asn1 encoding routines:d2i_PrivateKey:ASN1 lib
Maybe there's a hack for me to force the passphrase into the MAMP startup. I ripped the passphrase out. Alter your server.key file from the command line:
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
OK, between all this, hopefully you can figure it out. I opted to combine my ssl.conf and httpd.conf into just the httpd.conf.
See if you have any luck with this file after you remove the '.txt' suffix:
httpd.conf.txt. Make sure you edit this line to fit your local environment:
User yourlocalmacuser |