Condivisione cartella tramite Apache

Per condividere una cartella tramite Apache2 Webserver abilitare il seguente modulo:

a2enmod autoindex

quindi editare il seguente file:

nano /etc/apache2/mods-enabled/alias.conf

e aggiungere la cartella con la sintassi:

Alias "/nomecartella" "/percorso/cartella"

        Options Indexes FollowSymLinks
        AllowOverride None
        Order allow,deny
        Allow from all

prestando attenzione di rimanere all’interno del tag IfModule.
Riavviare apache2 con:

/etc/init.d/apache2 restart

A questo punto la cartella sarà visibile all’indirizzo:

http://192.168.x.x/nomecartella

Opzionalmente è possibile creare un file /var/www/index.hml contenente:

<html>
<head>
<meta HTTP-EQUIV="REFRESH" content="0; url=/nomecartella">
</head>
</html>

per avere un reindirizzamento automatico alla cartella.

In caso di voglia cambiare l’aspetto del sito è possibile specificare nel file /etc/apache2/mods-enabled/autoindex.conf i seguenti paraametri:

IndexOptions FancyIndexing VersionSort SuppressDescription FoldersFirst XHTML HTMLTable NameWidth=* IgnoreCase SuppressRules IconHeight=50 IconWidth=50
IndexStyleSheet "/style.css"
HeaderName "/header.html"
ReadmeName "/footer.html"

Il contenuto dei suddetti file potrebbe essere ad esempio il seguente:
Il file /var/www/style.css

html {
        margin: 0;
        padding: 0;
        background:#000000
}

body {
        font-family: sans;
        font-size: 200%;
        color: #FFFFFF;
}

h1 {
        text-align:center;
        background: #89aed6;
        padding: 10px;
}

table {
        width: 95%;
        margin: 10px auto;
        text-align: left;
}

a:link {
        color:#FFFFFF;
}

a:visited {
        color:#808080;
}

Il file /var/www/header.html

<html>
<head>
</head>
<body>
<h1>.: Index of Webserver :.</h1>

Il file /var/www/footer.html

</body>
</html>

Comments are closed.