Posts Tagged ‘PHP’

Symfony: enabling mod_rewrite

Tuesday, November 18th, 2008

The php Symfony framework comes with url rewritting management (allowing you for example to have url such as mysite.com/article/how-to-enable-mod_rewrite/ instead of mysite.com/article?id=124523).

On deploying the application on the production server however this was not working, I was getting 404 errors – after a little search on Symfony doc I found out that

a) the apache module mod_rewrite needed to be enabled
b) symfony configures the mod_rewrite for the application on a .htaccess file, which, depending on your server configuration, may not be read by the server.

On Debian, a) is quite simple: the module is actually available by default when installing apache, you just need to enable it, by moving the loading file from the /mods-available folder to the /mods-enabled folder:

mv /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/

[UPDATE] as suggest Ludovic, the following command is probably better:

a2enmod rewrite

[UPDATE2] Indeed the a2enmod command must be used instead of the former move command – as a2enmod actually create a symlink and don t move the file.
and then reload apache:

/etc/init.d/apache2 reload

Regarding b), we need to ensure that AllowOverride is set to All in the Alias or VirtualHost directory:

<Directory /my/web/root/directory/>
...
AllowOverride All
...
</Directory>

Using symfony “sync” command on Windows

Tuesday, October 21st, 2008

The php Symfony frameworks has a very handy deployment feature: on a single command line you can deploy your application to various environments. You just need to configure the ssh login/password for each of your environment and the files to ignore during the transfer.(see the link above for the details)

However, this tool relies on rsync, a file synchronisation tool which is on all Linux machines, but not on Windows. rsync relies itself on ssh – so if, like me, you re developing on a Windows machine, you need to have both installed on your machine.

The good  news is there a readily available archive containing all this here.