Ankündigung

Einklappen
Keine Ankündigung bisher.

Apache findet keine Symfony Routen

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Apache findet keine Symfony Routen

    Hallo erstmal,

    aktuell arbeite ich daran eine Anwendung auf einem Digital Ocean LAMP Dropplet zu deployen. Das hat auch alles ganz gut geklappt und ich sehe die Login-Maske, die sich unter der Route '/' verbirgt. Soweit so gut.
    Wenn ich jetzt das Administrator- Kennwort eingebe, sollte ich auf die /admin Route weitergeleitet werden. Stattdessen bekomme ich ein normales 404 vom Apache Server.
    Ich verwende Annotations im Controller um die Routen zu definieren und habe probehalber versucht Routen in der ./config/routes.yaml zu definieren. Ohne Erfolg.
    Habt ihr eine Idee woran es liegen könnte?

    Viele Grüße
    Alex

    Route im Controller:
    PHP-Code:
      /**  * @Route("/admin/", name="admin_main_page")  */ 
    /etc/apache2/sites-available/xxx.conf:

    Code:
    <VirtualHost *:80>
        ServerName xxx.de
        ServerAlias www.xxx.de
    
        DocumentRoot /var/www/xxx.de/public
        <Directory /var/www/xxx.de/public>
            AllowOverride None
            Require all granted
            Allow from All
    
            <IfModule mod_rewrite.c>
                Options -MultiViews
                RewriteEngine On
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteRule ^(.*)$ index.php [QSA,L]
            </IfModule>
        </Directory>
    
        # uncomment the following lines if you install assets as symlinks
        # or run into problems when compiling LESS/Sass/CoffeeScript assets
        # <Directory /var/www/xxx.de>
         #    Options FollowSymlinks
        #</Directory>
    
        # optionally disable the RewriteEngine for the asset directories
        # which will allow apache to simply reply with a 404 when files are
        # not found instead of passing the request into the full symfony stack
        <Directory /var/www/xxx.de/public/bundles>
            <IfModule mod_rewrite.c>
                RewriteEngine Off
            </IfModule>
        </Directory>
        ErrorLog /var/log/apache2/xxx.de_com_error.log
        CustomLog /var/log/apache2/xxx.de_com_access.log combined
    
    # optionally set the value of the environment variables used in the application
        SetEnv APP_ENV prod
        SetEnv APP_SECRET xxx
        SetEnv DATABASE_URL "mysql:/xxx:xxx@xxxx:xxxxxx/xxxx"
    
    
    </VirtualHost>
    ~

  • #2
    Stattdessen bekomme ich ein normales 404 vom Apache Server.
    und was findet dein apache nicht, logfile ?

    Kommentar


    • #3
      Im Browser bekomme ich einen ganz normalen 404 Fehler:

      HTML-Code:
      <title>404 Not Found</title></head><body><h1>Not Found</h1><p>The requested URL /admin was not found on this server.</p><hr><address>Apache/2.4.18 (Ubuntu) Server at xxx.xxx.xxx Port 80</address>
      Im acces_log der Seite stehen beide Requests. Der / Request funktioniert.

      Code:
      37.4.250.116 - - [06/Apr/2018:15:45:11 +0000] "GET / HTTP/1.1" 200 480 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/xx.0.xxxx.xxx Safari/537.36"
      37.4.250.116 - - [06/Apr/2018:15:47:57 +0000] "GET /admin HTTP/1.1" 404 500 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/xx.x.xxxx.xxx Safari/537.36"
      ~

      Im Error_Log ist der letzte Eintrag von heute 14 Uhr. Das Problem mit der bundles Variable ist gelöst.

      Code:
      [Fri Apr 06 15:45:11.408102 2018] [php7:notice] [pid 24189] [client 37.4.250.116:40752] PHP Notice:  Undefined variable: bundles in /var/www/xxx.de/src/Kernel.php on line 43
      ~
      Ich hoffe du kannst mit den Files etwas anfangen.
      Ich bin mir leider im unklaren ob das Problem bei Symfony oder Apache liegt.
      Die Anwendung funktioniert mit dem lokalen Server ./bin/console server:run tadellos.

      Viele Grüße
      Alex

      Kommentar


      • #4
        mod_rewrite Modul im Apache ist geladen?

        Grüße.

        Kommentar


        • #5
          Zitat von php1704 Beitrag anzeigen
          mod_rewrite Modul im Apache ist geladen?

          Grüße.
          Tausend Dank dir. Daran hats gelegen.

          Code:
           <Directory /var/www/xxx/public/bundles>
                  <IfModule mod_rewrite.c>
                      RewriteEngine On
                  </IfModule>
              </Directory>
          Mit der Option funktioniert es

          Kommentar


          • #6
            Hallo,

            wenn du schon am optimieren bist, also alles in die vhost config schreibst, dann kannst auch gleich die Rewrite Regeln da mit aufnehmen.

            Eine .htaccess Datei wird immer rekursiv eingelesen. Das heißt, gibt es keine, lädt alles schneller.


            MFG

            derwunner

            Kommentar

            Lädt...
            X