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

Can't figure out how to run Matomo from the package. #69

Closed
Dreamsorcerer opened this issue Jul 26, 2018 · 9 comments
Closed

Can't figure out how to run Matomo from the package. #69

Dreamsorcerer opened this issue Jul 26, 2018 · 9 comments

Comments

@Dreamsorcerer
Copy link

Accessing the site is giving me:

An error occurred
Matomo couldn't write to some directories .
Try to Execute the following commands on your server, to allow Write access on these directories:
chown -R root:root /usr/share/matomo
chmod -R 0755 /usr/share/matomo/tmp
chmod -R 0755 /usr/share/matomo/tmp/assets/
chmod -R 0755 /usr/share/matomo/tmp/cache/
chmod -R 0755 /usr/share/matomo/tmp/logs/
chmod -R 0755 /usr/share/matomo/tmp/tcpdf/
chmod -R 0755 /usr/share/matomo/tmp/templates_c/

Obviously, the server is not running as root, so it cannot write to these directories. But, I don't want it to write to /usr/share/ anyway.

Looking at index.php, it appears to define the paths with no way for me to customise them. Presumably, I need to set PIWIK_DOCUMENT_ROOT to /var/www/mysite/ and PIWIK_INCLUDE_PATH to /usr/share/matomo/.

Is there something I'm missing that would allow me to change these paths?
I'm using nginx if it makes a difference.

@Dreamsorcerer
Copy link
Author

OK, I've now tried hacking the index.php file to get something working temporarily, and set PIWIK_DOCUMENT_ROOT to /var/www/mysite, PIWIK_INCLUDE_PATH to /usr/share/matomo, and PIWIK_USER_PATH to /etc/matomo.

However, I now get this error:

Matomo encoutered an error: An exception has been thrown during the rendering of a template ("The ui asset with 'href' = /var/www/mysite/plugins/Morpheus/stylesheets/base/bootstrap.css is not readable"). (which lead to: SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO))

So, I still can't figure out any way to get this application to run...

@aureq
Copy link
Contributor

aureq commented Jul 28, 2018

@Dreamsorcerer

  • Don't hack index.php. I mean, that's not going to help you in any way.
  • Could you provide more details on how you are trying to install Matomo
  • Could you provide more information about your environment
  • Could you provide your nginx configuration related to Matomo

Guessing what could be wrong without the above is going to be really hard for anyone.

Thanks

@Dreamsorcerer
Copy link
Author

Well, I was more looking for a general idea of how someone is supposed to run/install it. Based on the instructions, I have installed the package, and then setup a database. From there, I can't seem to find any clear instructions on how this is supposed to be configured/run (obviously there is an Apache config in the package, but that doesn't seem to be helping me figure it out).

Here's one version of my nginx conf (I've tried a couple of different approaches):

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;

	server_name mysite;
	root /usr/share/matomo;

	include fastcgi.conf;

	location / {
		try_files $uri @var;
	}

	location @var {
		root /var/www/mysite;
		try_files $uri /index.php?$query_string;
	}

	location = /index.php {
		fastcgi_pass php;
	}
}

For comparison, to understand what I am expecting to do, if you install the wordpress package, it comes with a custom config.php which automatically loads individual site configs from /etc/wordpress/, and then in that site config, you would define WP_CONTENT_DIR as /var/www/mysite/. That way, everything just works by getting nginx to run WordPress from /usr/share/wordpress/ and WordPress automatically loads plugins/themes etc. through the /var directory.

Literally everything I've tried seems to result in Matomo wanting me to allow it write access to /usr/share/matomo/ and to run everything from there.

@Dreamsorcerer
Copy link
Author

Dreamsorcerer commented Jul 28, 2018

So, for the record, instructions that I've been following: http://debian.piwik.org/
After installing the package, it says 'Check the configuration files in /etc/matomo/'.
No information on what I should be checking or what I might want to change. And, that's the end of those instructions, so I have no information on how I might run the project.

Finding these instructions in the README: https://github.com/matomo-org/matomo-package/blob/master/debian/README.Debian
That asks me to setup a database.
Then adds an Apache config.
But, as far as I can tell that config is just telling it to run through /usr/share/matomo/ which is what I've tried, and keeps giving me errors because it's not writeable.

@Dreamsorcerer
Copy link
Author

I'm still rather lost, any hints on how it's supposed to work would be great. The only way I can imagine at this point is using some kind of overlayfs setup, using /usr/share/matomo as a read-only layer and then having a writeable layer on top of that.

Other than that, I'm completely lost as to how someone is supposed to run Matomo from this package...

@florianjacob
Copy link

florianjacob commented Aug 6, 2018

Small hints hoping they could be useful: The canonical way to change stuff like PIWIK_USER_PATH is a bootstrap.php file, see https://matomo.org/docs/include-piwik-in-your-project/#bootstrap-php-execute-custom-code-before-matomo-runs for more info. That way, you don't have to modify index.php.

e.g. something like this:

<?php
// set PIWIK_USER_PATH to a writable location
define('PIWIK_USER_PATH', '/var/www/mysite');

(adapted from the NixOS package I maintain, so I can't give you specific info on this Debian package)

Also, the @var location should be removed, as none of the files in PIWIK_USER_PATH are intended to be served to users through the web server, they're only config and tmp files, read / writte by the php scripts in the /usr location.

@Dreamsorcerer
Copy link
Author

Thanks so much @florianjacob, that gets it working.

@aureq Looking at how the package installs, I'm guessing the Debian package intends everything to be run out of /etc/matomo, rather than a /var/www/ site. However, without me adding the bootstrap.php file, it will only try to run from /usr/share/matomo. Obviously, manually adding bootstrap.php is another hack, so it seems to me that the package is missing this file, which should be hardcoded to /etc/matomo (if that's how the Debian package is meant to be run), or otherwise include a file from /etc/matomo/ to allow the user to customise the path.

@Dreamsorcerer
Copy link
Author

Another error now, when downloading the geoip2 databases; it wants to save them to /usr/share/matomo/misc/. So, either Matomo should be tweaked to download them somewhere under the user_path, or if it must use that location, then that directory should be a symlink to somewhere in the user_path.

@mattab
Copy link
Member

mattab commented Aug 30, 2021

Thanks for your patience, let's continue the discussion in this other issue for now, where we're looking for a new maintainer for the debian package: #131

@mattab mattab closed this as completed Aug 30, 2021
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

4 participants