Every time I upgrade OS X something breaks with apache or php or both.
The steps for me to fix it this time was…
* Open your httpd.conf file
* uncomment the Load php5 module
* uncomment the load vhosts module
in etc/apache2/users
* duplicate Guest.conf to harrybailey.conf – replace harrybailey with your username obviously
* edit harrybailey.conf to read:
<Directory "/Users/harrybailey/Sites/">
Options Indexes MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
Note: as Michal mentions below you may want to add +FollowSymLinks to your options too. This allows the system to follow any symbolic links you have set up.
AGAIN – replace harrybailey with your username.
* save the file
You may also get a php error which includes…
“It is not safe to rely on the system’s timezone settings”
The fix for that is
* navigate to /etc/ and rename php.ini.default to php.ini
* edit your new php.ini file – find “;date.timezone = ” (no brackets)
* update it to read “date.timezone = Europe/London” (no brackets) – if you aren’t on GMT then find your relevant timezone string and use that
* save the file
* open terminal
* submit the line:
sudo apachectl restart
That did it for me. Hopefully it will do it for you too.
I was first seeing the default html file in the /Library/Webserver/Documents folder
I was then seeing 403 errors for all vhosts that I has setup
Personally I saw these problems after upgrading from Lion (10.7) to Mountain Lion (10.8)
Posted by Harry at 10:45 am on September 20th, 2012.
Categories: Apache, Mac.
Two hours of my life were wasted on this one, even though I’ve done it before. So…
If you want to move your ~/Sites folder into say Dropbox or AeroFS or Google Drive or SkyDrive and then you still want to point to it from its default location don’t use an alias.
I know an alias is only a ctrl-click away, but it means all sorts of pain.
Instead, move the folder to dropbox by dragging it (yes you can do this), then open Terminal and type:
ln -s ~/Dropbox/Sites ~/Sites
Replace Dropbox with whatever the folder of your service is called.
Restart Apache either by restarting Web Sharing in System Preference -> Sharing or by using Terminal and typing:
apachectl graceful
Cross your fingers and open a virtual host in your web browser. I fought with an Alias and all sorts of folder settings and httpd.conf lines to try and get it working, and then all I needed was to use a SymLink in its place.
Don’t worry about no longer having a ‘real’ ~/Sites folder. You don’t actually need one.
Cheers to James Galley, my desk neighbour for helping my brain to click on this one.
Posted by Harry at 10:17 am on May 9th, 2012.
Categories: Apache, Mac, OS X 10.7, PHP.
fetchit-21
If you’re a web developer and you can only get the first Virtual Host to work in your new Apache 2 local setup, it’s very simple to resolve.
Thanks to Alex King for the solution to fix Apache 2 only serving the first virtual host.
Basically the NameVirtualHost must match the value you use in your virtual host declaration, be it *, 1.2.3.4 or example.local
NameVirtualHost *
<VirtualHost *>
</VirtualHost>
You get the gist.
Posted by Harry at 10:00 pm on January 22nd, 2010.
Categories: Apache.