(pubblicato il 28 settembre 2005)
Server Apache
Un altro programma servente HTTPD presente sia in ambiente Linux che Windows è rappresentato da Apache HTTP Server (scaricabile dal sito www.apache.org)
Durante l'installazione del programma (sotto ambiente windows) è possibile scegliere la tipologia di avvio da adottare. Se siete in ambiente win98 oppure non volete che il server non si avvii come servizio windows è opportuno selezionare l'avvio manuale come in figura.
Qui sotto in figura l'elenco dei servizi attivati su un windows server 2000. tale elenco è richiamabile tramite il pannello di controllo
La cartella di destinazione rappresenta la cartella dove verrà salvato l'applicativo
Avvio del server httpd Apache
Se si è selezionato l'avvio manuale allora basta, partendo dal menu avvio, lanciare Apache come in figura
Dopo l'avvio si apre una finestra dos
Aprendo il browser e digitando l'indirizzo IP della vostra macchina se tutto è OK dovrebbe apparire la Home Page di default proposta da Apache
Parametri di configurazione relativi al server APACHE
Il server Apache ha come file di configurazione il file httpd.conf - Si tratta di un file di testo editabile mediante il mitico block notes. La modifica di questo file può essere richiamata utilizzando lo stesso menu avvio utilizzato per avviare il programma Apache. All'interno di questo file si evidenziano le seguenti sezioni:
Porta di ascolto ed indirizzo IP utilizzati per il servizio httpd
#
# ServerName
allows
you
to
set a host
name
which
is
sent
back to
clients
for
# your
server if
it's
different
than
the one the program would
get
(i.e.,
use
# "www" instead
of the host's
real
name).
#
# Note: You
cannot
just invent
host
names
and hope
they
work. The name
you
# define
here
must
be
a valid
DNS
name
for
your
host.
If
you
don't
understand
# this,
ask
your
network administrator.
# If
your
host
doesn't
have
a registered
DNS
name,
enter
its
IP address
here.
# You
will
have
to
access it
by
its
address
(e.g.,
http://123.45.67.89/)
# anyway,
and this
will
make
redirections
work in a sensible
way.
#
# 127.0.0.1 is
the TCP/IP
local
loop-back
address,
often
named
localhost.
Your
# machine
always
knows
itself
by
this
address.
If
you
use
Apache strictly
for
# local
testing
and development,
you
may
use
127.0.0.1 as
the server name.
#
ServerName
192.168.1.68
#
# Port: The port to which the standalone server listens. Certain firewall
# products must be configured before Apache can listen to a specific port.
# Other running httpd servers will also interfere with this port. Disable
# all firewall, security, and other services if you encounter problems.
# To help diagnose problems use the Windows NT command NETSTAT -a
#
Port 8081
Se la porta è definita come si vede qui sopra allora per accedere alla home page devo digitare http://192.168.1.68:8081/ dove 192.168.1.68 rappresenta l'indirizzo IP del mio computer
Cartella dei documenti erogati (document root)
La cartella contenente i documenti che vengono erogati dal server httpd (si può dire anche server web)
#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "E:/Programmi/Apache
Group/Apache/htdocs"
Documento predefinito
Sempre nel file di configurazione è possibile inserire il nome del documento predefinito (ovvero quello che viene caricato quando sulla barra degli indirizzi digito solo il percorso di una cartella presente sul web server)
#
# DirectoryIndex: Name of the file or files to use as a pre-written HTML
# directory index. Separate multiple entries with spaces.
#
<IfModule mod_dir.c>
DirectoryIndex index.html
</IfModule>
Pagine di errore personalizzate
E possibile, come in IIS, personalizzare anche i messaggi di errore
#
# Customizable
error response
(Apache style)
# these
come in three
flavors
#
# 1) plain
text
#ErrorDocument
500 "The server made
a boo
boo.
# n.b. the single leading
(") marks
it
as
text,
it
does
not
get
output
#
# 2) local
redirects
ErrorDocument 404 /missing.html
# to
redirect
to
local
URL
/missing.html
#ErrorDocument
404 /cgi-bin/missing_handler.pl
# N.B.:
You
can redirect
to
a script or a document
using
server-side-includes.
#
# 3) external
redirects
#ErrorDocument
402 http://www.example.com/subscription_info.html
# N.B.:
Many
of the environment
variables
associated
with
the original
# request
will
*not*
be
available
to
such
a script.