Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Broken Apache configuration after upgrading to Yosemite

Yesterday I upgraded to Yosemite and now my local configuration for web development is not working anymore.

I managed to set up a userdir under /Users/user/public_html and I could access all the websites via localhost/~user/websitename. Nothing special, but it took me a while to configure.

Looking in the apache directory I saw that many files were replaced, keeping a backup. I tried putting back the files with my settings again, but still is not working. Maybe I'm missing some file that I don't remember.

This is httpd-userdir.conf:

# Settings for user home directories
#
# Required module: mod_userdir

#
# UserDir: The name of the directory that is appended onto a user's home
# directory if a ~user request is received.  Note that you must also set
# the default access control for these directories, as in the example below.
#
UserDir public_html

#
# Users might not be in /Users/*/Sites, so use user-specific config files.
#
Include /private/etc/apache2/users/*.conf
<IfModule bonjour_module>
       RegisterUserSite customized-users
</IfModule>

<Directory "/Users/*/public_html/">
    AllowOverride FileInfo AuthConfig Limit Indexes
        Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
        Order allow,deny
        Allow from all
</Directory>

Then in http.conf I have enabled some modules:

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

and this:

DocumentRoot "/Users/user/public_html"

Directory "/Users/user/public_html">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks MultiViews

    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride all

    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all

</Directory>

If I simply try to access localhost, it displays the message "It works!". If I go to localhost/user simply doesn't load and the same if I try to access one of the websites.

Did I miss any file? In the apache logs it doesn't even display any error.

like image 354
Carlo Avatar asked Oct 21 '14 10:10

Carlo


2 Answers

OS X 10.10 Yosemite comes with Apache 2.4 instead of Apache 2.2 in Mavericks.
The major difference in configuration is that you have to replace...

Order allow,deny
Allow from all

...with...

Require all granted

See Apache doc's manual Upgrading to 2.4 from 2.2 for more details.

UPDATE:
Please be aware that after upgrading OS X you will usually find your old config files as backups next to the new ones written by Yosemite. They are labeled e.g. httpd.conf.pre-update and/or httpd.conf~previous and can be found in the same paths as the new configs (e.g. in /private/etc/apache2).

like image 180
Jpsy Avatar answered Sep 20 '22 13:09

Jpsy


After attempting to fix this problem for 6 hours I was finally able to get this to work. I edited the httpd.conf, httpd-userdir.conf, httpd-vhosts.conf, etc to no avail. Leaving all of these files unedited from the yosemite configuration, what finally worked for me was to edit the httpd_server_app.conf located at /Library/Server/Web/Config/apache2/ by adding the following (for each site) as follows:

<Directory />
	Options +FollowSymLinks
	AllowOverride All
	Order deny,allow
	Deny from all
</Directory>

<Directory "/Library/Server/Web/Data/Sites/Default/">
	Options +Indexes +FollowSymLinks +MultiViews
	AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

<Directory "/Library/Server/Web/Data/Sites/[OTHER SITE DIRECTORY]/">
	Options +Indexes +FollowSymLinks +MultiViews
	AllowOverride All
	Order allow,deny
	Allow from all
</Directory>

Make sure if you use textedit to edit this file you undo the automatic insertion of the slanted quotation marks otherwise you will get a unicode error message.

Hope this helps!

like image 29
Bill Avatar answered Sep 19 '22 13:09

Bill