svrjs-nextjs-website/pages/docs/index.mdx
2024-06-24 13:55:54 +05:30

104 lines
5.4 KiB
Text

---
title: SVR.JS documentation
---
# Welcome to the official documentation of SVR.JS!
_This documentation is in the public domain._
## First use
### System requirements
#### Minimum
- Node.JS 8.4.0 or newer (SVR.JS 3.4.x and earlier), Node.JS 10.0.0 or newer (SVR.JS 3.5.x and later) / Latest version of Bun (experimental).
- OS supported by Node.JS/Bun.
#### Recommended
- Latest Node.JS LTS version.
- 2-core CPU or better.
- 1.5GB of RAM or more.
- One of tested platforms: Android, FreeBSD, GNU/Linux, Haiku, Oracle Solaris, Microsoft Windows.
### Installation
#### Using SVR.JS installer (installer packages made in April 5, 2024 and later; GNU/Linux only)
The command for SVR.JS installation is available on [the SVR.JS home page](https://svrjs.org). First off, switch to _GNU/Linux_ tab, then copy the command below the tab into the terminal. The command looks something like this:
```sh copy
curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240509.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh
```
The command for SVR.JS installation is available in [the SVR.JS home page](https://svrjs.org). First off, switch to _GNU/Linux_ tab, then copy the command below the tab into the terminal. The command looks something like this: `curl -fsSL https://downloads.svrjs.org/installer/svr.js.installer.linux.20240509.sh > /tmp/installer.sh && sudo bash /tmp/installer.sh`. After starting the installer, you will be prompted to select the type of SVR.JS installation. After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, the server is started at _http://localhost_.
File structure will look like this:
- _/usr/lib/svrjs_ - SVR.JS installation directory
- _/var/log/svrjs_ - SVR.JS logs
- _/var/www/svrjs_ - SVR.JS web root
- _/etc/svrjs-config.json_ - SVR.JS configuration file (SVR.JS _config.json_)
SVR.JS installer will also install these commands:
- _svrjs-loghighlight_ - SVR.JS log highlighter
- _svrjs-logviewer_ - SVR.JS log viewer
- _svrpasswd_ - SVR.JS user management tool
- _svrjs-updater_ - SVR.JS updater
#### Using SVR.JS installer (installer packages made before April 5, 2024; GNU/Linux only)
SVR.JS now has a brand new installer for GNU/Linux. First, [download SVR.JS installer](https://downloads.svrjs.org/installer), then unpack your SVR.JS installer zip archive. After unpacking the installer, download SVR.JS zip archive (not installer), copy it to the installer directory and rename it to "_svrjs.zip_". Then run SVR.JS installer using `sudo bash installer.sh`. After starting the installer, you will be prompted to select the type of OS (type of GNU/Linux distribution). After selecting the type, SVR.JS installer will install Node.JS, SVR.JS and create SVR.JS service. During installation, you may be prompted for the installation of dependencies. Once the installation is done, restart your server OS or type `systemctl start svrjs` or `/etc/init.d/svrjs start` to start SVR.JS and get a web server on _http://localhost_.
File structure will look like this:
- _/usr/lib/svrjs_ - SVR.JS installation directory
- _/var/log/svrjs_ - SVR.JS logs
- _/var/www/svrjs_ - SVR.JS web root
- _/etc/svrjs-config.json_ - SVR.JS configuration file (SVR.JS _config.json_)
SVR.JS installer will also install these commands:
- _svrjs-loghighlight_ - SVR.JS log highlighter
- _svrjs-logviewer_ - SVR.JS log viewer
- _svrpasswd_ - SVR.JS user management tool
#### Using _create-svrjs-server_ tool
To install SVR.JS using _create-svrjs-server_, first install the utility using `npm install -g svrjs`. Then create a directory, which will contain SVR.JS. Change your working directory to a new one, and run one of those commands:
- `create-svrjs-server lts` - Latest SVR.JS LTS version
- `create-svrjs-server latest` - Latest SVR.JS version
- `create-svrjs-server 3.6.1` - SVR.JS 3.6.1 (replace 3.6.1 with your desired version)
After downloading and installing SVR.JS to your working directory, run `node svr.js` for SVR.JS 3.x or `node svr_new.js` for earlier versions or `bun run svr.js` if you're using Bun instead of Node.JS.
You will then see this message:
```
Decompressing modules...
Deleting SVR.JS stub...
Decompressing SVR.JS...
Restart SVR.JS to get server interface.
```
After running this command again, you'll get a web server on _http://localhost_.
#### Using Docker
To install SVR.JS via Docker, first pull the image using `docker pull svrjs/svrjs` command, or `docker pull svrjs/svrjs:lts` command, if you wish to install LTS version of SVR.JS. Then create and start the Docker container using `docker run --name mysvrjs -d -p 80:80 --restart=always svrjs/svrjs` command (replace `mysvrjs` with desired Docker container name). The file structure is the same, as it would be installed via SVR.JS installer. Once the installation is done, the server is started at _http://localhost_.
#### Manual installation
To install SVR.JS manually, first unpack your SVR.JS zip archive you downloaded from SVR.JS download page. Then change your working directory to one containing SVR.JS script stub, and run `node svr.js` for SVR.JS 3.x or `node svr_new.js` for earlier versions or `bun run svr.js` if you're using Bun instead of Node.JS.
You will then see this message:
```
Decompressing modules...
Deleting SVR.JS stub...
Decompressing SVR.JS...
Restart SVR.JS to get server interface.
```