next/README.md

76 lines
2.3 KiB
Markdown
Raw Normal View History

2024-04-26 14:42:57 +00:00
# next
2024-04-26 16:19:35 +00:00
2024-04-26 16:22:26 +00:00
PHP 8 Server for [Nex Protocol](nex://piclog.blue/nex/info/specification.txt), based on the [nex-php](https://github.com/YGGverse/nex-php) library
2024-04-26 16:19:35 +00:00
## Install
* `git clone https://github.com/YGGverse/next.git`
2024-04-26 19:53:17 +00:00
* `cd next` - navigate into the server directory
* `composer update` - grab latest dependencies
2024-04-26 16:19:35 +00:00
2024-04-26 19:47:12 +00:00
## NEX
Optimal to serve static files
2024-04-26 21:39:44 +00:00
For security reasons, `next` server prevents any access to the hidden files (started with dot)
2024-04-26 19:47:12 +00:00
### Start
2024-04-26 19:54:37 +00:00
Create as many servers as wanted by providing different `host` and `port` using optional arguments
2024-04-26 16:19:35 +00:00
``` bash
2024-04-26 19:47:12 +00:00
php src/nex.php host=127.0.0.1 port=1900 path=/target/dir
2024-04-26 16:19:35 +00:00
```
2024-04-26 19:47:12 +00:00
#### Arguments
##### Required
* `path` - **absolute path** to the public directory
##### Optional
2024-04-26 16:19:35 +00:00
2024-04-26 19:47:12 +00:00
* `host` - `127.0.0.1` by default
* `port` - `1900` by default
2024-04-26 21:41:37 +00:00
* `file` - index **filename** that server try to open on directory path requested, disabled by default
2024-04-26 19:50:41 +00:00
* `list` - show content listing in the requested directory (when index file not found), `yes` by default
2024-04-26 21:46:08 +00:00
* `fail` - **filepath** that contain failure text or template (e.g. `error.gmi`), `fail` text by default
2024-04-26 19:47:12 +00:00
* `size` - limit request length in bytes, `1024` by default
2024-04-26 20:52:42 +00:00
* `dump` - dump queries or set blank to disable, default: `[{time}] [{code}] {host}:{port} {path} {goal}`
2024-04-26 19:47:12 +00:00
* `{time}` - event time in `c` format
* `{code}` - formal response code: `1` - found, `0` - not found
* `{host}` - peer host
* `{port}` - peer port
* `{path}` - path requested
2024-04-26 21:03:37 +00:00
* `{goal}` - goal destination returned
2024-04-26 21:36:17 +00:00
### Autostart
Launch server as the `systemd` service
Following example mean you have `next` server installed into home directory of `next` user (`useradd -m next`)
2024-04-26 21:38:54 +00:00
1. `mkdir /home/next/public` - make sure you have created public folder
2. `sudo nano /etc/systemd/system/next.service` - create new service:
2024-04-26 21:36:17 +00:00
``` next.service
[Unit]
After=network.target
[Service]
Type=simple
User=next
Group=next
ExecStart=/usr/bin/php /home/next/next/src/nex.php path=/home/next/public
StandardOutput=file:/home/next/debug.log
StandardError=file:/home/next/error.log
Restart=on-failure
[Install]
WantedBy=multi-user.target
```
2024-04-26 21:38:54 +00:00
3. `sudo systemctl daemon-reload` - reload systemd configuration
4. `sudo systemctl enable next` - enable `next` service on system startup
5. `sudo systemctl start next` - start `next` server