`Apache` `localhost/~username/` not working `Apache` `localhost/~username/` not working apache apache

`Apache` `localhost/~username/` not working


Looks like you need to uncomment the following:

#LoadModule userdir_module libexec/apache2/mod_userdir.so

and

#Include /private/etc/apache2/extra/httpd-userdir.conf

Then in httpd-userdir.conf you may need to uncomment:

#Include /private/etc/apache2/users/*.conf

Lastly you would need to create /private/etc/apache2/users/kevin.conf if it doesn't exist. I think it should look something like this:

<Directory "/Users/kevin/Sites/">  Options Indexes MultiViews  AllowOverride None  Require all granted</Directory>

Make sure to restart the Apache server afterwards with:

sudo apachectl restart


For the rare person who spent as much time as I did wondering why none of the other resources or posts worked... this is for you. I spent 6 hours (at work) devoted entirely towards getting this damn permission issue solved and here was my solution. PLEASE NOTE: When I initially set out to solve this issue, I could access localhost (in Chrome), getting the desired output of It Works!. So make sure you can at least get that far before moving on.


I'm using PHP v5.5.14 on a Retina Macbook Pro (mid-2014) that is running OS X Yosemite (I tested this again using Apple's recent El Capitan update and confirmed to be a solution!). My problem was that I recieived a 403 ERROR stating that permission was denied whenever attempting to access localhost/~userDirName/. My solution involves 3 simple steps:

STEP #1:

Load the userdir module by finding the following two lines in /etc/apache2/httpd.conf and uncommenting them by removing the leading hash (#):

LoadModule userdir_module libexec/apache2/mod_userdir.soInclude /private/etc/apache2/extra/httpd-userdir.conf

STEP #2:

Navigate to /etc/apache2/extra/httpd-userdir.conf and uncomment the following line (in the same manner as step 1):

Include /private/etc/apache2/users/*.conf

STEP #3:

Edit /etc/apache2/users/fileYouMade.conf. You must add Require local and a + character before each argument that is option-specific. The result will look like this:

<Directory "/Users/user/Sites/">    Options +Indexes +MultiViews +FollowSymLinks +SymLinksIfOwnerMatch +ExecCGI    AllowOverride All    Require local    Order allow,deny    Allow from all</Directory>


here's a script i wrote because i got tired of googling how to do this every time i upgrade os x.

#!/bin/sh# edit httpd.conf to allow home directories.# some day just rip out httpd and replace with nginxbin=$(basename "${0}")conf="/etc/apache2/httpd.conf"if [ $(id -u) -ne 0 ]then  echo "ERROR: ${bin} must run as root. goodbye."  exit 1fi# make backup filen=1while [ -f "${conf}.bak.${n}" ]do  let n=${n}+1donecp "${conf}" "${conf}.bak.${n}"# edit httpd.conf in place - uncomment out two linessed -i ''                                                                 \    -e '/^#.*[[:space:]]userdir_module[[:space:]]/s/^#*//'                \    -e '/#Include \/private\/etc\/apache2\/extra\/httpd-userdir.conf/s/^#//'   \    "${conf}"echo "INFO: ${bin}:"echo "INFO: ${bin}: check that this looks OK"echo "INFO: ${bin}: % cat /private/etc/apache2/extra/httpd-userdir.conf"echo "INFO: ${bin}:"cat /private/etc/apache2/extra/httpd-userdir.confecho "INFO: ${bin}:"echo "INFO: ${bin}: in particular, that '/private/etc/apache2/users/*.conf' files look OK"ls /private/etc/apache2/users/*.confecho "INFO: ${bin}:"echo "INFO: ${bin}: hint: check for /private/etc/apache2/users/${SUDO_USER}.conf"if [ -f "/private/etc/apache2/users/${SUDO_USER}.conf" ]then  echo "INFO: ${bin}: /private/etc/apache2/users/${SUDO_USER}.conf exists. See if it is OK."else  echo "INFO: ${bin}: /private/etc/apache2/users/${SUDO_USER}.conf does NOT exist."fi  echo "INFO: ${bin}:"echo "INFO: ${bin}: here is a sample conf file (with php and perl enabled)."echo "INFO: ${bin}:"cat<<!<Directory "/Users/${SUDO_USER}/Sites/">  Options Indexes MultiViews FollowSymLinks  AllowOverride All  Order allow,deny  Allow from all  Require all granted  Options +ExecCGI  AddHandler cgi-script .cgi .pl</Directory>!echo "INFO: ${bin}:"echo "INFO: ${bin}: restarting apache httpd"sudo apachectl restartecho "INFO: ${bin}:"