Where is localhost folder located in Mac or Mac OS X?

PhpMacosEclipse Pdt

Php Problem Overview


I just started developing PHP projects on my mac (using PDT) and was wondering where localhost is located? How does Mac OS X serve websites, I haven't changed any settings during the installation of PDT.

Php Solutions


Solution 1 - Php

There are actually two place where where mac os x serves website by default:

/Library/WebServer/Documents --> http://localhost

~/Sites --> http://localhost/~user/

Solution 2 - Php

The default Apache root folder (localhost/) is /Library/WebServer/Documents

Also, make sure you have the PHP5 module loaded in /etc/apache2/httpd.conf

LoadModule php5_module libexec/apache2/libphp5.so

Solution 3 - Php

For posterity

I never use PHP so I completely forgot where apache was installed on my mac as it was running on port 8080 mocking me, installed in a non-standard path. After giving up on the internet, I tried this...

httpd -t -D DUMP_INCLUDES

Because httpd was running it produced the httpd.config path and then the clouds parted and the sun shown brightly on my face. Victory! as within it lies the path to localhost.

ServerRoot "/your/path"

Solution 4 - Php

If you use apachectl to start or stop, then you can find it with this command

apachectl -t -D DUMP_RUN_CFG

Solution 5 - Php

Actually in newer Osx os's, this is stored in /Library/WebServer/Documents/

The .en file is just an html file, but it needs special permissions to change, so I just made a folder for my stuff and then accessed it by user.local/Folder/file.html

Solution 6 - Php

I realized you need to start service first.

  1. Start apache service sudo apachectl start

  2. Test in browser by hitting localhost You should get "It works" message in the browser

  3. Serve your files inside /Library/WebServer/Documents folder. Make directories if necessary.

Important: Notice in step 3 that it is /Library and not ~/Library

> Tested in MacOS 11.2.3 Big Sur

Solution 7 - Php

There's no such thing as a "localhost" folder; the word "localhost" is an alias for your local computer. The document root for your apache server, by default, is "Sites" in your home directory.

Solution 8 - Php

Macintosh HD/Library/WebServer/Documents

Macintosh HD is the name of your HD

If you can't find it: Open Finder > click "Go" at the very top > Computer > Your HD should be there. You can drag and drop the HD to favorites on the left.

Solution 9 - Php

open the 'Finder' in Mac and Command+Shift+G and type in the path:/usr/local/zend/apache2/htdocs. path will open then create/paste your web page/application then check it on the browser.

Solution 10 - Php

Applications -> XAMPP -> htdocs This is the place where you should put your files for the website you're building.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionTassistoView Question on Stackoverflow
Solution 1 - PhpChris MuenchView Answer on Stackoverflow
Solution 2 - PhpMcKaylaView Answer on Stackoverflow
Solution 3 - PhpKing FridayView Answer on Stackoverflow
Solution 4 - PhpOlusola OmosolaView Answer on Stackoverflow
Solution 5 - Phpuser6120108View Answer on Stackoverflow
Solution 6 - PhpbikramView Answer on Stackoverflow
Solution 7 - PhpErnest Friedman-HillView Answer on Stackoverflow
Solution 8 - PhpRodrigo CarvalhoView Answer on Stackoverflow
Solution 9 - PhpRajesh MView Answer on Stackoverflow
Solution 10 - PhpDragiView Answer on Stackoverflow