skip to Main Content

After hours of struggle I have come to the conclusion that the answer to my question is no, they can’t.
Am I correct?
We have the following structure at work:

/var/www/html
           |___app1
           |___app2
           |___app3

App1, app2 and app3 are accessible like http://server_name/app1 (app2 , or app3)
These apps are created using different frameworks (angular, jquery with bootstrap, moca, etc) and there is no issue with them.
But I haven’t been able to create an app4 using the slim project skeleton (slim4 in this case)….slim needs the document root to be the public folder and that crashes with the other applications.

I don’t have the luxury to create virtual hosts by names or by IP…..DNS is not handled by my team and communication with networking IT is not possible (yes, that’s rigt)….

I am able to make it work (the skeleton) if I change the DocumentRoot to /var/www/html/app4 (the slim app). But then all other apps stop working.

Is there a way to solve this under my conditions?

Thank you very much,

Andres

2

Answers


  1. Chosen as BEST ANSWER

    I was wrong, there is a way to have slim frontend coexisting with the other apps in the same webserver, while sharing all the same DocumentRoot. I Changed the routes.php to watch for all /app4/public/<any_entry_here> .

    Like for example:

    routes.php (that lives in /app4/app/routes.php)

    <?php
    declare(strict_types=1);
    use AppApplicationActionsUserListUsersAction;
    use AppApplicationActionsUserViewUserAction;
    use PsrHttpMessageResponseInterface as Response;
    use PsrHttpMessageServerRequestInterface as Request;
    use SlimApp;
    use SlimInterfacesRouteCollectorProxyInterface as Group;
    
    return function (App $app) {
    $app->get('/app4/public/login', function (Request $request, Response $response) {
    $response->getBody()->write('You have a slim4 app working now!');
    return $response;
        });
    
    };
    

    Of course, under /app4/public lives index.php (and the corresponding .htaccess if using apache)

    If using nginx, this location worked fine for me:

    location ~ /app4/public/ {
    
    error_log /apps/dss/websites/slim4_app_public.log;
    
    try_files $uri $uri/ /app4/public/index.php;
    
    include fastcgi.conf;
    
    fastcgi_pass php-fpm-upstream;
    
    }
    

    php-fpm-upstream, in my system is:

    upstream php-fpm-upstream {
    
    server fpm80:9000;
    
    }
    

    Where fpm80 is the name of the container serving the php-fpm module.

    Thank you Nigel and Michael.


  2. If it must be on the same domain. Have you considered using another port? It’s not the most orthodox approach but I have set this up for staging environments at port 8080 while the live site lives at port 80. Would that work in your scenario? You would have to configure a virtual host to use port 8080.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search