> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.bearsampp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Apache Web Server in Bearsampp

> Configure and manage the Apache web server in Bearsampp. Change ports, manage modules, generate SSL certificates, and add virtual hosts from the tray menu.

Apache is the web server at the heart of Bearsampp. It listens for HTTP and HTTPS requests and serves your PHP applications and static files from the `www/` folder. Every time you start Bearsampp, Apache starts automatically as a Windows service and stays running in the background.

## How Apache works in Bearsampp

Apache runs as a Windows service named `bearsamppapache`. It handles both plain HTTP traffic and HTTPS (SSL) traffic on separate ports. Bearsampp manages the service lifecycle for you — you start, stop, and restart it from the tray menu rather than from the command line.

## Default ports

| Protocol    | Default port |
| ----------- | ------------ |
| HTTP        | 80           |
| HTTPS (SSL) | 443          |

<Note>
  If another application on your machine already uses port 80 or 443, Apache will fail to start. Use **Change port** from the tray menu to assign a free port.
</Note>

## Configuration file

The main Apache configuration file is located at:

```
bin/apache/apacheX.X.X/conf/httpd.conf
```

Replace `apacheX.X.X` with the version you have installed (for example, `apache2.4.62`). Bearsampp rewrites parts of this file automatically when you change settings through the tray menu, so always use the tray menu for port and module changes rather than editing the file directly when possible.

## Tray menu options

Right-click the Bearsampp icon in the system tray, then select **Apache** to access the following options:

<CardGroup cols={2}>
  <Card title="Start / Stop / Restart service" icon="power-off">
    Control the Apache Windows service without restarting all of Bearsampp.
  </Card>

  <Card title="Change port" icon="network-wired">
    Switch Apache to a different HTTP port. Bearsampp updates `httpd.conf` and restarts the service.
  </Card>

  <Card title="Access logs" icon="file-lines">
    Open the Apache access log to see all incoming requests.
  </Card>

  <Card title="Error logs" icon="triangle-exclamation">
    Open the Apache error log to diagnose startup failures and runtime errors.
  </Card>

  <Card title="Edit conf" icon="pen-to-square">
    Open `httpd.conf` in your default text editor.
  </Card>

  <Card title="Check port" icon="circle-check">
    Verify whether the configured HTTP port is free or already in use.
  </Card>

  <Card title="Generate SSL certificate" icon="lock">
    Create a self-signed SSL certificate for local HTTPS development.
  </Card>

  <Card title="Add virtual host" icon="globe">
    Create a new Apache virtual host for a custom local domain.
  </Card>

  <Card title="Add alias" icon="link">
    Map a URL path (for example, `/myapp`) to a folder anywhere on your machine.
  </Card>
</CardGroup>

## Enabling and disabling Apache modules

Apache ships with many optional modules — `mod_rewrite`, `mod_headers`, `mod_ssl`, and more. You can toggle individual modules on or off without editing `httpd.conf` by hand:

<Steps>
  <Step title="Open the Apache modules menu">
    Right-click the tray icon → **Apache** → **Modules**.
  </Step>

  <Step title="Toggle a module">
    Click a module name to enable or disable it. A checkmark indicates the module is currently active.
  </Step>

  <Step title="Restart Apache">
    Bearsampp restarts the Apache service automatically so the change takes effect immediately.
  </Step>
</Steps>

## Switching Apache versions

Bearsampp supports multiple Apache versions. To switch:

<Steps>
  <Step title="Open the versions menu">
    Right-click the tray icon → **Apache** → **Versions**.
  </Step>

  <Step title="Select a version">
    Click the version you want. Bearsampp stops the current Apache service, updates configuration, and starts the new version.
  </Step>
</Steps>

<Warning>
  Not every Apache version is compatible with every PHP version. If you see a compatibility warning after switching, check that your active PHP version supports the Apache version you selected.
</Warning>

## SSL / HTTPS

To use HTTPS locally, generate a self-signed certificate from the tray menu (**Apache** → **Generate SSL certificate**). Your browser will show a security warning for self-signed certificates — you can safely accept it for local development. The SSL configuration lives in:

```
bin/apache/apacheX.X.X/conf/extra/httpd-ssl.conf
```

## Virtual hosts and aliases

* **Virtual hosts** let you access projects at a custom domain like `myproject.local` instead of `http://localhost/myproject`. Add them via **Apache** → **Add a virtual host**.
* **Aliases** map a URL path to any folder on your machine. Add them via **Apache** → **Add an alias**.

<Tip>
  After adding a virtual host, use the **HostsEditor** tool (tray → Tools → HostsEditor) to add the domain to your Windows `hosts` file so your browser can resolve it.
</Tip>

## Service details

| Property     | Value                                    |
| ------------ | ---------------------------------------- |
| Service name | `bearsamppapache`                        |
| Start mode   | Automatic (on Bearsampp launch)          |
| Config file  | `bin/apache/apacheX.X.X/conf/httpd.conf` |
