Install Traccar from source

35TlEcDva year ago

Hello everyone,
I want to install traccar from the source code (server and web) to create a custom version and I wanted to be sure to do it right.
From what I understood it is necessary to recover the source code of the server and the web, in the opt/ folder, thanks to a git clone recursive.
Then you have to build the server with ./gradle assembles then build the web with npm commands and finally launch the traccar service.
And for the modifications make the changes locally then change the files on the server and restart the service

Am I on the right track or are there any errors in the installation I want to do or steps I would have missed?

Thanks for your answers and congratulations for the application.

Track-tracea year ago

I would say just start trying,

https://www.traccar.org/build/

35TlEcDva year ago

thank you for your answer, I will try this and get back to you if I have any problems

35TlEcDva year ago

I have built traccar server and web, now I want to put it on my vps, do I have to copy all the traccar folder in the opt folder? I tried to do it via the scp command but it doesn't find my folder, do you do this way to install the source code or do you have another method?

Thank you for your answers

Anton Tananaeva year ago

You need to take the output and replace the relevant files.

35TlEcDva year ago

Oh I was thinking of building and then transferring all the code, so I clone the source code first and then change the files (.jar, etc)

Cristiana year ago

I do it this way:
I install the official version of Traccar on my VPS (5.6 so far).
Then I download the source code of this version and make the necessary modifications, usually only in the frontend.
Then I compile and in the case of the frontend I replace the content of the /modern folder, for the server or backend I replace the .jar file.
I don't make modifications on the database in order not to have problems with future Traccar updates.
I hope it helps you.

35TlEcDva year ago

Thanks Cristian for the help, i download the source code on my vps (your certainly download the release so maybe i will change) and i want to change files, what command do u use ? I tried scp but it doesn't work for me so i certainly made a mistake..

Cristiana year ago

I don't quite understand what your problem is.
What are you trying to use the scp command for?
If it is to upload your modified files to the vps, what I do is to use filezilla to upload to the vps the modifications to a user folder, then I login to the vps by ssh and from there I use the following command

sudo rm -rf /opt/traccar/modern (I delete the modern folder from the official installation)

sudo cp -r /home/user/modern /opt/traccar (here I copy the modern folder uploaded to the user's /home to the official traccar installation)

restart service and verify that everything works.

35TlEcDva year ago

Hello, thank you for these precisions. I'm a student and I'm new to server hosting, I only know filezilla by name, I'll try to set it up.
So I delete the modern folder of the release and replace it with the build of the modern folder of the source code.
thanks again for your time

35TlEcDva year ago

Hello, I installed the release and changed the modern folder by the modern folder of the source code that I modified then I restarted the service. After that it gives me the 403 forbidden error. Is there anything I did wrong or do you know what I forgot to do?
Thanks

35TlEcDva year ago

Hello, i changed the web path from ./modern to ./modern/build, I don't know if it's a good operation but it worked for me. Is this a good thing or was there another good way to do it?
Thanks

gustavofariasa year ago

You don't need to upload to your VPS the entire "modern" folder of your local modified copy. You just need to overwrite the contents of /opt/traccar/modern (VPS) with the contents of your local traccar/traccar-web/modern/build
Doing so, no need to change web path.
The way you did is not wrong, but you uploaded the source code of your modifications too.

35TlEcDva year ago

Hello, when you install the release traccar the content of the modern folder (not containing the build) is different from the content of the modern folder of the source code so I changed once all the content to be able to change afterwards.
Should the content of the modern folder be: only the content of the build folder of the compiled source code, the content of the modern folder of the release to which we add the build or the modern folder of the source code where we update only the build for each modification?

Thanks for your help

gustavofariasa year ago

"when you install the release traccar the content of the modern folder (not containing the build) is different from the content of the modern folder of the source code"
Yes, the release modern folder only contains the minified(compressed) files. The source modern folder contains the source. The content of the build folder (after created, of course), on the other hand, should match the release modern folder.

"Should the content of the modern folder be:"
"1) only the content of the build folder of the compiled source code,"
"2) the content of the modern folder of the release to which we add the build"
"3) the modern folder of the source code where we update only the build for each modification"

Definitely (1) is the most easy/straightforward option. You just compile the source, and paste the content of the build folder over the content of modern folder.
Traccar is flexible enough. So (2) will work too, since you change the web path to "./modern/build". But you will just waste the rest of the content of modern folder possibly causing confusion. (3) is even worse, you will need to change web path the same way as (2) and put source code in the modern folder for no reason.