Search code examples
phpapachecakephpmampvirtualhost

Issue getting CakePHP to work on MAMP in virtual host


I dont know how to get CakePHP to run in a virtual host on my local machine. I can get the code to work on the default http://localhost:8888/caketest/ but cant get it to work from http://cakeapp.local:8888/ where I get the warning

"URL rewriting is not properly configured on your server.   1) Help me configure it 2) I don't / can't use URL rewriting"

In MAMP's httpd.conf I added

<VirtualHost *>
    DocumentRoot "/Applications/MAMP/htdocs"
    ServerName localhost
</VirtualHost>
<VirtualHost *>
    DocumentRoot "/Users/me/Documents/path/to/root/root"
    ServerName cakeapp.local
</VirtualHost>

I saw in the help page that it expects

Options FollowSymLinks
AllowOverride All
# Order deny,allow
# Deny from all

but this crashed MAMP

both are CakePHP 2.4.9 with no changes to the default download

Edit: The not working files in /Users/me/Documents/path/to/root/root which dont work were copied to /Applications/MAMP/htdocs where they then worked, so it is an issue with the virtual host

Edit 2: I thought I had found a solution but It looks like I was wrong. I changed the virtual host to point directly to /app/webroot which has made the default page show correctly, I then proceeded to add the DebugKit plugin (which I have working in a different local host file and the rewrites for its files still dont work.

For example app/Plugin/DebugKit/webroot/css/debug_toolbar.css gets loaded on http://localhost:8888/caketest/debug_kit/css/debug_toolbar.css but the file in the virtual host http://cakeapp.local:8888/debug_kit/css/debug_toolbar.css returns a 404 error (the plugin works), the files just dont get loaded.


Solution

  • OK, I think this works, the last time I tried to fix the directory it was not pointing at the correct directory.

    I added the following to the httpd.conf:

    <Directory "/Users/me/Documents/path/to/root/root">
        Options All
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>