Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.1k views
in Technique[技术] by (71.8m points)

web deployment - How can I deploy Symfony in a subdirectory?

My website is ready to be deployed and I am trying to set it up online.

Some informations:

  • The host is OVH.
  • It doesn't allow SSH, I have to send my files with FTP. No command line either.
  • I want to be able to set up the website in a subdirectory: /www/test for now (my current website is still in /www).

The problem:

When I open the URL my-website.com/test, a Symfony exception tells me No route found for "GET /test/", which clearly means that Symfony doesn't know it is in a sub-directory.

How can I tell it?


EDIT:

I just realized it worked when I access my-website.com/test/web.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Here I wrote exactly about that: https://www.refactory-project.com/install-symfony-app-in-a-subfolder-of-an-existing-site/

Upload the application part

Start by uploading the application folders at the same level of your site root:

[ftproot]
-- public_html
---- ...
---- ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- web
------ app.php
------ app_dev.php
------ ...
---- composer.json
---- composer.lock

Move the web part

Move the content of the "web" folder into the desired subfolder, i.e. "myapp".

[ftproot]
-- public_html
---- ...
---- ...
---- myapp
------ app.php
------ app_dev.php
------ ...
-- symfonyapp
---- app
---- bin
---- src
---- vendor
---- composer.json
---- composer.lock

Let the web know where is the application

Edit files app.php and app_dev.php and insert the new application location.

require_once __DIR__ . '/../../symfonyapp/app/bootstrap.php.cache';
require_once __DIR__ . '/../../symfonyapp/app/AppKernel.php';

Let the application know how the web folder is called

Edit file composer.json with the new web folder name

{
    ...
    "extra": {
        ...
       "symfony-web-dir": "../public_html/myapp"
    }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...