Veebiserver labor 2: Difference between revisions
Line 327: | Line 327: | ||
<pre> | <pre> | ||
NameVirtualHost *:443 | NameVirtualHost *:443 | ||
SSLStrictSNIVHostCheck | SSLStrictSNIVHostCheck off | ||
<VirtualHost *:443> | <VirtualHost *:443> | ||
ServerAdmin webmaster@localhost | ServerAdmin webmaster@localhost | ||
ServerName www. | ServerName www.album.ee | ||
DocumentRoot /var/www/www | DocumentRoot /var/www/www | ||
<Directory /> | <Directory /> | ||
Line 370: | Line 370: | ||
</Directory> | </Directory> | ||
ErrorLog /var/log/apache2/www. | ErrorLog /var/log/apache2/www.album.ee-ssl-error.log | ||
TransferLog /var/log/apache2/www. | TransferLog /var/log/apache2/www.album.ee-ssl-access.log | ||
SSLEngine on | SSLEngine on | ||
SSLCertificateFile /etc/apache2/www. | SSLCertificateFile /etc/apache2/www.album.ee.crt | ||
SSLCertificateKeyFile /etc/apache2/www. | SSLCertificateKeyFile /etc/apache2/www.album.ee.key | ||
SSLOptions +StdEnvVars | SSLOptions +StdEnvVars | ||
</VirtualHost> | </VirtualHost> | ||
<VirtualHost *:443> | <VirtualHost *:443> | ||
ServerAdmin webmaster@localhost | ServerAdmin webmaster@localhost | ||
ServerName | ServerName photo.album.ee | ||
DocumentRoot /var/www/ | DocumentRoot /var/www/photo | ||
<Directory /> | <Directory /> | ||
Options FollowSymLinks | Options FollowSymLinks | ||
AllowOverride None | AllowOverride None | ||
</Directory> | </Directory> | ||
<Directory /var/www/ | <Directory /var/www/photo> | ||
Options Indexes FollowSymLinks MultiViews | Options Indexes FollowSymLinks MultiViews | ||
AllowOverride None | AllowOverride None | ||
Line 402: | Line 403: | ||
</Directory> | </Directory> | ||
ErrorLog /var/log/apache2/ | ErrorLog /var/log/apache2/photo.error.log | ||
# Possible values include: debug, info, notice, warn, error, crit, | # Possible values include: debug, info, notice, warn, error, crit, | ||
Line 408: | Line 409: | ||
LogLevel warn | LogLevel warn | ||
CustomLog /var/log/apache2/ | CustomLog /var/log/apache2/photo.access.log combined | ||
Alias /doc/ "/usr/share/doc/" | Alias /doc/ "/usr/share/doc/" | ||
Line 418: | Line 419: | ||
Allow from 127.0.0.0/255.0.0.0 ::1/128 | Allow from 127.0.0.0/255.0.0.0 ::1/128 | ||
</Directory> | </Directory> | ||
ErrorLog /var/log/apache2/ | ErrorLog /var/log/apache2/photo.album.ee-ssl-error.log | ||
TransferLog /var/log/apache2/ | TransferLog /var/log/apache2/photo.album.ee-ssl-access.log | ||
SSLEngine on | SSLEngine on | ||
SSLCertificateFile /etc/apache2/ | SSLCertificateFile /etc/apache2/photo.album.ee.crt | ||
SSLCertificateKeyFile /etc/apache2/ | SSLCertificateKeyFile /etc/apache2/photo.album.ee.key | ||
SSLOptions +StdEnvVars | SSLOptions +StdEnvVars | ||
</VirtualHost> | </VirtualHost> | ||
<VirtualHost *:80> | <VirtualHost *:80> | ||
ServerAdmin webmaster@localhost | |||
ServerName www.album.ee | |||
DocumentRoot /var/www/www | |||
<Directory /> | |||
Options FollowSymLinks | |||
AllowOverride None | |||
</Directory> | |||
<Directory /var/www/www> | |||
Options Indexes FollowSymLinks MultiViews | |||
AllowOverride None | |||
Order allow,deny | |||
allow from all | |||
</Directory> | |||
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ | |||
<Directory "/usr/lib/cgi-bin"> | |||
AllowOverride None | |||
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | |||
Order allow,deny | |||
Allow from all | |||
</Directory> | |||
ErrorLog /var/log/apache2/www-error.log | |||
# Possible values include: debug, info, notice, warn, error, crit, | |||
# alert, emerg. | |||
LogLevel warn | |||
CustomLog /var/log/apache2/www-access.log combined | |||
Alias /doc/ "/usr/share/doc/" | Alias /doc/ "/usr/share/doc/" | ||
<Directory "/usr/share/doc/"> | <Directory "/usr/share/doc/"> | ||
Options Indexes MultiViews FollowSymLinks | Options Indexes MultiViews FollowSymLinks | ||
AllowOverride None | AllowOverride None | ||
Order deny,allow | Order deny,allow | ||
Deny from all | Deny from all | ||
Allow from 127.0.0.0/255.0.0.0 ::1/128 | Allow from 127.0.0.0/255.0.0.0 ::1/128 | ||
</Directory> | </Directory> | ||
</VirtualHost> | </VirtualHost> | ||
Line 474: | Line 476: | ||
ServerAdmin webmaster@localhost | ServerAdmin webmaster@localhost | ||
ServerName | ServerName photo.album.ee | ||
DocumentRoot /var/www/ | DocumentRoot /var/www/photo | ||
<Directory /> | <Directory /> | ||
Options FollowSymLinks | Options FollowSymLinks | ||
AllowOverride None | AllowOverride None | ||
</Directory> | </Directory> | ||
<Directory /var/www/ | <Directory /var/www/photo> | ||
Options Indexes FollowSymLinks MultiViews | Options Indexes FollowSymLinks MultiViews | ||
AllowOverride None | AllowOverride None | ||
Order allow,deny | Order allow,deny | ||
allow from all | allow from all | ||
</Directory> | </Directory> | ||
Line 491: | Line 493: | ||
AllowOverride None | AllowOverride None | ||
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch | ||
Order allow,deny | Order allow,deny | ||
Allow from all | Allow from all | ||
</Directory> | </Directory> | ||
ErrorLog /var/log/apache2/ | ErrorLog /var/log/apache2/photo.error.log | ||
# Possible values include: debug, info, notice, warn, error, crit, | # Possible values include: debug, info, notice, warn, error, crit, | ||
# alert, emerg. | # alert, emerg. | ||
LogLevel warn | LogLevel warn | ||
CustomLog /var/log/apache2/ | CustomLog /var/log/apache2/photo.access.log combined | ||
Alias /doc/ "/usr/share/doc/" | Alias /doc/ "/usr/share/doc/" | ||
<Directory "/usr/share/doc/"> | <Directory "/usr/share/doc/"> | ||
Options Indexes MultiViews FollowSymLinks | Options Indexes MultiViews FollowSymLinks | ||
AllowOverride None | AllowOverride None | ||
Order deny,allow | Order deny,allow | ||
Deny from all | Deny from all | ||
Allow from 127.0.0.0/255.0.0.0 ::1/128 | Allow from 127.0.0.0/255.0.0.0 ::1/128 | ||
</Directory> | </Directory> | ||
</VirtualHost> | </VirtualHost> | ||
</pre> | </pre> |
Revision as of 15:01, 7 December 2009
Autorid
- Niina Stsetnikova
- Viktoria Mulina
Sissejuhatus
Meil on vaja luua veebiserveri, ehk interneti püsiühendusega arvuti, milles hoitakse veebisaite:
- www.album.ee
- photo.album.ee
Eeldused
Ubuntu server 9.10
Apache 2.2.12
OpenSSL 0.9.8g
Nõuded
- Konfigureerida kaks veebilehte
- Mõlemal lehel peab olema võimalik kasutada php'd
- Konfigureerida mysql ja phpMyAdmin andmebaaside seadistamiseks
- Seadistada SSL
- Seadistada SNI
- Monitooring - valida millega monitoorida
Installeerimise ja konfigureerimise juhend
Logime ennast root kasutajaks:
sudo -i
Enne installerimist tasub uuendada tarkvara nimekirja:
apt-get update
Kuna nõudeks on uuem Ubuntu versioon siis on vaja meie oma uuendada
apt-get install update-manager apt-get install update-manager-core apt-get dist-upgrade do-release-upgrade
Veersiooni kontrollimiseks:
lsb-release
Testimiseks paigalda links veebisirvija
apt-get install links
Veebiserveri installeerimine
Kui on juba olemas Ubuntu server siis on vaja lihtsalt uuendada .conf failid, uus installeerimine ei ole tarvis.
Installeerimine apt abil:
apt-get install apache2
Teenuse taaskäivitamine:
/etc/init.d/apache2 restart
MySQL installeerimine
MySQL installeerimiseks tuleb sisestada Shelli käsk:
apt-get install mysql-server
Installeerimisel küsitakse MySQL root parooli määramist.
phpMyAdmin installeerimine
Paigaldamine
apt-get install phpmyadmin
Installeerimise käigus palutakse valida:
1) veebiserver, millele phpMyAdmin paigalda - vali apache2
2) administraatori parool
3) kas paigaldada vaikimisi seadistusega andmebaas - yes
Seadistamine
Muudame Apache konfiguratsioonifaili /etc/apache2/apache2.conf
nano /etc/apache2/apache2.conf
Lisa sinna rida:
Include /etc/phpmyadmin/apache.conf
Apache teenus tuleb taaskäivitada:
/etc/init.d/apache2 restart
Kontroll
Kontrollida saab käsureaga:
links http://masinanimi_või_IP/phpmyadmin
Alternatiivne seadistamine
Include lause lisamise asemel võib lihtsalt linkida phpmyadmin konfiguratsioonifaili Apache seadistuste kataloogi:
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
Nimelahenduse loomine
1) Uurida välja oma masina IP käsuga
ifconfig
2) Muuta 'hosts' faili käsuga
nano /etc/hosts
3) Lisada read
<MasinaIP> www.album.ee <MasinaIP> photo.album.ee
4) Testimiseks pingida www.album.ee ja photo.album.ee Kui ping vastab, on nimelahendus õigesti seadistatud
Nimepõhiste virtuaalserverite loomine
- Loo kataloogid www ja photo /var/www kausta.
mkdir -p /var/www/www /var/www/photo
- Kopeeri /etc/apache2/sites-available kaustas oleva default konfiguratsiooni faili ning loo koopiad www ja photo nimedega.
cp /etc/apache2/sites-available/default /etc/apache2/sites-available/photo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/www
- Ava photo konfiguratsiooni faili nanoga.
nano /etc/apache2/sites-available/photo
- Muudetud photo fail peaks välja nägema selline :
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName photo.album.ee DocumentRoot /var/www/photo <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/photo> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/photo.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/photo.access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
- Ava www konfiguratsiooni faili nanoga.
nano /etc/apache2/sites-available/www
- Muudetud www fail peaks välja nägema selline :
<VirtualHost *:80> ServerAdmin webmaster@localhost ServerName www.album.ee DocumentRoot /var/www/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/www> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/www.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/www.access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
- photo ja www virtualhostide kasutamiseks tuleb keelata default lehekülg ja lubada photo ning www, sisestades käsurealt järgmised käsud:
a2ensite photo a2ensite www a2dissite default /etc/init.d/apache2 reload
- Testimine
Testimiseks tuleb luua index.html fail nii www kui ka photo kataloogi. Selleks tegutse järgmiselt:
1. Loo fail www kataloogi
nano /var/www/www/index.html
1.1 Kirjuta faili
<h1>Tere tulemast www.album.ee veebilehele!</h1>
2. Loo fail photo kataloogi
nano /var/www/photo/index.html
2.1 Kirjuta faili
<h1>Siin saab fotod vaadata</h1>
- Kontrollimiseks mine veebilehitsejaga järgmistele aadressidele:
links www.album.ee links photo.album.ee
Kui ei tööta siis kontrollige, et kõik failid oleks korralikult muudetud. Võib olla veebilehe nimi on juba olemas, selle kontrollimiseks vaadake mis IP aadressile läheb signaal:
ping www.album.ee
kui IP on teie arvuti oma, siis viga ei ole selles!
phpinfo lehe loomine
Loo fail
nano /var/www/www/phpinfo.php
Kirjuta faili
<?php phpinfo(); ?>
Kontrollimiseks mine veebilehitsejaga aadressile
links http://www.album.ee/phpinfo.php
Peaks nägema standartset phpinfo lehte.
SSL keskkonna loomine
Sertifikaadi genereerimine
Kõigepealt liikuda kataloogi /etc/apache2/ ja siis genereerida www.album.ee võtmed
cd /etc/apache2/
Käivitada seal käsk:
openssl req -nodes -new -keyout www.album.ee.key -newkey rsa:1024 > www.album.ee.csr
Küsimustele vastata nii nagu allpool näidatud.
Country Name (2 letter code) [AU]:EE State or Province Name (full name) [Some-State]:Tallinn Locality Name (eg, city) []:Tallinn Organization Name (eg, company) [Internet Widgits Pty Ltd]:Album Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:www.album.ee Email Address []: A challenge password []: An optional company name []:
Käivitada need käsud
openssl x509 -req -days 3650 -in www.album.ee.csr -signkey www.album.ee.key -out www.album.ee.crt
openssl x509 -in www.album.ee.crt -noout -text
Nüüd genereerime photo.album.ee võtmed
cd /etc/apache2/
Käivitada seal käsk:
openssl req -nodes -new -keyout photo.album.ee.key -newkey rsa:1024 > photo.album.ee.csr
Küsimustele vastata nii nagu allpool näidatud.
Country Name (2 letter code) [AU]:EE State or Province Name (full name) [Some-State]:Tallinn Locality Name (eg, city) []:Tallinn Organization Name (eg, company) [Internet Widgits Pty Ltd]:Album Organizational Unit Name (eg, section) []: Common Name (eg, YOUR name) []:photo.album.ee Email Address []: A challenge password []: An optional company name []:
Käivitada need käsud
openssl x509 -req -days 3650 -in photo.album.ee.csr -signkey photo.album.ee.key -out photo.album.ee.crt
openssl x509 -in photo.album.ee.crt -noout -text
SNI Seadistamine
Kasutades Server Name Indication, ehk SNI, saab ühe IP ja pordi pealt suunata päringuid erinevatele https veebilehtedele.
Tekitame uue faili nimega 000-default, kataloogis /etc/apache2/sites-enabled/ :
nano /etc/apache2/sites-enabled/000-default
Konfiguratsioonifaili sisuks on:
NameVirtualHost *:443 SSLStrictSNIVHostCheck off <VirtualHost *:443> ServerAdmin webmaster@localhost ServerName www.album.ee DocumentRoot /var/www/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/www> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/www.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/www.access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ErrorLog /var/log/apache2/www.album.ee-ssl-error.log TransferLog /var/log/apache2/www.album.ee-ssl-access.log SSLEngine on SSLCertificateFile /etc/apache2/www.album.ee.crt SSLCertificateKeyFile /etc/apache2/www.album.ee.key SSLOptions +StdEnvVars </VirtualHost> <VirtualHost *:443> ServerAdmin webmaster@localhost ServerName photo.album.ee DocumentRoot /var/www/photo <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/photo> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/photo.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/photo.access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> ErrorLog /var/log/apache2/photo.album.ee-ssl-error.log TransferLog /var/log/apache2/photo.album.ee-ssl-access.log SSLEngine on SSLCertificateFile /etc/apache2/photo.album.ee.crt SSLCertificateKeyFile /etc/apache2/photo.album.ee.key SSLOptions +StdEnvVars </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName www.album.ee DocumentRoot /var/www/www <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/www> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/www-error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/www-access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost> <VirtualHost *:80> ServerAdmin webmaster@localhost ServerName photo.album.ee DocumentRoot /var/www/photo <Directory /> Options FollowSymLinks AllowOverride None </Directory> <Directory /var/www/photo> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory> ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all </Directory> ErrorLog /var/log/apache2/photo.error.log # Possible values include: debug, info, notice, warn, error, crit, # alert, emerg. LogLevel warn CustomLog /var/log/apache2/photo.access.log combined Alias /doc/ "/usr/share/doc/" <Directory "/usr/share/doc/"> Options Indexes MultiViews FollowSymLinks AllowOverride None Order deny,allow Deny from all Allow from 127.0.0.0/255.0.0.0 ::1/128 </Directory> </VirtualHost>
NameVirtualHost *:443 - määrab, et kõigil IP'del kuulatakse virtual host päringuid
SSLStrictSNIVHostCheck - määrab, kas ühendusi lubatakse ka mitte-SNI klientidelt (off = lubatakse, on = ei lubata)