Posts in category "PHP"
Upgrading to OSX El Capitan - Getting Virtual Hosts working with Apache
Today I upgraded my MacBook to El Capitan. The first thing I noticed (other than wiggling the cursor around - best feature ever) was that all my development Virtual Hosts had stopped working. To be honest, I kind of expected this.
El Capitan ships with Apache 2.4.16, and it looks like it overwrites your previous
httpd.conf
file.Getting things working for me was easy though, this is more of a write up for my collegues than a definitive guide, so there's a few extra steps at the end aimed towards them.
Enable Virtual Hosts
- Open up
httpd.conf
, this is located at/private/etc/apache2/
- Uncomment the line which includes virtual hosts:
Include /private/etc/apache2/extra/httpd-vhosts.conf
- Alternatively, just whack that at the end of the file, amounts to the same thing.
- Restart Apache:
sudo apachectl restart
That is it, as far as enabling virtual hosts goes. Read on for some Shed specific (but generic at the same time) next steps.
Enable PHP and ModRewrite
- Open up
httpd.conf
, this is located at/private/etc/apache2/
- Uncomment the line which loads PHP:
LoadModule php5_module libexec/apache2/libphp5.so
- Shed use homebrew managed PHP, so leave that line commented and place this line underneath instead:
LoadModule php5_module /usr/local/opt/php56/libexec/apache2/libphp5.so
- Shed use homebrew managed PHP, so leave that line commented and place this line underneath instead:
- Uncomment the line which laods mod_rewrite:
LoadModule rewrite_module libexec/apache2/mod_rewrite.so
- Allow .htaccess files by setting
AllowOverride All
in the<Directory />
block - Restart Apache:
sudo apachectl restart
Some other Apache Configs
The following are completely my preference, but I'd still recommend them anyway.
- Open up httpd.conf, this is located at /private/etc/apache2/
- Update the
user
andgroup
parameters to match your OSX login (in my casepablo
andstaff
)- This will cause apache to write as you, which generally makes delaing with reading/writing files a little less torublesome
- Restart Apache:
sudo apachectl restart
- Open up