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

Sean Pierce Sumler
Sean Pierce Sumler
18,968 Points

After renaming file form index.html to index.php MAMP no longer serves the site.

Hey everyone. I'm having some trouble here.

I'm following along with the "Build a basic PHP site" course. I have MAMP installed and I am successfully serving my project files locally. However, after renaming my index.html file to index.php, the page is no longer served.

I've tried digging around MAMP to see if there is some information/ setting that could help but I'm not finding a solution. It would be great if anyone has info on how this could be solved. Thanks!

Mikkel Rasmussen
Mikkel Rasmussen
31,772 Points

Some more info would be great - how does your link look like? and a screenshot of the project structure would also help us a lot :)

Simon Coates
Simon Coates
28,694 Points

I'm not an expert by any stretch, but i'd confirm you're using the right URL (using the localhost url and a .php extension). If the URL is good, then I'd look at the php itself (start with something you can't possibly get wrong like hello world), then maybe look at the server setup. If PHP is turned on, you should get something back. (try looking at page source). I'm not familiar with mamp, but in wamp, xampp, there's a default page for the local host page that should confirm that your server is up, and processing .php correctly. That's always a good start. Good luck.

Sean Pierce Sumler
Sean Pierce Sumler
18,968 Points

Simon Coates , Mikkel Rasmussen The project structure is a <p> tag that reads "test" so there isn't much to see there. And the link is localhost/Sites/index.php

It worked as it should when serving the index.html file (localhost/Sites/index.html). So I know the MAMP server is working. However after changing the file name to index.php I tried to serve localhost/Sites/index.php and I received a 404 message.

Simon Coates
Simon Coates
28,694 Points

I had to ask about the url. Treehouse students vary wildly in terms of skill level, i was just making sure you weren't accessing the .html using file:/ (leading to an incorrect assessment of the server running) , using the wrong url, had accidentally named your file 'index.php.html' or were confused about where your .php file should be placed in the directory (i know some of the bundled PHP stacks have different base directories). if the server is actually serving pages (implies port is fine, server is on, I guess), and you're not getting unprocessed PHP (php is wired up), then you've already ruled out all the problems i know how to solve. I've took a look online and didn't see anything that quite matched up your problem. sorry.

Joe Schultz
Joe Schultz
6,191 Points

Do you have any PHP code in your index.php file? If not, open the index.php file in your text editor and echo out the word "test" in the <p> tag. Save the file and try to open it in your browser.