I have a website running an OctoberCMS theme that I built. It’s running on a server from DigitalOcean. I need to add a separate project (namely code from Matomo analytics) on the same server and access a public page (e.g. my_site.com/matomo). I’m new enough to Laravel and server configurations that I’m unsure of how I need to configure the index.php files or maybe something like .htaccess so that I can access my_site.com/matomo.
Here’s my file structure
/var/www/html/ index.php (serves the pages of my project) artisan bootstrap/ config/ modules/ plugins/ server.php storage/ themes/ vendor/ matomo/ (for installing the analytics for the site) index.php matomo.php piwik.php config/ a number of other files I can enumerate if necessary
I’ve followed the instructions from matomo but to no avail. When I try to go to my_site.com/matomo I just get a 404 from my website with my theme’s formatting for it.
I know this shouldn’t be hard. Thanks!
EDIT: The home page of my website is at my_site.com, as desired. The various pages are at my_site.com/page_name. This is configured fine for my purposes.
Now, for Matomo, the instructions say:
Open your FTP client and upload the Matomo files in ‘binary mode’ to the desired location on your web server. For example using the Filezilla FTP client, you can enable Binary mode transfer in the top menu Transfer > Transfer type > Binary). All files can be uploaded to a “analytics” sub-directory in your public www folder, for example http://yourdomain.org/analytics/ or you could setup Matomo in its own subdomain and upload all the files at http://analytics.example.org/ If you have SSH access to your server, you can use it instead of FTP as it is much faster: run wget https://builds.matomo.org/matomo.zip && unzip matomo.zip
So, I used the wget option to add it to what I believe is the “public www folder”, /var/www/html
. So the instructions lead me to believe I can go to my_site.com/analytics/ and then view the GUI webpage for further install and setup. However, this doesn’t work as it takes to a 404 page that’s setup for the rest of my site. I also don’t know that I’d expect it to work as none of the files or folders in Matomo are named “analytics” — I’ve also tried my_site.com/matomo for the record. So, this is to say, I don’t know where the Matomo page is presented.
Advertisement
Answer
I don’t have any experience with Matomo
, but from the question I understood that you want to install two software X as CMS
and Y as Matomo
.
Your web server(I assume Apache is the web server) will serve all request to the following path: /var/www/html/index.php
. Which belong to software X. Your request my_site.com/matomo
will be served to software X, and because X doesn’t expect this request it will output 404 Not Found
error.
The first solution: which is the bad solution and harder solution is to edit /var/www/html/index.php
and combine it with Y index.php
if request have matomo in the URL.
The second solution: which is the optimal and better solution is to separate X and Y. It could be done in several ways:
You can combine all X files in a folder under
/var/www/html/x
, and all Y files in folder under/var/www/html/y
. Then you can access x using the following URLmy_site.com/x
and y usingmy_site.com/y
.If the first way in not possbile because you need to have X as root URL like
my_site.com
. Then you can combine all Y file under the following folder/var/www/html/matomo
. Then you need to create sub domain (virtual host for Y).
Create virtual host using Ubuntu and Apache:
sudo touch /etc/apache2/sites-available/matomo.my_site.com.conf
Then edit the file using your favorite text editor I will use nano
sudo nano /etc/apache2/sites-available/matomo.my_site.com.conf
and past the following code:
<VirtualHost *:80> ServerAdmin admin@my_site.com ServerName matomo.my_site.com DocumentRoot /var/www/html/matomo/ ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined </VirtualHost>
Change my_site.com
to your domain.
Then you need to enable the virtual host
sudo a2ensite /etc/apache2/sites-available/matomo.my_site.com.conf
Then restart apache to see the result.
sudo systemctl restart apache2
Your matomo
will be under the following URL matomo.my_site.com
If you are not using Ubuntu or Apache, tell me what are you using to update my answer.