Apache localhost 403 error with Yosemite Apache localhost 403 error with Yosemite apache apache

Apache localhost 403 error with Yosemite


You do NOT want to open up the entirety of your hard drive to the web server process. In fact, lines 215-217 of httpd.conf say:

# Deny access to the entirety of your server's filesystem. You must# explicitly permit access to web content directories in other# <Directory> blocks below.

Apache 2.4 (OSX 10.10 Yosemite) has a different structure from Apache 2.2 (OSX 10.9) for the Directory directive in Module mod_authz_core.

EDIT: If you are setting up Apache from the START, please follow this instruction set to setup apache and php on OSX 10.10 Yosemite.

Assuming you have mod_userdir.so enabled already, your problem is within your user .conf file (/etc/apache2/users/username.conf), edit (or add) the following.

Apache 2.2:

<Directory "/Users/jnovack/Sites/">  Options Indexes MultiViews  AllowOverride All  # OSX 10.9 / Apache 2.2  Order from deny, allow</Directory>

Apache 2.4

<Directory "/Users/jnovack/Sites/">  Options Indexes MultiViews  AllowOverride All  # OSX 10.10 / Apache 2.4  Require all granted</Directory>


Edit the file:/private/etc/apache2/httpd.conf

on line 250 (in Yosemite) change:

Options FollowSymLinks Multiviews

to:

Options FollowSymLinks Multiviews Indexes

then in the Terminal run:

sudo apachectl restart


This might be very late answer but i did followed most of Stack Overflow solutions, None of them helped me for various reasons. So i did reset my device as a fresh Yosemite OS to get this localhost working on Mac Yosemite (with Symlinks too),

Steps I did exactly :

sudo nano /etc/apache2/httpd.conf

Uncomment the following lines:

#LoadModule php5_module libexec/apache2/libphp5.sotoLoadModule php5_module libexec/apache2/libphp5.so#LoadModule userdir_module libexec/apache2/mod_userdir.sotoLoadModule userdir_module libexec/apache2/mod_userdir.so#Include /private/etc/apache2/extra/httpd-userdir.conftoInclude /private/etc/apache2/extra/httpd-userdir.conf

Save and Exit (Ctrl+X press Enter and press Y and enter again)

sudo nano /etc/apache2/extra/httpd-userdir.conf

and uncomment the following line at line 16:

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

Save and Exit (Ctrl+X press Enter and press Y and enter again).

Now go to apache Users folder to check your configuration file exist or not

cd /etc/apache2/users/

if you do not have configuration file in this folder, create one by

sudo nano /etc/apache2/users/<**YOUR USERNAME**>.conf

Replace <YOUR USERNAME> with the name of your machine (type whoami in terminal and enter that name).

after creating .conf file , copy below lines into that file

<Directory "/Users/<YOUR USERNAME>/Sites/">    AddLanguage en .en    LanguagePriority en fr de    ForceLanguagePriority Fallback    Options Indexes MultiViews    AllowOverride None    Order allow,deny    Allow from localhost     Require all granted</Directory>

save and Exit

Now restart your apache

sudo apachectl restart

Now go to your browser and type localhost, it should work as expected,

Just as a Note: if it does not work even after try restarting your computer

create index.html as exactly index.html.en that you should find here:

open /Library/Webserver/Documents/

right click on index.html.en and duplicate it to index.html leaving original as it is

try again in browser and if you have success, you can delete the duplicated file

Just to be clear, leave the original file index.html.en where it is, untouched and unharmed throughout this step.

Not sure why I had to take this mysterious detour - probably something local to my machine, but if you're having trouble after following the guide above, see if it helps.

SymLinks :

if you have success, in Browser you should see

It works!

Now create symlink to any your project.

ln -s <Path_to_your_Project(index_file)> <Path_to_webroot>

For example if you have project folder in your Documents folder ,then point webroot to your index file by

ln -s /Users/<YOUR USERNAME>/Documents/project/ /Library/Webserver/documents/projectlink 

you might need permission to create symlink (Use above command with Sudo)

Configure apache to follow symlinks ( Thanks to tomvon, i do not enough points to vote you)

sudo nano /private/etc/apache2/httpd.conf

on line 250 (in Yosemite) change:

Options FollowSymLinks Multiviews

to:

Options FollowSymLinks Multiviews Indexes

then in the Terminal run:

sudo apachectl restart

Now go to localhost/projectlink to see if your project index file shows here on browser.

Happy Coding..