Finder
or Spotlight
to find this file may prove difficult as by default it's private and owned by the root
user. Note: One way to open this is by using a Unix based text editor in the Terminal, for examplenano
, and because the file is owned byroot
we'll use thesudo
command to open it (asroot
) so for example type the following into theTerminal
Application (after, it will prompt for a password):sudo nano /private/etc/apache2/httpd.conf
Noteworthy nano commands:^w
(search),^o
(save), and^x
(exit) where^
represents the Ctrl key. Nocti (jam version) mac os.
Note: Versions of Mac OS X prior to 10.5 were bundled with older versions of PHP and Apache. As such, the Apache configuration file on legacy machines may be /etc/httpd/httpd.conf.
Note:Before Mac OS X 10.5 (Leopard), PHP 4 was bundled instead of PHP 5 in which case the above instructions will differ slightly by changing 5's to 4's.
DocumentRoot
This is the root directory for all the web files. Files in this directory are served from the web server so the PHP files will parse as PHP before outputting them to the browser. A typical default path is /Library/WebServer/Documents but this can be set to anything in httpd.conf. Alternatively, the default DocumentRoot for individual users is /Users/yourusername/Sitessudo apachectl graceful
in the shell or stop/start the 'Personal Web Server' option in the macOS System Preferences. By default, loading local files in the browser will have an URL like so: http://localhost/info.php Or using the DocumentRoot in the user directory is another option and would end up looking like: http://localhost/~yourusername/info.phpphp -v
to check the PHP version of this PHP binary. A call to phpinfo() Tavern mac os. will also reveal this information.