|
| 1 | +# OLS CLI |
| 2 | + |
| 3 | + |
| 4 | + |
| 5 | +[](https://github.com/Code-Egg/ols-cli/actions/) |
| 6 | +[](https://github.com/Code-Egg/ols-cli/actions/workflows/release.yml) |
| 7 | +[](https://go.dev/) |
| 8 | +[](https://github.com/Code-Egg/ols-cli/releases) |
| 9 | + |
| 10 | +[](https://ubuntu.com/) |
| 11 | +[](https://www.centos.org/) |
| 12 | +[-5C2D91?logo=amd&logoColor=white)](https://en.wikipedia.org/wiki/X86-64) |
| 13 | +[-0091BD?logo=arm&logoColor=white)](https://en.wikipedia.org/wiki/AArch64) |
| 14 | + |
| 15 | +## Installation |
| 16 | + |
| 17 | +Use the one-line installer to install ols cli binary: |
| 18 | + |
| 19 | +```bash |
| 20 | +bash <(curl -fsSL https://raw.githubusercontent.com/Code-Egg/ols-cli/master/install_olscli.sh) |
| 21 | +``` |
| 22 | + |
| 23 | +### Install runtime once |
| 24 | + |
| 25 | +Install OpenLiteSpeed, PHP, Database. |
| 26 | + |
| 27 | +```bash |
| 28 | +sudo ols install |
| 29 | +``` |
| 30 | + |
| 31 | +## Usage |
| 32 | + |
| 33 | +### Create a wordprss site |
| 34 | + |
| 35 | +```bash |
| 36 | +sudo ols site create example.com --wp |
| 37 | +``` |
| 38 | + |
| 39 | +### Create a site with WordPress + Let's Encrypt |
| 40 | + |
| 41 | +```bash |
| 42 | +sudo ols site create example.com --wp --le |
| 43 | +``` |
| 44 | + |
| 45 | +### Update a site to a target PHP version |
| 46 | + |
| 47 | +```bash |
| 48 | +sudo ols site update example.com --php85 |
| 49 | +``` |
| 50 | + |
| 51 | +### Update CLI binary to latest release |
| 52 | + |
| 53 | +```bash |
| 54 | +sudo ols update |
| 55 | +``` |
| 56 | + |
| 57 | +### Security |
| 58 | + |
| 59 | +#### Enable OWASP + reCAPTCHA and add security headers on a site |
| 60 | + |
| 61 | +```bash |
| 62 | +sudo ols site update example.com --enable-owasp --enable-recaptcha --hsts |
| 63 | +``` |
| 64 | + |
| 65 | +#### Enable namespace |
| 66 | + |
| 67 | +```bash |
| 68 | +sudo ols site update example.com --enable-ns |
| 69 | +``` |
| 70 | + |
| 71 | + |
| 72 | +### Control |
| 73 | + |
| 74 | +#### Show site information |
| 75 | + |
| 76 | +```bash |
| 77 | +ols site info example.com |
| 78 | +``` |
| 79 | + |
| 80 | +#### Show OpenLiteSpeed virtual host config |
| 81 | + |
| 82 | +```bash |
| 83 | +ols site show example.com |
| 84 | +``` |
| 85 | + |
| 86 | +#### List managed sites |
| 87 | + |
| 88 | +```bash |
| 89 | +ols site list |
| 90 | +``` |
| 91 | + |
| 92 | +### Preview mode |
| 93 | + |
| 94 | +```bash |
| 95 | +ols --dry-run site create example.com --wp --le --php85 --enable-owasp --hsts --enable-ns |
| 96 | +ols --dry-run site update example.com --enable-recaptcha --disable-owasp --disable-ns --le |
| 97 | +ols --dry-run site info example.com |
| 98 | +ols --dry-run site show example.com |
| 99 | +ols --dry-run site list |
| 100 | +ols --dry-run update |
| 101 | +``` |
| 102 | + |
| 103 | +## Command overview |
| 104 | + |
| 105 | +The ols commands: |
| 106 | + |
| 107 | +```bash |
| 108 | +ols (command) [options] |
| 109 | +``` |
| 110 | + |
| 111 | +| Command | Purpose | Options | |
| 112 | +| --- | --- | --- | |
| 113 | +| `install` | Install/align OpenLiteSpeed runtime and related packages | `--php81` `--php82` `--php83` `--php84` `--php85` `--database` `--config` `--http-port` `--https-port` `--ssl-cert` `--ssl-key` `--no-listeners` | |
| 114 | +| `site` | Manage sites (`create`, `update`, `enable`, `disable`, `info`, `show`, `list`, `delete`) | `--wp` `--le` `--php81` `--php82` `--php83` `--php84` `--php85` `--enable-owasp` `--disable-owasp` `--enable-recaptcha` `--disable-recaptcha` `--enable-ns` `--disable-ns` `--hsts` `--keep-db` | |
| 115 | +| `update` | Update installed `ols` binary to latest GitHub release for current platform | | |
| 116 | + |
| 117 | +Global options (apply to all commands): `--dry-run`, `--color` |
| 118 | + |
| 119 | + |
| 120 | +### site |
| 121 | +```bash |
| 122 | +ols site (command) [options] |
| 123 | +``` |
| 124 | + |
| 125 | +| Subcommand | Purpose | Options | |
| 126 | +| --- | --- | --- | |
| 127 | +| `create` | Create a new site/vhost | `--wp` `--le` `--php81` `--php82` `--php83` `--php84` `--php85` `--enable-owasp` `--disable-owasp` `--enable-recaptcha` `--disable-recaptcha` `--enable-ns` `--disable-ns` `--hsts` | |
| 128 | +| `update` | Update an existing site (PHP target optional when only WordPress/security/LE flags are used) | optional `--wp`, optional `--le`, optional PHP target: `--php81` `--php82` `--php83` `--php84` `--php85`, or security flags: `--enable-owasp` `--disable-owasp` `--enable-recaptcha` `--disable-recaptcha` `--enable-ns` `--disable-ns` `--hsts` | |
| 129 | +| `enable` | Enable site from server-level | | |
| 130 | +| `disable` | Disable site from server-level | | |
| 131 | +| `info` | Show site metadata and detected status | | |
| 132 | +| `show` | Print OLS virtual host config | | |
| 133 | +| `list` | List managed sites discovered from OLS vhost directory | | |
| 134 | +| `delete` | Remove site config/files and optionally keep DB | `--keep-db` | |
| 135 | + |
| 136 | + |
| 137 | +## Development |
| 138 | + |
| 139 | +### Build locally |
| 140 | + |
| 141 | +```bash |
| 142 | +go build -o ols ./cmd/ols |
| 143 | +``` |
| 144 | + |
| 145 | +### Run tests |
| 146 | + |
| 147 | +```bash |
| 148 | +go test ./... |
| 149 | +``` |
| 150 | + |
| 151 | +For verbose output: |
| 152 | + |
| 153 | +```bash |
| 154 | +go test -v ./... |
| 155 | +``` |
| 156 | + |
| 157 | + |
| 158 | +## FAQ |
| 159 | + |
| 160 | +#### Custom the default config file |
| 161 | +Use config file defaults (recommended for first-run bootstrap): |
| 162 | + |
| 163 | +```bash |
| 164 | +sudo mkdir -p /etc/ols-cli |
| 165 | +sudo cp docs/install.example.json /etc/ols-cli/install.json |
| 166 | +sudo ols install |
| 167 | +``` |
| 168 | + |
| 169 | +`install.json` also supports: |
| 170 | +- `owasp_crs_version` (for example, `"4.21.0"`) for OWASP CRS setup during `ols install` |
| 171 | +- `vh_recaptcha_type` and `vh_recaptcha_reg_conn_limit` (defaults: `1` and `500`) used when enabling vhost reCAPTCHA via `site create/update --enable-recaptcha` |
| 172 | + |
| 173 | +By default, `ols install` prepares server-level security blocks as: |
| 174 | +- `module mod_security` with `ls_enabled 0` |
| 175 | +- `lsrecaptcha` with `enabled 1` and `type 0` |
| 176 | +- `namespace` with `1` |
| 177 | + |
| 178 | +Override config values with flags when needed: |
| 179 | + |
| 180 | +```bash |
| 181 | +sudo ols install --config /etc/ols-cli/install.json --php85 --database mysql --http-port 80 --https-port 443 |
| 182 | +sudo ols install --no-listeners |
| 183 | +``` |
0 commit comments