Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP

MAMP server problems

I downloaded the MAMP program, installed it, changed the Apache Port setting from 8888 to 80, but when I click the "Start Servers" button, the Apache Server indicator light glows green, but the MySQL Server indicator remains RED. What do I check?

12 Answers

Hi Ralph. How are the rest of preferences set?

on 'Ports' make sure Apache Port is: 80 and MySQL Port is: 3306

on 'PHP' make sure PHP Version 5.4.10 is selected

on Apache make sure Document Root is set to: /Applications/MAMP/htdocs

Hope this helps. When you go to start servers you will be asked to enter your user password.

I set the settings required, the only difference I noticed is that I have PHP V 5.4.3 and I don't know how to replace it.

The reason I am looking into this is because on the Shirts 4 Mike page, when I hit the "Shirts" icon, I get the message: NOT FOUND The requested URL /shirts.php was not found on this server. The url says http://localhost/shirts.php Also noticed that on the home page the footer appears to show twice.

I looked through the files and found MANY php.ini files, one of them is the correct version. Does it automatically select the necessary one? Also, it is listed as opening with TextEdit...do I change that to open with Safari?

OK, when I bring up the MAMP server, where the selection bar is start/stop|Ports|PHP|Apache to make a selection, the PHP Version has two choices, the 5.2.17 or the 5.5.3 and I cannot make it change that. I set the ports as described, but I still get the red light on the MySQL server. I am at a standstill.

Ralph, to change the PHP version visible in the MAMP preference panel is non-intuitive. I've had to do this before when I needed 5.3 for a Drupal install.

What you need to do is navigate through your computer's file structure like so:

Applications -> MAMP -> bin -> php

Now you'll see all the versions of PHP that are installed. Rename the folder of the versions you don't want displayed in your menu. I put a dash in front of mine, so it looks like this: "-php5.2.17".

Now close down MAMP server and restart. If all went well, you'll notice your menu has changed to display the ones you want on there.

O,K., So I've spent HOURS trying, no, TWO DAYS trying to get this thing going past this point. I am ready to quit. what is the point? Apache root is /applications/MAMP/htdocs I have an error log that says:

[18-Nov-2013 01:26:16 Europe/Berlin] PHP Warning: include(inc/header.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:26:16 Europe/Berlin] PHP Warning: include(): Failed opening 'inc/header.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.3/lib/php') in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:30:55 Europe/Berlin] PHP Warning: include(inc/header.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:30:55 Europe/Berlin] PHP Warning: include(): Failed opening 'inc/header.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.3/lib/php') in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:33:56 Europe/Berlin] PHP Warning: include(inc/header.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:33:56 Europe/Berlin] PHP Warning: include(): Failed opening 'inc/header.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.3/lib/php') in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:37:16 Europe/Berlin] PHP Warning: include(inc/header.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/index.php on line 1 [18-Nov-2013 01:37:16 Europe/Berlin] PHP Warning: include(): Failed opening 'inc/header.php' for inclusion (include_path='.:/Applications/MAMP/bin/php/php5.5.3/lib/php') in /Applications/MAMP/htdocs/index.php on line 1

Ralph, don't give up. The PHP Warnings you have posted above explain what the problem is. On the line 1 of the file you are trying to open, which looks like htdocs/index.php there is an include that does not exist. So on line 1 you'll see something like this: <?php include( 'inc/header.php' ); ?>

So you first need to check whether that file exists in htdocs/inc/. If not, figure out where it is located and you'll be able to link to it.

the first line in my htdocs/index.php is exactly this:
<?php include('inc/header.php'); ?>

My index file was in the htdocs folder, not under the inc folder, so I changed it to the inc folder, and the problem is worse. i don't want to even describe what it did. I'm going to put it back, but I am still on hold, and I cannot figure out what's wrong.

ok, so I put everything back, and now none of it works. I am tired of this. maybe, MAYBE, i'll be back.

Index.php should be at the base level, i.e. in the htdocs folder. The path of the code on line 1 of index.php is telling the interpreter to look in the folder inc where it should find a file called header.php. The error message: PHP Warning: include(inc/header.php): failed to open stream: No such file or directory in /Applications/MAMP/htdocs/index.php on line 1 is stating that header.php cannot be found. So you must check to see if it exists.

You might do better starting with reinstalling MAMP. I have just downloaded it from mamp.info, loaded the default settings and dropped the project files from stage 6 into htdocs and everything worked out of the box. So rather than chasing errors, that might be a better solution for you. Get it running, then play around with the MAMP settings.?