# Installation via Linux installer

> Source: https://ferron.sh/docs/installation/linux/installer

You can install Ferron on Linux systems with an interactive installer script. The installer detects your distribution, architecture, and C library. Then it offers a choice between installing via a package manager or as a standalone archive.

## Installation steps

### 1. Run the installer

To install Ferron, run the following command:

```bash
sudo bash -c "$(curl -fsSL https://get.ferron.sh/v3)"
```

The installer prompts you to choose the installation type. If packages are available for your distribution, the installer offers to install Ferron via your package manager. Otherwise, it installs the archive version directly.

> [!note]
> On RHEL/Fedora systems, the installer automatically configures SELinux contexts and booleans for Ferron. If you encounter permission issues, verify that SELinux is properly configured.

### 2. Access the web server

By default, Ferron serves content from the `/var/www/ferron` directory. Open a web browser and navigate to `http://localhost` to check if the server runs and serves the default `index.html` file.

If you see the "Ferron is ready to serve." message on the page, the web server works correctly.

> [!tip]
> If you cannot access the server from another machine, make sure your firewall allows incoming connections on port 80. If you use a different port, allow connections on that port. If port 80 is already in use, change the listen port in `/etc/ferron/ferron.conf` and reload the service.

## File structure

The installer for Linux creates the following file structure:

- `/usr/sbin/ferron` - Ferron web server
- `/usr/sbin/ferron-fmt` - Ferron configuration formatter
- `/usr/sbin/ferron-kdl2ferron` - Ferron configuration conversion tool
- `/usr/sbin/ferron-passwd` - Ferron user password generation tool
- `/usr/sbin/ferron-precompress` - Ferron static files precompression tool
- `/usr/sbin/ferron-serve` - Ferron zero-configuration static file serving
- `/var/log/ferron/access.log` - Ferron access log in Combined Log Format
- `/var/log/ferron/error.log` - Ferron error log
- `/var/www/ferron` - the web root for Ferron
- `/etc/ferron/ferron.conf` - Ferron configuration

## Updating Ferron

To update Ferron to the latest version, run the installer script again:

```bash
sudo bash -c "$(curl -fsSL https://get.ferron.sh/v3)"
```

The installer detects existing installations and offers to update them.

## Managing the Ferron service

### Stopping the service

To stop the Ferron service, run:

```sh
sudo systemctl stop ferron # For systemd systems
sudo /etc/init.d/ferron stop # For non-systemd systems
```

### Restarting the service

To restart the service:

```sh
sudo systemctl restart ferron # For systemd systems
sudo /etc/init.d/ferron restart # For non-systemd systems
```

### Reloading the configuration

To reload the configuration without restarting the service:

```sh
sudo systemctl reload ferron # For systemd systems
sudo /etc/init.d/ferron reload # For non-systemd systems
```

## Environment variables

The installer supports several environment variables for automation and advanced use cases. Set them before running the installer script.

| Variable                | Description                                                                                                                                 | Example                                             |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| `FERRON_ARCHIVE_PATH`   | Path to a locally downloaded Ferron archive for offline installation. The installer will validate the archive and skip the download step.   | `/tmp/ferron-3.0.0-x86_64-unknown-linux-gnu.tar.gz` |
| `FERRON_VERSION`        | Specify a particular Ferron version to install. If not set, the installer fetches the latest stable version from `dl.ferron.sh`.            | `3.0.0`                                             |
| `FERRON_INSTALL_METHOD` | Override the detected install method. Valid values: `archive`, `debian`, `rhel`. Useful when the auto-detection fails.                      | `archive`                                           |
| `FERRON_INSTALL_MODE`   | Set to `update` or `uninstall` to skip the interactive mode selection. It only applies when the installer detects an existing installation. | `update`                                            |
| `FERRON_REMOVE_USER`    | During uninstall, set to `yes` to automatically remove the `ferron` system user and group without prompting.                                | `yes`                                               |
| `NO_COLOR`              | Set to any value to disable colored terminal output. Follows the [NO_COLOR standard](https://no-color.org/).                                | `1`                                                 |

### Examples

**Install from a locally downloaded archive:**

```bash
sudo FERRON_ARCHIVE_PATH=/tmp/ferron-3.0.0-x86_64-unknown-linux-gnu.tar.gz \
    bash -c "$(curl -fsSL https://get.ferron.sh/v3)"
```

**Install a specific version:**

```bash
sudo FERRON_VERSION=3.0.0 \
    bash -c "$(curl -fsSL https://get.ferron.sh/v3)"
```

**Non-interactive update:**

```bash
sudo FERRON_INSTALL_MODE=update \
    bash -c "$(curl -fsSL https://get.ferron.sh/v3)"
```