1

I have a very simple MAMP setup, with my index.php and related files in my htdocs folder. I was rolling along fine last night, being able to access the files by typing in things like localhost/index.php. Now, all of the sudden, I get 404s (file not found on this server) when I try to connect to any of the pages that are in my localhost folder or subdirectories of it.

What's more, when I just type in localhost, it shows me some of the directories but DOES NOT show any of my .php files, even though they show up when I perform a ls in the command line.

My MAMP app shows that I am connected to my Apache/MySQL servers. I can still access the localhost/MAMP homepage. But for some obscene reason, all of the sudden my php files are inaccessible. I have changed nothing inside of them! What's going on?

Edit: Turns out I needed to change the permissions of my php files -- they were set to read and write only for sudo and read only for everyone else. I ran chmod 777 on the applicable files and things were back to normal, but this begs several questions:

  • Why was it working earlier then changed without me ever modifying the file permissions?
  • Why should I have to make it writeable for other users to be able to access it on my local host as the admin user?
  • If I were to deploy this code in the wild (I know MAMP isn't used that often in the wild, but still), what would I do? Wouldn't creating these kinds of permissions result in serious security holes?

EDIT 2: Aaaaaand now it's not working again. Again, no changes made to file preferences, etc., just a few tweaks to the actual php files themselves. I don't have any sharing enabled under my sharing settings in System Preferences... this behavior is really starting to become frustrating.

user1427661
  • 11,158
  • 28
  • 90
  • 132

2 Answers2

0

Open Activity Monitor and make sure all instances of Apache and MySQL are closed. Sometimes MAMP has a tendency to not actually quit those processes and the next time you start it up they're still running and it generally messes with things (how's that for a technical explanation?).

Make sure there isn't any other process that's trying to use localhost for any reason. I came across this problem with POW installed. The POW process had stopped responding and it ended up interfering with MAMP's Apache.

Make sure that MAMP's settings haven't somehow been changes. I've seen MAMP revert custom document roots for seemingly no reason which can cause this.

I'd say even before any of this open your system preferences and make sure your Mac's own built-in Apache is off. You'll be able to see this in the Sharing section (it looks like its been moved in Mavericks however).

wgp
  • 1,147
  • 15
  • 15
0

Make sure you're not routing traffic through a VPN or SSH using Sidestep. I had this problem after going back to an old project I built with MAMP while working from a coffee shop.

Ken Prince
  • 1,437
  • 1
  • 20
  • 26