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.
The Hosts file on a Mac is found in the /etc/hosts folder.
There is no such thing as a localhost directory by default. You first have to install a web server, and then drop your files in the directory that is specified in the configuration.
Set up localhost on macOS You'll need to enable apachectl in Terminal to launch the requisite service for running localhost.
Find httpd. By default, Apache is enabled and installed in /etc/apache2/ , inside httpd. conf file, find DocumentRoot to tell where is the default localhost folder.
There are actually two place where where mac os x serves website by default:
/Library/WebServer/Documents --> http://localhost
~/Sites --> http://localhost/~user/
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With