# Apache

[Digital Ocean tutorial for Virtual Hosts](https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-18-04).

Enable site:`sudo a2ensite SITENAME`

Disable site:`sudo a2dissite SITENAME`

List apache modules:`apache2ctl -M`

Enable an apache2 module:`sudo a2enmod MODULENAME`

Disable an apache2 module:`sudo a2dismod MODULENAME`

Enable mod rewrite: `sudo a2enmod rewrite`

Reload server:`service apache2 reload`

Force reload the server:`sudo /etc/init.d/apache2 force-reload`

Apache file permissions:

```
chown -R www-data:www-data /folder/
chmod +r /folder
```

Virtual hosts directory: `/etc/apache2/sites-available/`

Virtual Host sample file:

```
<VirtualHost *:80>
  DocumentRoot /var/www/site
  ServerName site.example.com
  CustomLog /var/www/logs/site/access.log combined
  ErrorLog /var/www/logs/site/error.log
</VirtualHost>
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://kb.chrisltd.com/cheat-sheets/apache.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
