Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Install and configure mod_rewrite for Apache 2 on Mac OS X for Zend Framework 2

I getting started with zend framework 2 and they have a prerequisite of an installation and configuration of mod_rewrite for apache. Apache 2.2.22 came pre-installed on Mac OS X 10.8.2. Is there an easy way to install and configure mod_rewrite for apache?

The only help I have come across suggests to recompile apache. Is this the only way?

like image 578
brad.roush Avatar asked Sep 25 '12 22:09

brad.roush


2 Answers

To check that mod_rewrite and PHP are enabled, look at /etc/apache2/httpd.conf and ensure that these lines:

LoadModule rewrite_module libexec/apache2/mod_rewrite.so LoadModule php5_module        libexec/apache2/libphp5.so 

are uncommented.

Also ensure that AllowOverride is set to All within the <Directory "/Library/WebServer/Documents"> section.

After making these changes, restart Apache with: sudo apachectl restart

If you then put your project within the /Library/WebServer/Documents folder, then it should work.

like image 198
Rob Allen Avatar answered Sep 22 '22 08:09

Rob Allen


If you are serving your site from ~/Sites, the trick for me was modifying my /private/etc/apache2/users/USERNAME.conf file. Initially, the content was:

<Directory "/Users/USERNAME/Sites/">     Options Indexes MultiViews FollowSymLinks ExecCGI     AllowOverride None     Order allow,deny     Allow from all </Directory> 

Changing AllowOverride to all and then restarting the server with a quick sudo apachectl restart enabled me to start using mod_rewrite in .htaccess files living beneath ~/Sites.

like image 31
sffc Avatar answered Sep 22 '22 08:09

sffc