Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running sulu in a subfolder #495

Open
alexander-schranz opened this issue Feb 19, 2020 · 5 comments
Open

Running sulu in a subfolder #495

alexander-schranz opened this issue Feb 19, 2020 · 5 comments

Comments

@alexander-schranz
Copy link
Member

alexander-schranz commented Feb 19, 2020

For changing only the admin url have an look at:

https://github.com/sulu/sulu-demo/pull/60/files

For having all in a subfolder:

Currently if you want to run sulu in a subfolder you need to touch the following files:

public/index.php

-if (preg_match('/^\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) {
+if (preg_match('/^\/subfolder\/admin(\/|$)/', $_SERVER['REQUEST_URI'])) {

config/packages/framework_admin.yaml

This file need to be created:

framework:
    session:
        cookie_path: /subfolder/admin
    fragments:
        path: /subfolder/admin

config/packages/sulu_media.yaml

sulu_media:
    routing:
        media_proxy_path: '/subfolder/uploads/media/{slug}'
        media_download_path: '/subfolder/media/{id}/download/{slug}'

config/webspaces/example.xml

<url language="en">{host}/subfolder</url>

The following is maybe optional

If symfony detects the subfolder configuration correctly the following is not needed this could e.g. happen if $_SERVER['PHP_SELF'] and $_SERVER['SCRIPT_NAME'] is set correctly:

$_SERVER['PHP_SELF']; // should be something like '/subfolder/index.php'
$_SERVER['SCRIPT_NAME']; // should be something like '/subfolder'

Else you need to change the configuration of all routes:

config/packages/security_admin.yaml

Add prefix to ALL security urls:

-        - { path: ^/admin/reset, roles: IS_AUTHENTICATED_ANONYMOUSLY }
+        - { path: ^/subfolder/admin/reset, roles: IS_AUTHENTICATED_ANONYMOUSLY }
...
config/packages/fos_rest.yaml
fos_rest:
    zone:
-        - { path: ^/admin/* }
+        - { path: ^/subfolder/admin/* }

config/routes/*

Add /subfolder to all urls all urls and add prefix: /subfolder to all imports.

Use following commands to debug:

bin/adminconsole debug:router
bin/websiteconsole debug:router

config/packages/media.yaml

Media routes are configured also in the following config:

sulu_media:
    routing:
        media_proxy_path: '/subfolder/uploads/media/{slug}'
        media_download_path: '/subfolder/media/{id}/download/{slug}'

Vhost

Based on your webserver you need configure that the path-to-your-project/public is running under /subfolder.

@Zerewan
Copy link

Zerewan commented Feb 6, 2025

I am getting this Error after adding prefix /cms overall.

Unable to find the controller for path "/cms/admin/login". The route is wrongly configured.

And bin/adminconsole debug:router | grep admin/login shows:
sulu_admin.login_check ANY ANY ANY /cms/admin/login

@alexander-schranz
Copy link
Member Author

@Zerewan this sounds like you are not running in admin context please check the regex in your public/index.php see first adoption above.

@Zerewan
Copy link

Zerewan commented Feb 7, 2025

@alexander-schranz many thanks, it works 👍

@Zerewan
Copy link

Zerewan commented Feb 7, 2025

@alexander-schranz we have now this problem on our prod server:

The cache can be cleared successfully but the folder proxies is missing. Is that caused by (The controller for URI "/admin/" is not callable) ? how can we fix that?

Thanks.

request.CRITICAL: Uncaught PHP Exception InvalidArgumentException: "The controller for URI "/admin/" is not callable: Provided directory "/var/app/current/sulu/var/cache/admin/prod/sulu/proxies" does not exist" at ControllerResolver.php line 97 {"exception":"[object] (InvalidArgumentException(code: 0): The controller for URI "/admin/" is not callable: Provided directory "/var/app/current/sulu/var/cache/admin/prod/sulu/proxies" does not exist at /var/app/current/sulu/vendor/symfony/http-kernel/Controller/ControllerResolver.php:97)\n[previous exception] [object] (ProxyManager\Exception\InvalidProxyDirectoryException(code: 0): Provided directory "/var/app/current/sulu/var/cache/admin/prod/sulu/proxies" does not exist at /var/app/current/sulu/vendor/friendsofphp/proxy-manager-lts/src/ProxyManager/Exception/InvalidProxyDirectoryException.php:18)"} []

@alexander-schranz
Copy link
Member Author

That normally something else make sure that bin/adminconsole cache:clear and bin/websiteconsole cache:clear on your used APP_ENV works like expected. Try hardclear the cache before with rm -rf var/cache

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants