feat: add doc/apache-vh.md

This commit is contained in:
dancingCycle 2024-02-22 17:20:05 +01:00
parent afafc63323
commit e12c5fa6b6
2 changed files with 76 additions and 0 deletions

74
doc/apache-vh.md Normal file
View File

@ -0,0 +1,74 @@
# Source
[setting up VH](https://www.digitalocean.com/community/tutorials/how-to-install-the-apache-web-server-on-debian-11#step-5-setting-up-virtual-hosts-recommended)
# Setup
* create directory for our domain
```
sudo mkdir -p /var/www/vm2037.swingbe.mooo.com
```
* assign ownership of the directory to the user youre currently signed in as with the `$USER` environment variable
```
sudo chown -R $USER:$USER /var/www/vm2037.swingbe.mooo.com
```
* ensure that your permissions are correct and allow the owner to read, write, and execute the files while granting only read and execute permissions to groups and others, you can input the following command
```
sudo chmod -R 755 /var/www/vm2037.swingbe.mooo.com
```
* create a sample index.html page with this instruction
```
vi /var/www/vm2037.swingbe.mooo.com/index.html
```
* and enter this content
```
<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1>Success! The virtual host is working!</h1>
</body>
</html>
```
* create a new virtual host file with the correct directives
```
sudo vi /etc/apache2/sites-available/vm2037.swingbe.mooo.com.conf
```
* and enter this content
```
<VirtualHost *:80>
ServerAdmin admin@swingbe.de
ServerName vm2037.swingbe.mooo.com
ServerAlias www.vm2037.swingbe.mooo.com
DocumentRoot /var/www/vm2037.swingbe.mooo.com
ErrorLog ${APACHE_LOG_DIR}/vm2037.swingbe.mooo.com.error.log
CustomLog ${APACHE_LOG_DIR}/vm2037.swingbe.mooo.com.access.log combined
</VirtualHost>
```
* enable the file with the a2ensite tool
```
sudo a2ensite vm2037.swingbe.mooo.com.conf
```
* disable the default site
```
sudo a2dissite 000-default.conf
```
* test for configuration errors
```
sudo apache2ctl configtest
```
* restart Apache to implement your changes
```
sudo systemctl restart apache2
```

View File

@ -37,3 +37,5 @@ http://<server ip>
* OPTION: enable web service proxy modules like [this](./apache-proxy.md)
* OPTION: enable SSL like [this](./apache-ssl.md)
* OPTION: set up virtual host [this](./apache-vh.md)