Z
Z
zudwamorrison2014-11-24 14:01:42
symfony
zudwamorrison, 2014-11-24 14:01:42

Symfony on virtualHost?

Help me understand what the problem is.
Symfony 2 was installed (like here ) on localhost (Debian, apache2, MySQL, PHP). Several projects are running on the localhost, everything works fine. But with a project with symfony it doesn’t work, the virtualHost settings are copied from a working project. The browser at localhost/project/web shows the folder structure ("Index of /project/web ...").
Found this answer on Stackoverflow:
1)

# app/config/routing.yml
homepage:
    pattern:   /
    defaults:  { _controller: AcmeHomeBundle:home:show }

2) rename the app_dev.php to index.php and this will route to the home page automatically
The homepage is displayed, but does not leave the feeling that it should work somehow differently...
/etc/apache2/sites-available/project
<VirtualHost *:80>
  ServerAdmin [email protected]

  DocumentRoot /var/www/project/web
  <Directory />
    Options FollowSymLinks
    AllowOverride None
  </Directory>
  <Directory /var/www/project/web/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride ALL
    Order allow,deny
    allow from all
  </Directory>

  ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
  <Directory "/usr/lib/cgi-bin">
    AllowOverride None
    Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
    Order allow,deny
    Allow from all
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/project.error.log

  # Possible values include: debug, info, notice, warn, error, crit,
  # alert, emerg.
  LogLevel debug

  CustomLog ${APACHE_LOG_DIR}/project.access.log combined
</VirtualHost>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
silentvick, 2014-11-24
@zudwamorrison

You don't need to rename app_dev.php to index.php . I suspect you forgot to include the .htaccess file: symfony/.htaccess Related
:
Symfony: Configuring a Web Server

Z
zudwamorrison, 2014-11-24
@zudwamorrison

Thanks for the help, really the problem is in .htaccess.
As a result, however, I wrote everything down in the VirtualHost config

<VirtualHost *:80>
        ServerName symfony.test
        ServerAdmin [email protected]

        DocumentRoot /var/www/projecty/web

        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/project/web/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride ALL
                Order allow,deny
                allow from all
                DirectoryIndex app_dev.php
                <IfModule mod_rewrite.c>
                        RewriteEngine On
                        RewriteCond %{REQUEST_URI}::$1 ^(/.+)/(.*)::\2$
                        RewriteRule ^(.*) - [E=BASE:%1]
                        RewriteCond %{ENV:REDIRECT_STATUS} ^$
                        RewriteRule ^app_dev.php(/(.*)|$) %{ENV:BASE}/$2 [R=301,L]    ##### this is the part that you should tweak, have th$
                        RewriteCond %{REQUEST_FILENAME} -f
                        RewriteRule .? - [L]
                        RewriteRule .? %{ENV:BASE}/app_dev.php [L]        ##### this is the part that you should tweak, have the .htaccess $
                </IfModule>
                <IfModule !mod_rewrite.c>
                        <IfModule mod_alias.c>
                                # When mod_rewrite is not available, we instruct a temporary redirect of
                                # the startpage to the front controller explicitly so that the website
                                # and the generated links can still be used.
                                RedirectMatch 302 ^/$ /app.php/
                                # RedirectTemp cannot be used instead
                        </IfModule>
                </IfModule>
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>
        ErrorLog ${APACHE_LOG_DIR}/project.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel debug

        CustomLog ${APACHE_LOG_DIR}/project.access.log combined

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question