httpd
> Check version
httpd -v
Apache
> Start & version
sudo apachectl start
> Test localhost in browser
http://localhost
Setup user
> Create user Sites folder
mkdir ~/Sites
> Create or edit user apache .conf file, don't forget to replace USERNAME by yours
sudo nano /etc/apache2/users/USERNAME.conf
> Paste in USERNAME.conf
<Directory "/Users/*/Sites/">
Options Indexes MultiViews FollowSymLinks
AllowOverride All
Require all granted
</Directory>
httpd.conf
> Edit httpd.conf
sudo nano /etc/apache2/httpd.conf
> Uncomment these line to activate mandatories modules
LoadModule userdir_module libexec/apache2/mod_userdir.so
LoadModule alias_module libexec/apache2/mod_alias.so
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
LoadModule php5_module libexec/apache2/libphp5.so
> Change default apache user
_www
to
USERNAME
in httpd.conf
User USERNAME
Group staff
> Allow .htaccess and Override
<Directory "/Library/WebServer/Documents">
...
AllowOverride All
...
</Directory>
> Activate userdir conf
Include /private/etc/apache2/extra/httpd-userdir.conf
httpd-userdir.conf
> Edit httpd-userdir.conf
sudo nano /etc/apache2/extra/httpd-userdir.conf
> Uncomment or add this line at the end
Include /private/etc/apache2/users/*.conf
Restart apache
sudo apachectl restart
PHP test file
> Create php test file
printf "<?php phpinfo(); ?>" > ~/Sites/phpinfo.php
> Test phpinfo in browser
http://localhost/USERNAME/phpinfo.php
Auto start apache
> Set to auto start
sudo launchctl load -w /System/Library/LaunchDaemons/org.apache.httpd.plist
> Unset to auto start
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist
Created By
Metadata
Favourited By
Comments
No comments yet. Add yours below!
Add a Comment
Related Cheat Sheets