Archive by Author

Fix MAMP: Apache won’t start but MySQL will

If your MAMP will start MySQL just fine but won’t start Apache there is likely 2 problems you’re facing.

  1. Port number conflict, or
  2. Apache related error that for some reason doesn’t show up in the MAMP apache logs.

How to Fix the port conflict in MAMP and Apache on Mac OS X

You need to disable web sharing. Web sharing intercepts communication going to port 80 which is the default port for websites and since MAMP is set to start by default on port 80 there is a conflict because Mac OS X Apache server already has the port reserved.

To enable or disable Web Sharing (Apache):

  1. From the Apple menu, choose System Preferences.
  2. From the View menu, choose Sharing.
  3. To enable Web Sharing, select the Web Sharing checkbox.
    To disable Web Sharing, deselect the Web Sharing checkbox.
  4. Close Sharing preferences.
If you’ve disabled web sharing and it’s still not working, try changing your Apache port to something like 8888 or 8889, these usually work for me. If this still doesn’t solve your problem then you’re most likely dealing with problem #2

How to fix the Apache not starting in MAMP problem

First you need to figure out what the problem is, but in my experience 9 times out of 10 it’s an apache config problem.

Open up a terminal and type change directories to wherever you installed MAMP, in my case it’s /Applications/MAMP/

crainbandy$ cd /Applications/MAMP/bin/

Once you’re in this directory you can call the shell script that typically starts the MAMP Apache server through the interface, type what’s below in your /MAMP Intall directory/MAMP/bin

crainbandy$ ./startApache.sh
Syntax error on line 368 of /Applications/MAMP/conf/apache/httpd.conf:
DocumentRoot must be a directory

Boom. It’s obvious what the problem is now. We need to modify our httpd.conf file to change the DocumentRoot to a folder that actually exists on our computer. This in my experience fixes the problem.

If you’re still having trouble post in the comments and we’ll see what we can do. The Apache error logs in MAMP are useless though because they don’t actually log the apache2 errors, if anyone knows where this log is please let me know, but I can’t find it.

Find text in Files recursively on Linux and Mac OS X

Ever had a page that says something like “Test” on it, and you have no idea where that page is? I know you have and that’s why you’re here. You’ve thought to yourself “If I could just search to find the text in files recursively it would make my life so much easier!” and it does.

I’ll give you an example. Recently I was working on a Drupal project using advanced forum and I had this ridiculous block “What’s going on?” below my forum and I didn’t want it there. Going through file by file wasn’t exactly what I envisioned my day to be so I started looking around for a simpler way to find text in files using linux but I wanted it to work on Mac OS X too because I run production on Linux and Development on Mac OS X.

The baby-making-magic time-vampire killing power is below

grep -lir "some text" *
// or
find /path -name *.txt | grep -lir "some text" *

Sample output

bmaxwell$ grep -lir "What's going on" *
./modules/advanced_forum/styles/naked/.svn/text-base/advf-forum-statistics.tpl.php.svn-base
./modules/advanced_forum/styles/naked/advf-forum-statistics.tpl.php

Obviously the first one is the svn base file for that revision so we can ignore it. The second asshole causing all of the trouble known to man-kind contains exactly what I’m trying to find so I can use my DELETE button, or modify it.

Tetco rewards cards are bullshit.
Bryan

Getting the available variables in Drupal

It’s simple but it’s a complete headache if you’ve had this problem and found this post (or a similar one) trying to do what this function does. What I mean when I say “Get available variables” or “Get the available variables in Drupal” or “Find the available variables in PHP” or any number of combinations you’re still havin the same problems.

Get the available (defined) variables in Drupal

You want the variables available to you in a PHP script. This is tailored for Drupal only because it’s the reason I came across it FOR a PROBLEM I was having in Drupal. It’s what I use this function the most for but I can see this having seriously  dynamic capabilities if used correctly (I’d elaborate, but it’s too genius… it seems. I want to play around with it first. Think Russian doll situation (while maintaining the same size, but not relationally) with a level of granularity where weight wasn’t a factor, it could be an axis position on axis’ with one object allowing large amounts of array data and non-scalar information between-themselves to be displayed at a dashboard-like interface. Maybe I’m making it a Drupal module, maybe I’m not.)

The code is!

// Get the available aka "defined" vars available to Drupal
print_r(get_defined_vars());

Pretty simple like I said but if you’ve ever been there you’ll thank me every day. Every. Single. Day.

WAM BAM THANK YOU MA’M.
Bryan

25 Google Wave Invites

Who wants one?! Post a comment!

List of Geocode APIs with Rate Limits and Features

https://webgis.usc.edu/Services/Geocode/About/GeocoderList.aspx

Don’t bother with Yahoo! or Google. They rate limit you, some of the services in the link above do not.