# Web

## Structure

```
.
├── apache
    ├── www.delmar.bzh       (80)  > hugo
    ├── nsns.delmar.bzh      (81)  > hugo
    ├── ugo.delmar.bzh       (82)  > wordpress
    ├── dav.delmar.bzh       (83)  > baïkal
	├── julien.delmar.bzh    (84)  > hugo
	├── nds.delmar.bzh       (85)  > hugo
	├── shop.delmar.bzh      (86)  > prestashop
  	├── kontadenn.delmar.bzh (87)  > joomla
  	├── _____.delmar.bzh     (88)  > 
    └── _____.delmar.bzh     (89)  > 
```

```bash
sudo vim /etc/apache2/ports.conf
```

```conf
# If you just change the port or add more ports here, you will likely also
# have to change the VirtualHost statement in
# /etc/apache2/sites-enabled/000-default.conf

Listen 80
Listen 81
Listen 82
Listen 83
Listen 84
Listen 85
Listen 86
Listen 87
Listen 88
Listen 89

<IfModule ssl_module>
        Listen 443
</IfModule>

<IfModule mod_gnutls.c>
        Listen 443
</IfModule>
```

```bash
sudo vim /etc/apache2/sites-available/delmar.bzh.conf
```

```conf
<VirtualHost *:80>
        ServerName www.delmar.bzh

        ServerAdmin admin@delmar.bzh
        DocumentRoot /var/www/hugo

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:81>
        ServerName nsns.delmar.bzh

        ServerAdmin admin@delmar.bzh
        DocumentRoot /var/www/nsns

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:82>
        ServerName ugo.delmar.bzh

        ServerAdmin ugo@delmar.bzh
        DocumentRoot /var/www/wpugo

        <Directory /var/www/wpugo> 
                Options Indexes FollowSymLinks
                AllowOverride None 
                Order allow,deny 
                allow from all 

                RewriteEngine On
                RewriteBase /
                RewriteRule ^index\.php$ - [L]
                RewriteCond %{REQUEST_FILENAME} !-f
                RewriteCond %{REQUEST_FILENAME} !-d
                RewriteRule . /index.php [L]
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

DavLockDB /usr/local/apache/var/DavLock

<VirtualHost *:83>
        ServerAdmin admin@delmar.bzh
        DocumentRoot /var/www/baikal/html
        ServerName dav.delmar.bzh

        RewriteEngine on
        RewriteRule /.well-known/carddav /dav.php [R=308,L]
        RewriteRule /.well-known/caldav  /dav.php [R=308,L]

        <Directory "/var/www/baikal/html">
                Options None
                # If you install cloning git repository, you may need the following
                # Options +FollowSymlinks
                AllowOverride None
                # Configuration for apache-2.4:
                Require all granted
                # Configuration for apache-2.2:
                # Order allow,deny
                # Allow from all
        </Directory>

        Alias /webdav /var/www/webdav

        <Directory /var/www/webdav>
                DAV On
                AuthType Basic
                AuthName "webdav"
                AuthUserFile /usr/local/apache/var/users.password
                Require user admin
        </Directory>

        <Directory /var/www/webdav/shared>
                Options Indexes
                AllowOverride none
                Order allow,deny
                allow from all
                DAV On
                AuthType Basic
                AuthName "webdav"
                AuthUserFile /usr/local/apache/var/users.password
                <Limit GET POST PROPFIND PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                        Require valid-user
                </Limit>
        </Directory>

        <Directory /var/www/webdav/julien>
                Options Indexes
                AllowOverride none
                Order allow,deny
                allow from all
                DAV on
                AuthType Basic
                AuthName "webdav"
                AuthUserFile /usr/local/apache/var/users.password
                <Limit GET POST PROPFIND PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                        Require user julien
                </Limit>
        </Directory>

        <Directory /var/www/webdav/eliot>
                Options Indexes
                AllowOverride none
                Order allow,deny
                allow from all
                DAV on
                AuthType Basic
                AuthName "webdav"
                AuthUserFile /usr/local/apache/var/users.password
                <Limit GET POST PROPFIND PUT DELETE PROPPATCH MKCOL COPY MOVE LOCK UNLOCK>
                        Require user eliot
                </Limit>
        </Directory>

        <IfModule mod_expires.c>
                ExpiresActive Off
        </IfModule>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:84>
        ServerName julien.delmar.bzh

        ServerAdmin admin@delmar.bzh
        DocumentRoot /var/www/resumes/julien

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:85>  
        ServerName nds.delmar.bzh  

        ServerAdmin admin@delmar.bzh  
        DocumentRoot /var/www/nds  

        ErrorLog ${APACHE_LOG_DIR}/error.log  
        CustomLog ${APACHE_LOG_DIR}/access.log combined  
</VirtualHost>

<VirtualHost *:86>
        ServerName shop.delmar.bzh

        ServerAdmin admin@delmar.bzh  
        DocumentRoot /var/www/shop

        <Directory /var/www/shop> 
                Options Indexes FollowSymLinks
                AllowOverride None 
                Order allow,deny 
                allow from all 

                RewriteEngine on
                #Domain: shop.delmar.bzh
                RewriteRule . - [E=REWRITEBASE:/]
                RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
                RewriteRule ^upload/.+$ %{ENV:REWRITEBASE}index.php [QSA,L]
                # Images
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$1$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$1$4 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$1$5 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$1$6 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$1$7 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$1$8 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$8/$1$9 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([\d]+)(\-[\.*\w-]*)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([a-zA-Z_-]+)(-[\d]+)?/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                # AlphaImageLoader for IE and fancybox
                RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ %{ENV:REWRITEBASE}js/jquery/plugins/fancybox/images/$1.$2 [L]
                # Dispatcher
                RewriteCond %{REQUEST_FILENAME} -s [OR]
                RewriteCond %{REQUEST_FILENAME} -l [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^.*$ - [NC,L]
                RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

<VirtualHost *:87>
        ServerName kontadenn.delmar.bzh

        ServerAdmin admin@delmar.bzh
        DocumentRoot /var/www/kontadenn

        <Directory /var/www/kontadenn>
                Options Indexes FollowSymLinks
                AllowOverride None 
                Order allow,deny 
                allow from all 

                RewriteEngine on
                #Domain: kontadenn.delmar.bzh
                RewriteRule . - [E=REWRITEBASE:/]
                RewriteRule ^api(?:/(.*))?$ %{ENV:REWRITEBASE}webservice/dispatcher.php?url=$1 [QSA,L]
                RewriteRule ^upload/.+$ %{ENV:REWRITEBASE}index.php [QSA,L]
                # Images
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$1$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$1$4 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$1$5 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$1$6 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$1$7 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$1$8 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^(([\d])([\d])([\d])([\d])([\d])([\d])([\d])(?:\-[\w-]*)?)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/p/$2/$3/$4/$5/$6/$7/$8/$1$9 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([\d]+)(\-[\.*\w-]*)/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                RewriteCond %{HTTP_HOST} ^shop.delmar.bzh$
                RewriteRule ^c/([a-zA-Z_-]+)(-[\d]+)?/.+(\.(?:jpe?g|webp|png|avif))$ %{ENV:REWRITEBASE}img/c/$1$2$3 [L]
                # AlphaImageLoader for IE and fancybox
                RewriteRule ^images_ie/?([^/]+)\.(jpe?g|png|gif)$ %{ENV:REWRITEBASE}js/jquery/plugins/fancybox/images/$1.$2 [L]
                # Dispatcher
                RewriteCond %{REQUEST_FILENAME} -s [OR]
                RewriteCond %{REQUEST_FILENAME} -l [OR]
                RewriteCond %{REQUEST_FILENAME} -d
                RewriteRule ^.*$ - [NC,L]
                RewriteRule ^.*$ %{ENV:REWRITEBASE}index.php [NC,L]
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
```

```bash
sudo systemctl restart apache2
```