Daemons and web servers
The Apache Software Foundation 2023: Apache HTTP Server Version 2.4 Documentation: Name-based Virtual Host Support [1]
Karvinen 2018: Name Based Virtual Hosts on Apache – Multiple Websites to Single IP Address [2]
HTTP Request Methods w3schools
[3]
$ sudo apt update
$ sudo apt install apache2 -y
$ curl -I localhost
kuva 1
curl -I localhost
kertoo lyhyesti tietoa sivusta, jos sivu on saatavilla HTTP/1 200 OK
, muutoin tilakoodi on esim 300
alkuinen tai 400
, 500
alkuiset kertoo myös virheestä. Komento välittää myös tietoa palvelinohjelmasta Server
, sivuston koosta Content-Length
ja sisällön tyypistä Content-Type
.
200 OK
Ma 6.1.2025
Apache
Ma 6.1.2025
10701
tavuaStatus Codes Wikipedia
Wikipedia [5]
1xx informational response – the request was received, continuing process
2xx successful – the request was successfully received, understood, and accepted
3xx redirection – further action needs to be taken in order to complete the request
4xx client error – the request contains bad syntax or cannot be fulfilled
5xx server error – the server failed to fulfil an apparently valid request
[5]
kuva 2
$ sudo tail /var/log/apache2/access.log
Rivi 1
curl localhost
näyttää koko sivun terminaalissa. GET / HTTP/1.1
Huom. GET pyyntö
Rivit 2-4
Näyttää komennon curl -I localhost
yhteydenotot. Näet HEAD / HTTP/1.1
Eli tässä yhteydessä haetaan vain otsake. Esimerkki tulosteesta kuvassa 1.
GET
ja HEAD
ero näkyy myös tulostuksen koossa. GET
tuotti 10958 tavun kokoisen tulostuksen, ja HEAD
tuotti vain 257 tavuisen tulostuksen
$ sudo tail /var/log/apache2/error.log
Näyttää lokitietoja, ensimmäinen rivi kertoo Apachen konfiguraatiosta ja jatkaa normaalia toimintaa.
Toinen rivi näyttää koodia AH00094
, joka kertoo että Apache on käynnistetty/alustettu/initialized
/var/www/html/index.html
on mihin Apachen oletussivu sijoitetaan asennuksessa.
Tehdään kansio hattu-.example.com
käyttäjän hakemistoon. Muutetaan samalla tiedoston lukuoikeuksia, niin että kansioon pääsee ilman sudo
a.
$ chmod 755 hattu.example.com/index.html
index.html
sisältö
Apachen konfiguraatiotiedosto. “DocumentRoot directive to show where in the filesystem the content for that host lives.” Using Name-based Virtual Hosts [6]
Sivusto selaimella