Forum

Monitor installed in subdirectory

Sil68
26 October 2015, 22:38
Hi,

I've opted for Hiawatha on my Raspberry Pi for various reasons, and I'm more than satisfied with this approach!

One thing I've still not tackled yet, is running monitor from a subdirectory, not the document root (WebsiteRoot).

My file system looks something like this:

/data
+-- /www
+-- /apps
+-- /drupal
+-- /monitor
+-- /phpmyadmin
+-- /piwik
+-- /cgi-bin
+-- /htdocs
+-- /index.php
+-- /images
+-- /tools
+-- /phpinfo.php


The document root (WebsiteRoot) is set to "/data/www/htdocs", and there are several aliases setup, eg.

Alias /drupal:/data/www/apps/drupal
Alias /monitor:/data/www/apps/monitor
Alias /phpmyadm:/data/www/apps/phpmyadmin
Alias /piwik:/data/www/apps/piwik


So when browsing "http://my.site.local" the "index.php" file found in the "htdocs" directory is getting displayed, when opening URL "http://my.site.local/monitor" I'd like to see the Hiawatha Monitor, but instead I'm receiving an error message reading

"The requested page could not be found"

My virtual host configuration:

VirtualHost {
Hostname = my.site.local
RequiredBinding = my.site.local

WebsiteRoot = /data/www/sites/my.site.local/htdocs
StartFile = index.php

AccessLogfile = /var/log/hiawatha/my.site.local-access.log
ErrorLogfile = /var/log/hiawatha/my.site.local-error.log

TimeForCGI = 600
UseFastCGI = php5-fpm

Alias /tools:/data/www/sites/my.site.local/tools
Alias /drupal:/data/www/sites/my.site.local/apps/drupal
Alias /monitor:/data/www/sites/my.site.local/apps/monitor/public
Alias /phpmyadm:/data/www/sites/my.site.local/apps/phpmyadmin
Alias /piwik:/data/www/sites/my.site.local/apps/piwik

#UseToolkit = monitorroot
#UseToolkit = monitorsub, drupalsub, drupal8sub
#UseToolkit = drupalsub, drupal8sub
}


My URL Toolkits:

MonitorServer = 127.0.0.1

UrlToolkit {
ToolkitID = monitorroot
RequestURI isfile Return
Match ^/(css|images|js)/ Return
Match ^/(favicon.ico|robots.txt)$ Return
Match [^?]*(\?.*)? Rewrite /index.php$1
}
UrlToolkit {
ToolkitID = monitorsub
RequestURI isfile Return
Match ^/(css|images|js)/ Rewrite /monitor/$1/
Match ^/(favicon.ico|robots.txt)$ Rewrite /monitor/$1
Match [^?]*(\?.*)? Rewrite /monitor/index.php$1
}

UrlToolkit {
ToolkitID = drupalroot
RequestURI isfile Return
Match ^/(favicon.ico)$ Return
Match /(.*)\?(.*) Rewrite /index.php?q=$1&$2 Return
Match /(.*) Rewrite /index.php?q=$1
}
UrlToolkit {
ToolkitID = drupalsub
RequestURI isfile Return
Match ^/(favicon.ico)$ Rewrite /drupal/$1
Match /(.*)\?(.*) Rewrite /drupal/index.php?q=$1&$2 Return
Match /(.*) Rewrite /drupal/index.php?q=$1
}


What would I have to amend in which manner?
Btw. as Drupal is located in a subdirectory as well and accessed with this instead of the document root (WebsiteRoot), and hints with regards to this would come in quite handy as well!

--Sil68
Hugo Leisink
26 October 2015, 23:01
Banshee was never made to have its complete content within the webroot. The directory public should be the webroot. To make your setup work, we have to do some trickery. Please note that I haven't tested the rules below. You might have to do some tweaking yourself. It's just to give you an idea. Anyway, here's my best shot.

...

UrlToolkit {
ToolkitID = monitorsub
Match ^/monitor/(.*) Rewrite /monitor/public/$1 Continue
RequestURI isfile Return
Match ^/monitor/public/(css|images|js)/ Return
Match ^/monitor/public/(favicon.ico|robots.txt)$ Return
Match ^/monitor/public/[^?]*(\?.*)? Rewrite /monitor/public/index.php$1
}

...

UrlToolkit {
ToolkitID = drupalsub
RequestURI isfile Return
Match ^/drupal/favicon.ico$ Return
Match ^/drupal/(.*)\?(.*) Rewrite /drupal/index.php?q=$1&$2
Match ^/drupal/(.*) Rewrite /drupal/index.php?q=$1
}

...
Sil68
27 October 2015, 06:44
Hi Hugo,

Thanks for your quick response, much appreciated!

I've tried out your suggestions, but I'm afraid they didn't work out as intended.

Is there any chance of catching monitor-related URLs, and rewriting those accordingly. I pursued the route of placing monitor into the webroot for a tick, retrieve all the relevant monitor-specific URLs, and create corresponding UrlToolKit entries.

What I'm trying to achieve is operating one management website, featuring various tools--amongst others Hiawatha monitor--and pick each of those from a menu/portal-kind of starting point.

Eg.

http://my.site.local .......................... portal
http://my.site.local/tools/phpinfo.php ........ php info
http://my.site.local/piwik .................... Piwik analytics (outside webroot, accessed by means of alias)
http://my.site.local/phpmyadm ................. phpmyadmin (outside webroot, accessed by means of alias)
http://my.site.local/drupal ................... Drupal (outside webroot, accessed by means of alias)
http://my.site.local/hiamon ................... Hiawatha monitor (outside webroot, accessed by means of alias)


--Sil68
Hugo Leisink
27 October 2015, 09:09
Ow, wait. The monitor symlink already points to the public directory. Sorry, should have read more carefully. Try this one:
UrlToolkit {
ToolkitID = monitorsub
RequestURI isfile Return
Match ^/monitor/(css|images|js)/ Return
Match ^/monitor/(favicon.ico|robots.txt)$ Return
Match ^/monitor/[^?]*(\?.*)? Rewrite /monitor/index.php$1
}
Sil68
27 October 2015, 18:19
Thanks again!

I'm afraid it's still to no avail, as I'm again receiving an error message.

Error

The requested page could not be found.

If you believe this is due to a bug in this website, please notify the webmaster. Click here to return to the homepage.


--Sil68
Hugo Leisink
27 October 2015, 22:11
I think the UrlToolkit rules don't work well with aliases. Try using softlinks instead.
Sil68
29 October 2015, 21:05
Same error message is getting displayed (when using "Alias /monitor:/data/www/sites/my.site.local/apps/monitor/public")
This topic has been closed.