> For the complete documentation index, see [llms.txt](https://kb.chrisltd.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://kb.chrisltd.com/cheat-sheets/apache.md).

# 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>
```
