Installer un ou plusieurs projet(s) symfony sur wamp 2 sans le casser
Si on lit la doc symfony, ou le tuto dédié, on voit qu'installer ce framework sur wamp "détruit" son comportement par défaut (accès simple via localhost).
En utilisant correctement les virtualHost de apache, on peut éviter ca (et l'installation via PEAR !).
Nous allons créer le site "symfony.local" ayant comme emplacement "C:\wamp\www\sfproject\".
NOTE : créer le projet à un autre emplacement que celui initialement donné à wamp résultera par une belle page d'accès interdit.
1. Éditer le fichier "httpd-vhosts.conf" (situé dans "C:\wamp\bin\apache\Apache2.2.11\conf\extra\") avec :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
#Site symfony <VirtualHost *:80> ServerAdmin admin@symfony.com DocumentRoot "C:\wamp\www\sfproject\web" ServerName symfony.local ServerAlias symfony.local ErrorLog "logs/symfony.localhost-error.log" CustomLog "logs/symfony.localhost-access.log" common Alias /sf C:\wamp\www\sfproject\lib\vendor\symfony\data\web\sf </VirtualHost> #localhost opérationnel <VirtualHost *:80> DocumentRoot "C:\wamp\www" ServerName localhost ServerAlias localhost </VirtualHost> |
2. Éditer le fichier "httpd.conf" (situé dans "C:\wamp\bin\apache\Apache2.2.11\conf\"), et décommenter la ligne :
Include conf/extra/httpd-vhosts.conf
3. Éditer le fichier "hosts" (situé dans "C:\WINDOWS\system32\drivers\etc\"), et ajouter :
127.0.0.1 symfony.local
4. Redémarrer apache (ou wamp) et vous pouvez accéder à votre projet symfony via :
http://symfony.local/
Pour installer un autre projet, il suffit de rajouter ce bloc au fichier "httpd-vhosts.conf" et de modifier RACINE_DU_PROJET et URL_PROJET avec les bonnes valeurs :
1 2 3 4 5 6 7 8 9 10 |
#Site symfony <VirtualHost *:80> ServerAdmin admin@sitesymfony.com DocumentRoot "RACINE_PROJET" ServerName URL_PROJET ServerAlias URL_PROJET ErrorLog "logs/symfony.localhost-error.log" CustomLog "logs/symfony.localhost-access.log" common Alias /sf RACINE_PROJET\lib\vendor\symfony\data\web\sf </VirtualHost> |
Sans oublier le fichier host :
127.0.0.1 URL_PROJET
Sources :
Virtual hosts dans Wamp pour Symfony Blog Symfony - Lexik Montpellier
SymfonyOnWampEnFrancais