Creare virtualhost in apache - Tutorial Symfony

Postat la Mon 25 May 2015 in tutoriale, symfony 2

In unele cazuri dorim sa rulam proiectul nostru Symfony sub Apache. Iata setarile pentru un virtualhost la varianta dev

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
<VirtualHost *:80>
    ServerName symfony.dev
    ServerAlias www.symfony.dev
    DocumentRoot /var/www/symfo_tut/web
    <Directory "/var/www/symfo_tut/web">
      DirectoryIndex app_dev.php
      Options -Indexes FollowSymLinks SymLinksifOwnerMatch
      AllowOverride None
      Order allow,deny
      Allow from all
    </Directory>
    <Directory /var/www/symfo_tut>
         Options FollowSymlinks
     </Directory>
    CustomLog "/var/log/apache2/symfony.local-access.log" combined
    ErrorLog "/var/log/apache2/symfony.local-error.log"
</VirtualHost>

si pentru versiunea de productie:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
<VirtualHost *:80>
    ServerName symfony.prod
    ServerAlias www.symfony.prod
    DocumentRoot /var/www/symfo_tut/web
    <Directory "/var/www/symfo_tut/web">
       DirectoryIndex app.php
       Options -Indexes FollowSymLinks SymLinksifOwnerMatch
       RewriteEngine On
       AllowOverride All
       Order allow,deny
       Allow from All
    </Directory>
    <Directory /var/www/symfo_tut>
         Options FollowSymlinks
     </Directory>
    CustomLog "/var/log/apache2/symfony.local-access.log" combined
    ErrorLog "/var/log/apache2/symfony.local-error.log"
</VirtualHost>

Nu uitati sa adaugati aceste domenii in /etc/hosts:

127.0.0.1 symfony.dev www.symfony.dev
127.0.0.1 symfony.prod www.symfony.prod

Acum putem testa in browser cele doua vesiuni: http://symfony.dev si http://symfony.prod

Anterior - Instalare Symfony 2 Urmator - Creare bundle