# Installing CloudTube ## System dependencies - node.js (v12+) - nginx (needed for public instances only) ## Prepare **Install NewLeaf first.** [→ Installing NewLeaf](./Installing%20NewLeaf.md) Change to the CloudTube user you created before: ``` # su cloudtube ``` ## Installing Clone the repo: ``` $ git clone https://git.sr.ht/~cadence/cloudtube $ cd cloudtube ``` Install dependencies: ``` $ npm install ``` Set up the configuration. Configuration is read from the filename `config/config.js`. Copy the sample file to that name, **then edit it.** You must set the setting for the default instance. You should write an address that is reachable from the machine running CloudTube. Hint: If CloudTube and NewLeaf are on the same machine, you can write `http://localhost:3000`. ``` $ pushd config $ cp config.sample.js config.js $ $EDITOR config.js $ popd ``` All done! Start CloudTube: ``` $ npm run start ``` In the future, from a new terminal session, CloudTube can be started with: ``` $ cd [installation directory] $ npm run start ``` ### Updating ``` $ cd [installation directory] $ git pull $ npm install ``` Then start: ``` npm run start ``` ## systemd service If you want to control the services with systemd, you can use these files. This is optional. This service should be run as the cloudtube user rather than as the system. You may need to adjust the paths in these files. ### As user service If you find that these processes terminate when you log out, see the documentation for [`libpam-systemd`](https://manpages.debian.org/stretch/libpam-systemd/pam_systemd.8.en.html) and [`logind.conf`](https://manpages.debian.org/stretch/systemd/logind.conf.5.en.html). ``` [Unit] Description=CloudTube website [Service] Type=simple ExecStart=/usr/local/bin/node /home/cloudtube/cloudtube/server.js WorkingDirectory=/home/cloudtube/cloudtube # Restart timing Restart=always RestartSec=60 SyslogIdentifier=cloudtube [Install] WantedBy=default.target ``` Save to `~/.config/systemd/user/cloudtube.service`. #### Start service ``` $ systemctl --user daemon-reload $ systemctl --user start cloudtube ``` ...and if all is successful... ``` $ systemctl --user enable cloudtube ``` ### As system service ``` [Unit] Description=CloudTube After=network.target [Service] Type=simple ExecStart=/usr/local/bin/node /home/cloudtube/cloudtube/server.js WorkingDirectory=/home/cloudtube/cloudtube # Restart timing Restart=always RestartSec=60 # Disable logs StandardOutput=null StandardError=null SyslogIdentifier=cloudtube # User to run service as User=cloudtube [Install] WantedBy=multi-user.target ``` Save to `/etc/systemd/system/cloudtube.service`. #### Start service ``` # systemctl daemon-reload # systemctl start cloudtube ``` ...and if all is successful... ``` # systemctl enable cloudtube ``` ## nginx reverse proxy This will allow people to access CloudTube over HTTPS and without having to enter a port into the browser's address bar. It's highly recommended for public instances, but if this installation is for a test or for your personal use, you don't need to do it. Follow the steps [on the nginx documentation page →](https://git.sr.ht/~cadence/tube-docs/tree/main/item/docs/Proxy%20with%20nginx.md)