logo

Weblog

Host webpages from your ~ directory on a mac

How-to host web pages from your home directory, like from ~/Sites to http://localhost/~username This works for most recent mac versions, I did it on 10.14.2.

Fri 21 Dec 2018 / André / 0 comments

I always like to host a lot of my frontend projects from my local machine, quite old fashioned from my home directory, recognized by `~` on unix. This is how to do that.

$ cd /etc/apache2
$ open .
Open `http.conf` in your favorite editor (I like BBEdit, it helps you do sudo stuff). Find the following line and remove the `#` in front of it.
LoadModule userdir_module libexec/apache2/mod_userdir.so
Do the same for the following line.
Include /private/etc/apache2/extra/httpd-userdir.conf
Open the `httpd-userdir.conf` configuration file in the directory `/etc/apache2/extra`. Enable the following line by removing `#` in front of it.
Include /private/etc/apache2/users/*.conf
And then for every user for who you like to enable this functionality, you include a file `username.conf` with something like this configuration in the directory `/etc/apache/users/`. This example enables quite al lot of stuff - like directory indexes - which I like during development.
<Directory "/Users/username/Sites/">
  AllowOverride All
  Options Indexes MultiViews 
  Options +FollowSymLinks
  Require all granted
</Directory>
Check if your Apache's configuration is correct and restart with the following commands:
$ sudo apachectl configtest
$ sudo apachectl restart
And find the web pages on your mac in `/Users/username/Sites` hosted on http://localhost/~username

0 comments

RSS feed

Tweet this article

geschiedenis

Dit is de zoveelste incarnatie van mijn website wie nieuwsgierig is kan de

oudere 'recente' wijzigingen bekijken.

En ik heb hier een pagina waarop ik nieuwe en oudere versies van my_editors verzamel.