R
Railway•13mo ago
oz

Matomo on Railway

Anyone know a good way I can setup Matomo on Railway? I know how to do it on a normal VPS or local, but since I cant interact with console I am unsure how to do this. Any help is appreciated!
Solution:
hey give this a try and let me know if anything is broken? https://railway.app/template/MiHicG...
Jump to solution
28 Replies
Percy
Percy•13mo ago
Project ID: N/A
oz
oz•13mo ago
N/A
Brody
Brody•13mo ago
do they provide a docker image?
oz
oz•13mo ago
yes I actually was looking into the run local feature in railway I assume I copy the github on my computer and set it up there?
Brody
Brody•13mo ago
run local feature?
oz
oz•13mo ago
What I mean is I see that I can run a project locally, which I believe can be used to set up the software. Am I on to something here?
Brody
Brody•13mo ago
yes you can but I'd just run the docker image on Railway I'll see what I can do later tonight
oz
oz•13mo ago


[Region: us-west1]

==============

Using Nixpacks

==============


context: 7ce89026dc8f940e1f11c4c4ec0fa330

Nixpacks build failed





Nixpacks was unable to generate a build plan for this app.

Please check the documentation for supported languages: https://nixpacks.com



The contents of the app directory are:



docker-entrypoint.sh

generate-stackbrew-library.sh

fpm/

license.md

php.ini

README.md

Dockerfile-alpine.template

fpm-alpine/

.github/

update.sh

apache/

Dockerfile-debian.template

.examples/


[Region: us-west1]

==============

Using Nixpacks

==============


context: 7ce89026dc8f940e1f11c4c4ec0fa330

Nixpacks build failed





Nixpacks was unable to generate a build plan for this app.

Please check the documentation for supported languages: https://nixpacks.com



The contents of the app directory are:



docker-entrypoint.sh

generate-stackbrew-library.sh

fpm/

license.md

php.ini

README.md

Dockerfile-alpine.template

fpm-alpine/

.github/

update.sh

apache/

Dockerfile-debian.template

.examples/
oz
oz•13mo ago
This is current error I get for git: https://github.com/matomo-org/docker
GitHub
GitHub - matomo-org/docker: Official Docker project for Matomo Anal...
Official Docker project for Matomo Analytics. Contribute to matomo-org/docker development by creating an account on GitHub.
oz
oz•13mo ago
ALl I did was add create a space with MYSQL and this git, added the required env variables, and thats it
Brody
Brody•13mo ago
I wouldn't use a repo
oz
oz•13mo ago
So how else? Sorry as u can see I am new to Railway
Brody
Brody•13mo ago
I'll see what I can do (I'll try to make the template)
oz
oz•13mo ago
Oh I really appreciate it, doing some of my own research now as well
Brody
Brody•13mo ago
I'll be honest, it would be quite the task for someone new to railway to undertake
oz
oz•13mo ago
Appreciate the warning, gonna try for 10 min and see what happens Yeah I got it to build but now just stuck on deployment error
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.210. Set the 'ServerName' directive globally to suppress this message

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.210. Set the 'ServerName' directive globally to suppress this message

[Thu Oct 05 20:43:11.436995 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.24 configured -- resuming normal operations

[Thu Oct 05 20:43:11.437057 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.210. Set the 'ServerName' directive globally to suppress this message

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.210. Set the 'ServerName' directive globally to suppress this message

[Thu Oct 05 20:43:11.436995 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.24 configured -- resuming normal operations

[Thu Oct 05 20:43:11.437057 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
Brody
Brody•13mo ago
are you using a docker image?
oz
oz•13mo ago
In case it helps you here is my docker file
FROM php:8.1-apache

ENV PHP_MEMORY_LIMIT=256M
ENV MATOMO_VERSION 4.15.1

RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype-dev \
libjpeg-dev \
libldap2-dev \
libpng-dev \
libzip-dev \
procps \
; \
\
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
docker-php-ext-install -j "$(nproc)" \
gd \
bcmath \
ldap \
mysqli \
opcache \
pdo_mysql \
zip \
; \
\
# pecl will claim success even if one install fails, so we need to perform each install separately
pecl install APCu-5.1.21; \
pecl install redis-5.3.6; \
\
docker-php-ext-enable \
apcu \
redis \
; \
rm -r /tmp/pear; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

RUN set -ex; \
fetchDeps=" \
dirmngr \
gnupg \
"; \
apt-get update; \
apt-get install -y --no-install-recommends \
$fetchDeps \
; \
\
curl -fsSL -o matomo.tar.gz \
"https://builds.matomo.org/matomo-${MATOMO_VERSION}.tar.gz"; \
curl -fsSL -o matomo.tar.gz.asc \
"https://builds.matomo.org/matomo-${MATOMO_VERSION}.tar.gz.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys F529A27008477483777FC23D63BB30D0E5D2C749; \
gpg --batch --verify matomo.tar.gz.asc matomo.tar.gz; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" matomo.tar.gz.asc; \
tar -xzf matomo.tar.gz -C /usr/src/; \
rm matomo.tar.gz; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
rm -rf /var/lib/apt/lists/*

COPY php.ini /usr/local/etc/php/conf.d/php-matomo.ini

COPY docker-entrypoint.sh /entrypoint.sh

# WORKDIR is /var/www/html (inherited via "FROM php")
# "/entrypoint.sh" will populate it at container startup from /usr/src/matomo
# VOLUME /var/www/html

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
FROM php:8.1-apache

ENV PHP_MEMORY_LIMIT=256M
ENV MATOMO_VERSION 4.15.1

RUN set -ex; \
\
savedAptMark="$(apt-mark showmanual)"; \
\
apt-get update; \
apt-get install -y --no-install-recommends \
libfreetype-dev \
libjpeg-dev \
libldap2-dev \
libpng-dev \
libzip-dev \
procps \
; \
\
debMultiarch="$(dpkg-architecture --query DEB_BUILD_MULTIARCH)"; \
docker-php-ext-configure gd --with-freetype --with-jpeg; \
docker-php-ext-configure ldap --with-libdir="lib/$debMultiarch"; \
docker-php-ext-install -j "$(nproc)" \
gd \
bcmath \
ldap \
mysqli \
opcache \
pdo_mysql \
zip \
; \
\
# pecl will claim success even if one install fails, so we need to perform each install separately
pecl install APCu-5.1.21; \
pecl install redis-5.3.6; \
\
docker-php-ext-enable \
apcu \
redis \
; \
rm -r /tmp/pear; \
\
# reset apt-mark's "manual" list so that "purge --auto-remove" will remove all build dependencies
apt-mark auto '.*' > /dev/null; \
apt-mark manual $savedAptMark; \
ldd "$(php -r 'echo ini_get("extension_dir");')"/*.so \
| awk '/=>/ { so = $(NF-1); if (index(so, "/usr/local/") == 1) { next }; gsub("^/(usr/)?", "", so); print so }' \
| sort -u \
| xargs -r dpkg-query --search \
| cut -d: -f1 \
| sort -u \
| xargs -rt apt-mark manual; \
\
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false; \
rm -rf /var/lib/apt/lists/*

# set recommended PHP.ini settings
# see https://secure.php.net/manual/en/opcache.installation.php
RUN { \
echo 'opcache.memory_consumption=128'; \
echo 'opcache.interned_strings_buffer=8'; \
echo 'opcache.max_accelerated_files=4000'; \
echo 'opcache.revalidate_freq=2'; \
echo 'opcache.fast_shutdown=1'; \
} > /usr/local/etc/php/conf.d/opcache-recommended.ini

RUN set -ex; \
fetchDeps=" \
dirmngr \
gnupg \
"; \
apt-get update; \
apt-get install -y --no-install-recommends \
$fetchDeps \
; \
\
curl -fsSL -o matomo.tar.gz \
"https://builds.matomo.org/matomo-${MATOMO_VERSION}.tar.gz"; \
curl -fsSL -o matomo.tar.gz.asc \
"https://builds.matomo.org/matomo-${MATOMO_VERSION}.tar.gz.asc"; \
export GNUPGHOME="$(mktemp -d)"; \
gpg --batch --keyserver keyserver.ubuntu.com --recv-keys F529A27008477483777FC23D63BB30D0E5D2C749; \
gpg --batch --verify matomo.tar.gz.asc matomo.tar.gz; \
gpgconf --kill all; \
rm -rf "$GNUPGHOME" matomo.tar.gz.asc; \
tar -xzf matomo.tar.gz -C /usr/src/; \
rm matomo.tar.gz; \
apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false $fetchDeps; \
rm -rf /var/lib/apt/lists/*

COPY php.ini /usr/local/etc/php/conf.d/php-matomo.ini

COPY docker-entrypoint.sh /entrypoint.sh

# WORKDIR is /var/www/html (inherited via "FROM php")
# "/entrypoint.sh" will populate it at container startup from /usr/src/matomo
# VOLUME /var/www/html

ENTRYPOINT ["/entrypoint.sh"]
CMD ["apache2-foreground"]
Yeah the docker github I sent earlier
Brody
Brody•13mo ago
a dockerfile and a docker image are two different things btw matomo does provide a docker image, and it is highly preferable to use a docker image over a github repo with a dockerfile in it
oz
oz•13mo ago
Hmm I see. I should learn more about docker tbh...
Brody
Brody•13mo ago
it would be beneficial
oz
oz•13mo ago
Yeah... Wow I hate myself U were right, SO much easier Weirdly enough, it is still roughly same error
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.142. Set the 'ServerName' directive globally to suppress this message

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.142. Set the 'ServerName' directive globally to suppress this message

[Thu Oct 05 21:16:19.232320 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.24 configured -- resuming normal operations

[Thu Oct 05 21:16:19.232392 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.142. Set the 'ServerName' directive globally to suppress this message

AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 172.17.2.142. Set the 'ServerName' directive globally to suppress this message

[Thu Oct 05 21:16:19.232320 2023] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.57 (Debian) PHP/8.1.24 configured -- resuming normal operations

[Thu Oct 05 21:16:19.232392 2023] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND'
Brody
Brody•13mo ago
yeah I'll have to look Into it later
oz
oz•13mo ago
Ok appreciate your time and help 🙂 Side note: I got the error to leave by adding start command "sh -c "echo 'ServerName s.xxxx.com' >> /etc/apache2/apache2.conf && apache2-foreground"" But service is still unreachable on my custom domain, I am guessing its a port issue Got it working more sh -c "echo 'ServerName s.xxx.com' >> /etc/apache2/apache2.conf && apache2-foreground && echo 'Listen $PORT' >> /etc/apache2/ports.conf" now I get
You don't have permission to access this resource.
You don't have permission to access this resource.
on website, looking how I can fix this on railway
Solution
Brody
Brody•13mo ago
hey give this a try and let me know if anything is broken? https://railway.app/template/MiHicG
Adam
Adam•13mo ago
@oz ^
oz
oz•13mo ago
This worked perfectly thanks! Gonna test it more, your a legend!
Brody
Brody•13mo ago
yeah let me know if you run into issues, otherwise i will go ahead and publish this template to the templates marketplace oh and I'm like to note that the template will still log stuff about the server name, but that's just a warning and there's nothing wrong with the server name it decides to use automatically another note, communication to the mariadb is done exclusively over the private network and mariadb is not exposed externally in any way by default, if you wanted to enable access outside of the private network you can go to the databases settings to enable tcp proxying and enter the internal port mariadb listens on (3306) and use the username, password, host, and port to connect to the database externally, then once you no longer need external access you can remove the tcp proxy and all external access to the database will be severed without ever effecting the internal connection I'd add these as notes to the template overview once I publish, but just thought I'd jot them down for you here
Want results from more Discord servers?
Add your server