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

John Lukacs
John Lukacs
26,806 Points

How do I preview a php file in a web browser. Its not allowing me

Do any of you work on php files and know how toview them

6 Answers

Kevin Korte
Kevin Korte
28,149 Points

You'll need to install at a minimum apache.

My favorite all-in-package that will install and setup apache, mysql, and phpmyadmin (which you'll want all 3 with php) is Mamp

https://www.mamp.info/en/

John Lukacs
John Lukacs
26,806 Points

I believe I already have it Kevin so what do I do >>??

Kevin Korte
Kevin Korte
28,149 Points

By default, the php file will have to be inside of the htdocs folder, and than make sure in the Mamp control panel, that apache is running.

So typically, you can have htdocs >> project1 >> index.php and you could have htdocs >> project2 >> index.php

Than, your browsers url will be localhost/project1 will display the index.php file, and if you changed the url to localhost/project2 you'd would display that index.php file.

John Lukacs
John Lukacs
26,806 Points

How do I make sure apache is running I have mamp pro for now. I have made the folder htdocs and project one SO I did localhost/project1 and localhost/project1/suggest.php not found on both tries what If I buy the app code kit

Kristian Egebæk-Carlsen
Kristian Egebæk-Carlsen
9,189 Points

Hi John.

Alena Holligan has made 2 videos about setting up MAMP on your local development environment. Check them out

Windows https://teamtreehouse.com/library/setup-your-local-development-environment

Mac https://teamtreehouse.com/library/mac-local-php-dev-environment

I followed these instructions, and use MAMP every time I make websites. It really is a great little tool

John Lukacs
John Lukacs
26,806 Points

It not working for me man I put the file in htdocs and instead of showing the page I made its just saying "it works" Does it have to be called index.php or can I name the file anything with the php extension

John Lukacs
John Lukacs
26,806 Points

I have XAMPP and my old dreamveawer seems to have put files into that then I have MAMP that does not work

John Lukacs
John Lukacs
26,806 Points

I changed the port to 80 and 80 and now the server work start. I deleted the XAMPP but that did nothing