skip to Main Content

I developped a site with sympfony/phpp i want to deploy on a local server.

After the development on my own computer (where it works well), I put the project on a local server with apache, php 7.3.x, composer 2.0.0 under a debian 10 OS

All the transfer of the project from my computer to the server and the setting are well finished.
The project folder name is si2a. It is in the directory /var/www
I set the permissions access on this directory with ACL following a symfony doc guideline.

I set the site configuration file those the name is si2afama.conf. This last is in the directory /etc/apache2/sites-available. After setting, I activate the site, reload apache and clear the cache. Here is the si2afama.conf’s contain :

<VirtualHost *:80> 
    ServerName si2afama 
    # ServerAlias www.si2afama.com 
 
    DocumentRoot /var/www/si2a/public
    DirectoryIndex /index.php
 
    <Directory /var/www/si2a/public> 
        AllowOverride All 
        Require all granted
        Allow from All 
 
    FallbackResource /index.php
 
    </Directory>
 
    <Directory /var/www/si2a/public/bundles>
        FallbackResource disabled
    </Directory>
 
    ErrorLog /var/log/apache2/si2a_error.log
    CustomLog /var/log/apache2/si2a_access.log combined 
</VirtualHost>

When i try to access the site, i found this error :
No route found for "GET /si2afama"

Since, it is a Routing issus, here are some files’s contain :

si2a/config/packages/routing.yaml

framework:
    router:
        utf8: true

si2a/config.routes.yaml

index:
    path: /
    controller: AppControllerDefaultController::index

si2a/public/index.php.

<?php
use AppKernel;
use SymfonyComponentErrorHandlerDebug;
use SymfonyComponentHttpFoundationRequest;
require dirname(__DIR__).'/config/bootstrap.php';
if ($_SERVER['APP_DEBUG']) {
    umask(0000);
    Debug::enable();
}
if ($trustedProxies = $_SERVER['TRUSTED_PROXIES'] ?? $_ENV['TRUSTED_PROXIES'] ?? false) {
    Request::setTrustedProxies(explode(',', $trustedProxies), Request::HEADER_X_FORWARDED_ALL ^ Request::HEADER_X_FORWARDED_HOST);
}
if ($trustedHosts = $_SERVER['TRUSTED_HOSTS'] ?? $_ENV['TRUSTED_HOSTS'] ?? false) {
    Request::setTrustedHosts([$trustedHosts]);
}
$kernel = new Kernel($_SERVER['APP_ENV'], (bool) $_SERVER['APP_DEBUG']);
$request = Request::createFromGlobals();
$response = $kernel->handle($request);
$response->send();
$kernel->terminate($request, $response);

I don’t really know what to do in order to fix the issus.

May someone help me, please. Thank you.

2

Answers


  1. try to install this package composer require symfony/apache-pack it will create a .htaccess file that’ll fix your problem

    Login or Signup to reply.
  2. Your vhost is related to your domain name and directory of source code,
    if you want a route name like si2afama for your application, you have to add it to symfony routes.

    # si2a/config.routes.yaml
    
    
    index:
        path: /
        controller: AppControllerDefaultController::index
    
    si2afama:
        path: /si2afama
        controller: AppControllerDefaultController::nameActionFromController
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search