Problems, hosting cockpit in a subfolder on uberspace

Hello,

i am currently trying to host a site on uberspace in a subfolder. Another cockpit project, that is lying in my root is working perfectly fine, but i somehow struggle to overcome problems with my project in the subfolder. This is the error i am getting:

My project is lying under
/var/www/virtual/username/html/nino-dornemann.de/cms
but somehow it is trying to resolve the path to
/var/www/virtual/username/nino-dornemann.de/cms
without the html-part.

And this is, how my defines.php is looking like:

<?php
define('COCKPIT_DOCS_ROOT', dirname(__DIR__));
define('COCKPIT_BASE_URL', '/cms');
define('COCKPIT_BASE_ROUTE', '/cms');

the root path is btw
/var/www/virtual/username/html
and the cockpit project not working is in the /nino-dornemann.de subfolder

sounds like your apache config

Your primary docs root is in /var/www/virtual/$USER/html and all connected domains point to that root if there is no matching folder (secondary docs root) in /var/www/virtual/$USER/sub.domain.tld.

So /var/www/virtual/$USER/nino-dornemann.de/cms should be the right place.

If you use it that way, $_SERVER['DOCUMENT_ROOT'] still points to /var/www/virtual/$USER/html.

See: DocumentRoot — Uberspace 7 manual 7.15.4 documentation

define('COCKPIT_DOCS_ROOT', __DIR__); and eventually RewriteBase / in .htaccess should do the trick.

Hey,

i moved everything, where it belongs, with the defines.php and RewriteBase / in place and am now getting this:

Without RewriteBase the somewhat same error occurs:

Not found
The requested URL /var/www/virtual/$USER/www.nino-dornemann.de/cms/index.php was not found on this server

As naive as i am i also renamed the folder to www.nino-dornemann.de, so that the path actually NEEDS to hit the index.php but unfortunately it does not.

@nino1337 I was able to reproduce your setup with the help of this thread (working example for Uberspace in a secondary docs root, but not in a subfolder):

This works, if your cockpit instance is in a subfolder /cms:

# connect domain
uberspace web domain add test.domain.tld

# set A and AAAA records at your domain provider...

# create docs root
cd /var/www/virtual/$USER
mkdir test.domain.tld
cd test.domain.tld

git clone https://github.com/agentejo/cockpit.git cms

cd cms

nano .htaccess
# set RewriteBase /cms
# Be aware, that .htaccess might be overridden with the next cockpit update

nano defines.php
# set constants (see below)

defines.php:

<?php
define('COCKPIT_BASE_URL', '/cms');
define('COCKPIT_BASE_ROUTE', '/cms');
define('COCKPIT_DOCS_ROOT', dirname(__DIR__));
define('COCKPIT_SITE_DIR',  dirname(dirname(__DIR__)));
1 Like