PHP won't appear in my local host

1k views Asked by At

So I'm very new to programming and php. I installed MAMP (I'm on a mac), am using the default ports and wrote a short html document that I saved as index.php.

I saved it in a folder called "test" within the HTDOCS within the MAMP app.

I then go into my browser and type: localhost:8888/test/index.php, but keep getting a 404 error. What am I doing wrong? Thanks so much.

3

There are 3 answers

1
pbu On

Try the following URLs without the port 8888

http://localhost/test/index.php
http://127.0.0.1/test/index.php

Is it working?

If not,here is a probable fix

Edit the /etc/hosts in your mac

sudo nano /etc/hosts

then add these lines to the file for MAMP to work

127.0.0.1   localhost
255.255.255.255 broadcasthost
::1             localhost 
fe80::1%lo0 localhost
1
Adam On

If you get 404 its probably wrong dir

Have a look at mamp app and double check dir.

https://i.stack.imgur.com/Go4E5.jpg (10 rep to upload at stack)

Document root

0
Ian On

Wow, I feel like such a newbie, I had installed WordPress locally using MAMP and so consequently had it sent to the WP folder on my desktop instead of HTDOCS. As soon as I rerouted it, putting in localhost:8888/testsite/index.php worked just fine. Thanks so much for your help!