Install nvm then run the following commands to get the LTS version of nodejs.
Then run the following command to get the LTS version of nodejs.
```bash
$ nvm install --lts
nvm install --lts
```
You may install Node.js yourself without nvm if you prefer.
Installing Node.js yourself without nvm is possible, but unsupported by this guide.
**6. Configure nginx**
**6. (Optional) If you want a .onion address (Tor) and/or .loki address (Lokinet)**
For standard installations, run `configs/nginx/nginx.sh` as root. This will prompt you for installation directory, domains, onion/lokinet, enable geoip, install a letsencrypt certificate with certbot and more.
Install Tor, setup a hidden service, and output your .onion address:
```bash
sudo apt install tor -y
sudo systemctl enable --now tor
sudo sh -c "cat > /etc/tor/torrc" <<'EOF'
HiddenServiceDir /var/lib/tor/jschan/
HiddenServiceVersion 3
HiddenServicePort 80 unix:/var/run/nginx-tor.sock
EOF
For non-standard installations like using a CDN, see [configs/nginx/README.md](configs/nginx/README.md) and DIY.
sudo systemctl restart tor
sudo cat /var/lib/tor/jschan/hostname
```
**7. Get the backend setup & running**
Install Lokinet, setup a SNApp, and find your .loki address:
# you can also add more .pug files in that folder with the same general format to create other custom pages
Note down the .loki and .onion address for the next step.
# install nodejs packages
$ npm install
**7. Setup nginx**
# replace the master file for your favicon in gulp/res/icons/master.png
For standard installations, run `configs/nginx/nginx.sh`. This will prompt you for installation directory, domains, onion/lokinet, enable geoip, install a letsencrypt certificate with certbot and more:
```bash
sudo bash configs/nginx/nginx.sh
```
# run the setup script. installs pm2 process manager and gulp build system and runs some gulp tasks.
$ npm run-script setup
For non-standard installations like using a CDN, see [configs/nginx/README.md](configs/nginx/README.md) and DIY.
# run gulp reset to setup the database and folder structure and create the admin account. **Default admin account details with random password will be printed to the command line.**
$ gulp reset
# NOTE: dont run gulp reset again unless you want to completely irreversibly wipe everything.
**8. Get the backend setup & running**
# make jschan pm2 a service and load on system startup. this will output some additional commands you need to run to complete the process if you were smart and didnt do everything as "root" user.
$ pm2 startup
1. Copy the example secrets file and edit it with your mongodb+redis credentials, cookie secrets, etc:
# some commands you may need to use in future/find helpful
$ pm2 list #list running pm2 processes
$ pm2 logs #see logs
$ pm2 reload ecosystem.config.js #reload all backend processes
4. Replace `gulp/res/icons/master.png` with your desired favicon image.
# gulp is used for various jobs like minifying and compiling scripts
# the build-worker process may also run some of these for certain operations e.g. editing global settings in the web panel
$ gulp --tasks #list available gulp tasks
$ gulp migrate #check for and run db migrations
$ gulp password #reset the admin account password if you forgot it
$ gulp #run default gulp task
5. Run the setup script. This will install `pm2` (nodejs process manager) and `gulp` (task system) and runs some gulp tasks.
```bash
npm run-script setup
```
**8. Optionally, if you plan to use the webring and want to make requests with a proxy to mask your origin server IP:**
6. Run gulp reset to initialize the database and folder structure, and create the admin account. **Default admin account with random password will be printed to the command line.** NOTE: dont run gulp reset again unless you want to completely irreversibly wipe everything.
```bash
gulp reset
```
7. Make pm2 a system service and load on system startup. **NOTE: This will also output some additional commands you need to run to complete the process. Read the command output carefully.**
```
pm2 startup
```
8. Start all the backend processes.
```bash
npm run-script start
gulp
pm2 save
```
Some commands you may need to use in future/find helpful:
- `pm2 list` - Lists running pm2 processes.
- `pm2 logs` - Start tailing logs.
- `pm2 reload ecosystem.config.js` - Reload all backend processes.
- `gulp password` - Reset the admin account password if you forgot it.
- `gulp` - Run the default gulp task.
More information and commands for customisation or advanced use is in the ADVANCED section.
**9. (Optional) if you plan to use the webring and want to make requests with a proxy to mask your origin server IP**
EITHER:
@ -112,44 +220,64 @@ Either of the first two options will allow you to follow .onions in your webring
To enable the proxy, tick "Use Socks Proxy" in global management settings and set the appropriate proxy address, e.g. `socks5h://127.0.0.1:9050`, then save settings.
**10. All done!**
## Updating
0. `cd` to your jschan installation folder.
1. Stop the running backend:
```bash
#first, stop the jschan backend
$ pm2 stop ecosystem.config.js
pm2 stop ecosystem.config.js
```
#update node.js to the latest LTS node version, latest npm, and reinstall global packages:
#NOTE: Only works if you installed node.js "nvm" as per the recommendation in the installation instructions.
2. (Optional) Update node.js to the latest LTS node version, latest npm, and reinstall global packages. NOTE: Only works if you installed node.js "nvm" as per the recommendation in the installation instructions.
4. Install nodejs dependencies again in case any have updated or changed
```bash
npm install
```
5. Check if the nginx config needs updating, comparing the version you updated from with the current version:
```bash
git diff v0.9.2 v0.8.0 configs/nginx
```
If the output was blank, goto step 6.
#install dependencies again in case any have updated or changed
$ npm install
If the output showed changes and you used `configs/nginx/nginx.sh` to setup nginx, run it again to reconfigure nginx and overwrite your old configuration.
#check if anything nginx related changed between the old and new verison, e.g.
$ git diff v0.1.5 v0.1.6 configs/nginx
#If you use a completely standard jschan nginx, run configs/nginx/nginx.sh again.
#Otherwise, update your nginx config with the necessary changes.
If you have a non-standard nginx config, update your nginx config yourself.
#run the gulp migrate task. this will update things such as your database schema.
$ gulp migrate
#run the default gulp task to update, scripts, css, icons, images and delete old html
$ gulp
6. Run the gulp migrate task. This will run "migrations" such as updating the database schema or file structure:
```bash
gulp migrate && gulp
```
#start the backend again
$ pm2 restart ecosystem.config.js --env production
7. Start the backend:
```bash
pm2 restart ecosystem.config.js --env production
```
#if something breaks, check and read the logs, they will help figure out what went wrong
$ pm2 logs
At this point, your installation is updated. If something is broken, check and read the logs, they will help figure out what went wrong:
```bash
pm2 logs
```
## Help! Something didn't work!!!1!!1
If you are sure you did everything correctly and you still can't get it working, you can ask for help in the IRC (linked in [README](README.md)).
Be polite, ask [smart questions](http://www.catb.org/~esr/faqs/smart-questions.html), and keep in mind nobody is obliged to help you.
Be polite, be patient, ask [smart questions](http://www.catb.org/~esr/faqs/smart-questions.html), and keep in mind nobody is obliged to help you.
Paid support is available at a rate of $50USD/hr, payable in cryptocurrency (BTC/XMR) only. Email the address on my [Gitgud profile](https://gitgud.io/fatchan) to inquire.