Wednesday, March 03, 2010

CakePhp and SSL connections (https)

I've been playing with CakePhp for some time now (and really enjoyed and enjoying it), since I'm turning my bibliography system, PhpBibliography, to use it (I've rewritten it basically from scratch using cakephp, and hopefully the new version will be out soon).

What I've been struggling with was the https ssl connections which didn't seem to work: I was getting page not found errors, and even after the ssl site was working, only the home page seemed to respond, but no css style was applied.

The problem was due to the rewriting engine on which cakephp is based on, and I had not configured it correctly in the apache site (so cakephp was not to blame). I document my experience here hoping it can help others.

I'm using Ubuntu 9.10, so what follows was done on such system.

First of all, you need to enable ssl in apache; To enable SSL, type (as user root, e.g., with sudo):

a2ensite default-ssl
a2enmod ssl

Note that I'm not interested here in creating a specific certificate, so I'm using the default one.

Then, you need to make the mod_rewrite work also for the ssl site: you need to edit /etc/apache2/sites-enabled/default-ssl and make sure that AllowOverride is set (in my case I only need that in /var/www):

<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all

Then, restart apache and your cakephp will work with https as well.


John Isaacks said...

Thank you very much! I was having this same issue. This solved it for me as well :)

Anonymous said...

merci beaucoup !!
thank you

Staff Ngeditblog said...

tempat nyari SSL murah ya di Cuman disini kamu bisa menemukan paket terbaik untuk hosting webkamu.