Mainos / Advertisement:

Apache2

Kohteesta Taisto
Siirry navigaatioon Siirry hakuun
Tämä on käännetty versio sivusta Apache2, ja käännös on 43 % valmis.

Muut kielet:
English • ‎suomi

Apache is a free and open source HTTP server software (web server). You can also install Apache on Windows and it comes integrated with Mac OSX. Apache has for long been the most popular web server software worldwide, even the server this wiki uses runs on Apache. The servers of http://www.datatekniikka.fi use Nginx server software.

This manual is a general manual for the Apache2 server software. All of the content in this manual has been tested in Apache version 2.2. Apache version 2.4 article can be found here.

More information about Apache: Apache (server software)

Installation

This installation manual is made for Apache version 2.2 and Debian OS version 7.8

Debian / Ubuntu

Apache can be found on Debian installation DVD 1.

You can install Apache with the command:

 aptitude install apache2

You can test your web page by using a browser and navigating to http://ip_address_of_server. The page should look like this:

 It works!
 This is the default web page for this server.
 The web server software is running but no content has been added, yet.

The default web page directory of Apache is located in:

 /var/www/

The configuration directory of Apache is found in:

 /etc/apache2

Default web page settings can be found here:

 nano /etc/apache2/sites-enabled/default

You can also use Php5 and Mysql with Apache.

Red Hat / CentOS / Fedora

Install Apache2 with the command:

 yum install httpd

Start up Apache2

 service httpd start

More information for CentOS: https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6

Configuration

From the Apache configuration directory

Debian / Ubuntu:

 cd /etc/apache2/

you can find the following files and directories:

 apache2.conf  envvars     magic            mods-enabled/  sites-available/
 conf.d/       httpd.conf  mods-available/  ports.conf     sites-enabled/

apache2.conf is the main configuration file. In this file you can make all the Apache definitions, even though it is recommended to use separate files for clarity.

ports.conf In here you define the ports and virtual hosts reply to requests.

conf.d In this directory there are different definitions for Apache. In this directory there is also the charcet file which allows you to enable UTF-8 character encoding.

sites-available/ In this directory there are all the definition files for virtual host assemblies.

sites-enabled/ In this directory you define what virtual hosts will be used.

mods-available/ Module definitions.

mods-enabled/ Modules that are in use.

Red Hat / CentOS / Fedora:

 /etc/httpd/

Apaches own configuration file can be found in the CentOS operating system under the path:

 /etc/httpd/conf/httpd.conf


apache2.conf

 nano /etc/apache2/apache2.conf

Parameters in the file:

Timeout By default this is 300 seconds. This tells you how long the server will answer a request. It is recommended to lower it to 60, since most servers can't answer 300s requests.

KeepAlive If this is set to "On", it enables the fulfillment of multiple requests. If set to "Off" then all requests will be handled separately, which can increase the server load.

MaxKeepAliveRequests This throttles the simultaneous amount of requests. You should keep this as high as you can due to server load. If it is set to "0", then the server will allow unlimited simultaneous requests.

KeepAliveTimeout Timeout for requests. If a request persists over the timeout, the connection will be severed.

sites-available/ (Virtual Host)

In this directory there should by default be "default", and now we create another virtual host. Below is an example of a virtual host. Save it for example by the name "intra".

<VirtualHost *:80>                            #*.80 = Responds to all IP-addresses in port 80
       ServerAdmin webmaster@localhost        #E-mail address of the server administrator
       ServerName example.com                 #Server name or network address (You can use IPv4- and IPv6-addresses)
       ServerAlias www.example.com            #Sub domain, you can have several of these (You can use IPv4- and IPv6-addresses)
       DocumentRoot /var/www                  #Main directory where the webpages are located
       <Directory />
               Options FollowSymLinks
               AllowOverride None             #Allows overriding the configurations (.htaccess) in the root directory (not recommended)
       </Directory>
       <Directory /var/www/>
               Options Indexes FollowSymLinks MultiViews
               AllowOverride None             #Allows overriding the configurations (.htaccess)
               Order allow,deny               #Allow, deny others
               allow from all                 #Allow everything to form in your web page
       </Directory>
</VirtualHost>

By default the virtual host answers all requests in port 80, the default HTTP port. When you want to create another virtual host, edit this file (physical path and ServerName) and save it with another name.

After this you enable the site (Enabled sites are found in the /etc/apache2/sites-enabled/ directory):

 a2ensite page_name

a2ensite [file name which is in /etc/apache2/sites-available] which you want to enable.

For example:

 a2ensite intra

After this we need to make apache read the settings files again:

 service apache2 reload

After this, add the following to your ports.conf file if you didn't use port 80 (HTTP default port):

 NameVirtualHost hostname:port

More information:

Disabling a site:

 a2dissite page_name

The name of the page is the same as in /etc/apache2/sites-available/[page_name]

 service apache2 reload

Virtual Directories

Virtual directories allow the Apache web directory to be fetched from a different location that where the root directory is

Alias /websubdirectory/ /path/
# Web side directory (/webdirectory) and physical path ("/path")
 <Directory "/path/">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   allow from all
</Directory>

For example:

 Alias /wwwtest /var/wwwtest/
 <Directory "/var/wwwtest/">
   Options Indexes FollowSymLinks MultiViews
   AllowOverride None
   Order allow,deny
   allow from all
 </Directory>

conf.d/charset

In this file you can define the Apache character encoding to be UTF-8.

1. Open the configuration file:

nano /etc/apache2/conf.d/charset

2. Remove the # character from:

 AddDefaultCharset UTF-8

3. Restart Apache

 service apache2 restart

Additional Modules

Extra features and added security for Apache.

The directory for additional modules in Apache:

 /etc/apache2/mods-available 

And the modules in this directory that are enabled:

 /etc/apache2/mods-enabled

Defining .htaccess or virtual host

 <IfModule mod_[moduulinnimi].c>
 ...
 # Define configurations here
 ..
 </IfModule>

mod_bw (mod_bandwidth)

With mod_bw (mod_bandwidth) you can limit the amount of bandwidths Apache uses, for instance when you need to download large files but don't want to strangle your network.

Installation

Install mod_bw from packet manager

 apt-get install libapache2-mod-bw

Enable mod-bw with the command

 a2enmod bw

Configuration

Enable module

  BandwidthModule On

Force module to be applied for all connection types

  ForceBandWidthModule On

Limit connection speed for all types to 10Mbps

  Bandwidth all 10000000

Remove limitation for the address 192.168.218.5 0

 BandWidth 192.168.218.5 0

Allow a maximum of 10 simultaneous connections

  MaxConnection all 10

Limit the download speed of all .avi files to 1000bps - 5Mbps

  LargeFileLimit .avi 1000 5000000

Example

  <Directory /var/www>
  Enable the module
  BandwidthModule On
  ForceBandWidthModule On
  Bandwidth all 10000000
  BandWidth 192.168.218.5 0
  MaxConnection all 10
  LargeFileLimit .avi 1000 5000000
  </Directory>

mod_dir

This feature decides the default website file that is displayed as the "front page". Usually it is called index.html, index.php or index.htm .

The feature is enabled by default and is modifiable.

 /etc/apache2/mod-available/dir.conf

By default, the file looks like this:

 <IfModule mod_dir.c>

         DirectoryIndex index.html index.cgi index.pl index.php index.xhtml index.htm

 </IfModule>

mod_evansive

This Apache addon prevents DDOS (Distributed denial-of-service) attacks that could be made against your web server. It is recommended to install this. It restricts the loading of your webpages in the following manner:

  • Prevents requesting the same page more than a couple of times withing one second
  • Prevents over 50 simultanous requests to the same device within a second
  • Prevents any requests made by devices on the temporary blacklist

Installation

 apt-get install libapache2-mod-evasive

Restart Apache

 service apache2 restart

Create a folder for log files:

 mkdir -p /var/log/apache2/evasive

and define access privileges

 chown -R www-data:root /var/log/apache2/evasive

Configuration

Open the configuration file:

 nano /etc/apache2/mods-available/mod-evasive.load

Add this to the file if it is not already present:

 LoadModule evasive20_module /usr/lib/apache2/modules/mod_evasive20.so

Open virtual host ("default" in example):

 nano /etc/apache2/sites-available/default

And add lines to each virtual host:

...
</Directory>
<IfModule  mod_evasive20.c>
 DOSHashTableSize 3097
 DOSPageCount 2
 DOSSiteCount 50
 DOSPageInterval 5
 DOSSiteInterval 1
 DOSBlockingPeriod 10
 DOSLogDir “/var/log/apache2/evasive”
 #DOSSystemCommand "sudo -u root /sbin/iptables -A INPUT -s %s -j DROP"
</IfModule>
...


DOSPageCount = Page request limitations, if exceeded then it puts you on the temporary blacklist

DOSSiteCount = Total amount of pages that can be requested

DOSPageInterval = Interval between page requests

DOSSiteInterval = Interval between website requests

DOSBlockingPeriod = Blacklist duration

DOSLogDir = Log

DOSSystemCommand = Additional parameters (disabled, advanced users could find them useful)


Check the settings in the apache2.conf file:

 nano /etc/apache2/apache2.conf 

And the following lines should be present in the file:

# Include module configuration:
Include mods-enabled/*.load
Include mods-enabled/*.conf

mod_expires

This enables defining the timeout period and type of elements to be stored in RAM. It is recommended to define pictures to be stored in RAM, since they generate a lot of traffic and can be stored for up to a day. When the elements are stored in RAM, the page also loads faster when they don't have to be fetched from the server every time. Storing elements in RAM can create some problems if the site constantly updates and changes their elements. Old elements could still be loaded even when the new ones are already present. This will work itself out by time, though.

Installation

This feature comes boxed with the Apache installation package. Enable the feature with the command:

 a2enmod expires

Restart Apache

 service apache2 restart

Configuration

You can define the configuration directly to the virtual host and .htaccess file.

For example:

 ## EXPIRES CACHING ##
 <IfModule mod_expires.c>
 ExpiresActive On
 ExpiresDefault "access plus 30 days"
 </IfModule>
 ## EXPIRES CACHING ##

So by default the server forces a reload of all elements on the website every 30 days.


More:

 ExpiresActive On
 ExpiresByType image/jpg "access plus 1 year"
 ExpiresByType image/jpeg "access plus 1 year"
 ExpiresByType image/gif "access plus 1 year"
 ExpiresByType image/png "access plus 1 year"
 ExpiresByType text/css "access plus 1 month"
 ExpiresByType application/pdf "access plus 1 month"
 ExpiresByType text/x-javascript "access plus 1 month"
 ExpiresByType application/x-shockwave-flash "access plus 1 month"
 ExpiresByType image/x-icon "access plus 1 year"
 ExpiresDefault "access plus 2 days"

This gives pictures and icons a one year expiration period and a month for .pdf, javascript and flash files. The default for any other elements is two days.

mod_rewrite

Redirecting module, enables webpage redirecting.

Installation

Comes preinstalled with apache. Enable the feature by:

 a2enmod rewrite

Restart Apache

 service apache2 restart

Configuration

Example: HTTP -> HTTPS

 RewriteEngine On
 RewriteCond %{HTTPS} off
 RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI}

Eli uudelleenohjataan samaan sijaintiin HTTPS kanssa, kun pyydetään.

Esimerkki: Uudelleenohjaus UserAgentin avulla

 RewriteCond  %{HTTP_USER_AGENT}  (iPhone|Blackberry|Android)
 RewriteRule  ^/$                 /mobile.html  [L]
 
 RewriteRule  ^/$                 /std.html  [L]

Eli Iphone, Blackberry ja Android laitteet uudelleenohjataan /mobile.html sivulle. Lisääthän tarvittavat UserAgent tiedot että tämä toimisi kaikilla haluamallasi selaimilla tai laitteilla.

Esimerkki: Jos tiedostoa ei ole (ERROR 404), uudelleenohjaa /index.php tiedostoon. Normaalisti näytetään ERROR 404 verkkosivu.

  RewriteEngine On
  RewriteBase /
  RewriteCond %{REQUEST_FILENAME} !-f
  RewriteCond %{REQUEST_FILENAME} !-d
  RewriteRule . /index.php [L]

Sinun tulee määrittää DocumentRoot polku samaan sijainnilla kuin /index.php määritetty.

Esimerkki: domain.net, domain.com, www.domain.net uudelleenohjahtaan domain.local osoitteeseen.

 RewriteEngine On
 RewriteCond %{HTTP_HOST} =domain.net [OR]
 RewriteCond %{HTTP_HOST} =domain.com [OR]
 RewriteCond %{HTTP_HOST} =www.domain.net
 RewriteRule .* https://domain.local%{REQUEST_URI}

Esimerkkejä

Uudelleenohjaus domain.com -> www.domain.com

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^www.domain.com$ [NC]
 RewriteRule ^(.*)$ http://www.domain.com/$1 [L,R=301]

Uudelleenohjaus www.domain.com -> domain.com

 RewriteEngine On
 RewriteBase /
 RewriteCond %{HTTP_HOST} !^domain.com$ [NC]
 RewriteRule ^(.*)$ http://domain.com/$1 [L,R=301]

Uudelleenohjaus http -> https

 <IfModule mod_rewrite.c>
  RewriteEngine On
  RewriteCond %{HTTPS} off
  RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>

Uudelleenohjaus https -> http

<IfModule mod_rewrite.c>
   RewriteEngine On
   RewriteCond %{HTTPS} on
   RewriteRule (.*) http://%{HTTP_HOST}%{REQUEST_URI}
</IfModule>

mod_security

Tällä estetään SQL injektiot ja CSR. Lisätietoa https://www.digitalocean.com/community/tutorials/how-to-set-up-mod_security-with-apache-on-debian-ubuntu

Asennus

 apt-get install libapache2-modsecurity

Käynnistä Apache uudelleen

 service apache2 restart

Muuta oletuskonfigurointi tiedoston nimi

 /etc/modsecurity/modsecurity.conf{-recommended,} (tallenna uudelleen *.conf päätteeksi)

Lataa Apachen konfigurointi tiedosto uudelleen

 service apache2 reload

Löydät loki tiedoston Apachen loki hakemistosta /var/log/apache2/

 root@droplet:~# ls -l /var/log/apache2/modsec_audit.log
 -rw-r----- 1 root root 0 Oct 19 08:08 /var/log/apache2/modsec_audit.log

Konfigurointi

Avaa konfigurointi tiedosto

 nano /etc/modsecurity/modsecurity.conf

Etsi rivi:

 SecRuleEngine DetectionOnly

ja muuta se:

 SecRuleEngine On

Etsi rivi:

 SecResponseBodyAccess On

ja muuta se

 SecResponseBodyAccess Off

Näillä voit rajoittaa lähettettyjen tietojen määrää:

 SecRequestBodyLimit
 SecRequestBodyNoFilesLimit

mod_ssl

Tämä moduuli mahdollistaa HTTPS yhteyden palvelimeen.

Asennus

Tämä on asennettu apache2-common paketin mukana. Sinun tulee ottaa käyttöön

 a2enmod ssl

Käynnistä Apache uudelleen

 service apache2 restart

Konfigurointi

Esimerkki: SSL konffit

 SSLEngine on
 SSLCertificateFile /etc/ssl/ssl.crt
 SSLCertificateKeyFile /etc/ssl/ssl.key

Tallenna tilaamasi sertifikaatti hakemistoon ja määritä se virtuaali isäntään.

256 bittinen salaus

256bittiseen salaukseen on muokattava Apachen konffeihin:

 nano /etc/apache2/mod-available/ssl.conf

Ja muuta riviä:

 SSLCipherSuite AES256-SHA

Lisäkonfiguraatiota

Voidaan myös määrittää Virtuaalihost kohtaisesti ja htaccess


256bittiseen salaukseen on muokattava Apachen konffeihin:

 nano /etc/apache2/mod-available/ssl.conf
 SSLCipherSuite AES256-SHA

Poista SSL3 ja SSL2 käytöstä

 nano /etc/apache2/mod-available/ssl.conf

SSLProtocol All -SSLv2 -SSLv3


Hyvä SSLChipperSuite:


 nano /etc/apache2/mod-available/ssl.conf

SSLCipherSuite "ECDHE-RSA-AES128-GCM-SHA256 EECDH+ECDSA+AESGCM EECDH+aRSA+AESGCM EECDH+ECDSA+SHA384 EECDH+ECDSA+SHA256 EECDH+aRSA+SHA384 EECDH+aRSA+SHA256 EECDH EDH+aRSA !aNULL !eNULL !LOW !3DES !MD5 !EXP !PSK !SRP !DSS !RC4"


Ota käyttöön Strict Transport Security (HSTS) ominaisuus lisäämällä ottamalla käyttään moduuli headers

 a2enmod headers

ja lisäämällä konffeihin:

 Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"

DHPARAM

Korvaa seuraava rivi /etc/apache2/mod-enabled/ssl.conf tiedostosta ja käynnistä uudelleen

 SSLCipherSuite "EECDH+ECDSA+AESGCM:EECDH+aRSA+AESGCM:EECDH+ECDSA+SHA384:EECDH+ECDSA+SHA256:EECDH+aRSA+SHA384:EECDH+aRSA+SHA256:EECDH+aRSA!RC4:EECDH:!RC4:!aNULL:!eNULL:!LOW:!3DES:!MD5:!EXP:!PSK:!SRP:!DSS"

mod_userdir

Tämä moduuli mahdollistaa jokaiselle tai osalle palvelimen käyttäjätilille omat verkkosivut.

Asennus

Tämä moduuli on valmiina asennettu Apachen mukana, sinun tulee laittaa se käyttöön

 a2enmod userdir

Käynnistä Apache uudelleen

 service apache2 restart

Konfigurointi

Avaa konfigurointi tiedosto /etc/apache2/mods-available/userdir.conf

 nano /etc/apache2/mods-available/userdir.conf

Jos haluat määrittää tiettyyn virtuaaliseen hostiin, kommentoi tiedosto ja konfiguroi konffit virtuaali hostin konffeihin.

Esimerkki: Sallitaan kaikille käyttäjille käyttää tätä toimintoa. Käyttäjän tulee luoda /home/ hakemistoon public_html niminen kansio.

 UserDir public_html
 UserDir enabled

Esimerkki: Sallitaan kaikille käyttäjätileille käyttää tätä toimintoa, paitsi root käyttäjälle. Käyttäjän tulee luoda /home/ hakemistoon public_html niminen kansio.

 UserDir public_html
 UserDir disabled root
 UserDir enabled

Esimerkki: Sallitaan vain käyttäjän user1 ja user2 käyttää tätä toimintoa. Käyttäjän tulee luoda /home/ hakemistoon public_html niminen kansio.


 UserDir public_html
 UserDir disabled
 UserDir enabled user1 user2

Verkkopolku on käyttäjien kotisivuille http://ip-osoite/~username.

Esimerkki konfigurointi:

  UserDir public_html
  UserDir disabled root
    <Directory /home/*/public_html>
        AllowOverride AuthConfig
        Options FollowSymLinks +Indexes
    </Directory>

Lisää seuraava rivi jos haluat käyttää osoitetta http://ip-osoite/user/username

      AliasMatch ^/users/([a-zA-Z0-9]+)/?(.*) /home/$1/public_html/$2

Eli kaikille käyttäjille sallittu, paitsi root käyttäjälle. Lisäksi sallitaan /home/*/public_html hakemistoon (verkkosivuhakemistoon) AuthConfig eli .htaccess tiedostoon luominen kirjautiminen näkymä. AliasMatch mahdollistaa uudelleenohjata kotisivuhakemisto esimerkiksi tässä http://ip-osoite/users/username

PHP5 userdir

Salli käyttäjien sivuilla PHP5 käyttö.

Muokkaa tiedostoa

 /etc/apache2/mod-enabled/php5.conf

Lisää risuaita

#      php_admin_value engine On
Luo uudelle käyttäjälle public_html kansio

Luo kansio /etc/skel hakemiston alle. Täälä olevat tiedostot ja kansiot automaattisesti kopioidaan uuden käyttäjän kotikansioon.

 mkdir /etc/skel/public_html

.htaccess

.htaccess tiedosto mahdollistaa konfigurointi tiedostojen tallentamisen suoraan verkkosivuhakemistoon, esimerkiksi /var/www/.htaccess.

Sallitaan .htaccess tiedoston ylikirjoittamaan entiset konfiguroinnit:


 /etc/apache2/sites-available/default

seuraavanlaiseksi:

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

Käynnistä Apache uudelleen:

 service apache2 reload

Luodaan .htaccess tiedosto /var/www/.htaccess (HUOM! Varmista että se on ".htaccess" ei .htacess.txt ym.)

 nano /var/www/.htaccess

Salasanasuojaus verkkosivulle

!! htpasswd httpd-2.4.4 on rikki. Odota päivitystä. !!


Kirjoita alla olevat rivit .htaccess tiedotoon:

 AuthUserFile /var/.htpasswd
 AuthName "Anna kirjautumisen tiedot"
 AuthType Basic
 require user [käyttäjänimet]

Tallenna tiedosto ja tämän jälkeen luodaan esimerkiksi /var/.htpasswd tiedosto jossa on käyttäjänimet ja salasanat, jolla oikeudet kirjautua sivulle. Suositellaan erityisesti salasanojen kryptaamista. Huomaa, että polut pitää olla palvelimen fyysisiä polkuja, ei verkkopolkuja!

 käyttäjänimi:salasana

Sinun tulee käyttää Debianissa htpasswd työkalua. Internetissä on myös htpasswd työkaluja saatavilla.

Esimerkki:

htpasswd -B /polku/.htpasswd Käyttäjätunnus Salasana

Tallenna tiedosto ja kokeile kirjautua sivullesi.


htpasswd bugin väliaikaisen korjaus

Bugi ei anna kuin Debianissa generoituja salasanojen kirjautumisen järjestelmään.

Voit generoida salasanan tällä komennolla:

 htpasswd -nb user password

Kopioi ja tallenna htpasswd tiedostoon, näin pitäisi toimia

Virhesivut

Kirjoita alla olevat .htaccess tiedostoon. Muuta polut vastaamaan palvelimessasi olevaa polkua.

 ErrorDocument 400 /errors/badrequest.html
 ErrorDocument 401 /errors/authreqd.html
 ErrorDocument 403 /errors/forbid.html
 ErrorDocument 404 /errors/notfound.html
 ErrorDocument 500 /errors/serverr.html

Määritä polut oikein vastaamaan palvelimesi polkuja missä virhesivusi sijaitsevat

Apachen suojaaminen

Webbipalvelimen suojaaminne ulkopuolisten hyökkäyksiltä kannattaa tehdä. mod_evansive ja mod_security auttavat siinä. Olen heiman kuitenkin koonnut lisää konffeja jolla voi suojata Apachea paremmi.


Piilota Apachen versio ja muut tiedot

 /etc/apache2/conf.d/security
 ServerSignature Off
 ServerTokens Prod

Poista kansioden selaus käytöstä

.htaccess

 Options -Indexes

Määritä Timeout

 /etc/apache2/apache2.conf
 Timeout 45

Rajoita pyyntöjä

 /etc/apache2/apache2.conf
 LimitRequestBody 1048576

Apache2 + PAM autentikointi

Asennetaan lisämoduuli apacheen

aptitude install libapache2-mod-auth-pam

Avataan Apachen Virtuaalihost konfigurointi tiedosto

nano /etc/apache2/sites-enabled/000-default
<Directory /var/www/salaista/> #Polku palvelimella
        AuthType Basic
        AuthName "ebin" #Viesti kirjautumisessa
        AuthPAM_Enabled On
        AuthBasicAuthoritative Off
        AuthUserFile /dev/null
        #AuthBasicAuthoritative Off
        #AllowOverride AuthConfig
        AuthGroupFile /etc/group
        Require group Role_Adminit #Salli tietylle käyttäjäryhmälle oikeudet
</Directory>

Näin Unixin tunnuksillakin voi kirjautua htaccess sivulle (ilman että htpasswd komentoa on ajettu).

Apache ja Active Directory todennus

Testattu Apache 2.2 Debianilla.

Ota käyttöön moduulit authnz_ldap ja ldap

 a2enmod authnz_ldap
 a2enmod ldap

Kopioi alla oleva haluamasi virtualihostiin.

 <Directory "/var/www/login">
        AuthType Basic
        AuthName "Active Directory kirjautuminen"

        AuthBasicProvider ldap
        AuthzLDAPAuthoritative off

        AuthLDAPURL "ldap://dc.domain.com:389/dc=domain,dc=com?sAMAccountName?sub?(objectClass=*)"

        AuthLDAPBindDN "[email protected]"
        AuthLDAPBindPassword salaisuus

        Require valid-user
        #Require ldap-group CN=Administrators,CN=Users,DC=example,DC=com
</Directory>
  • AuthLDAPURL on osoite jossa ldap palvelin (toimialueenohjauskone) on. Muuta konfiguraatiota vastaamaan palvelimesi konfiguraatiota. Kokeile myös porttia 3268.
  • AuthLDAPBindDN on käyttäjätunnus jolla on pääsy lukemaan Active Directoryä
  • AuthLDAPBindPassword on käyttäjätunnuksen salasana

Jos ei toimi lisää tämä konfiguraatioon ja katso Apachen error log tiedosto /var/log/apache/error.log:

 LogLevel debug

Loki

Apachen lokiin virhe ja kävijä lokit

ErrorLog ${APACHE_LOG_DIR}/error.log

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined ==

Apachen postaminen

Pysäytä Apache2

 service apache2 stop

Poistetaan Apachen2 paketit:

  apt-get purge apache2 apache2-utils apache2.2-bin apache2-common

Etsitään Apachen hakemistoja ja poistetaan ne yksitellen:

 whereis apache2

Tässä tulostuu esimerkiksi:

 apache2: /etc/apache2

Poistetaan hakemisto:

 sudo rm -rf /etc/apache2

Ongelmanratkaisu

Jos Apache ei käynnisty ja tulee jonkinlainen virhe, varmista että olet kirjoittanut konfigurointi tiedostoihin oikein jä tämän jälkeen kannattaa avata palvelimen loki:

 /var/log/apache2/error.log

sinne tallentuu kaikki virheilmoitukset. Kopioi virheilmoitus ja Googleta virheilmoitus. Googlesta saat ongelmaan ratkaisun.

Konfiguroinnin tarkistus

 apachectl configtest

TAI

 apache2ctl configtest

Lähteet

http://fi.wikipedia.org/wiki/Apache_(palvelinohjelma)

https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-debian-7

http://wiki.syotec.fi/index.php?title=JAH380_-_Linux_Server_-_Toimialue

http://www.rudedog.org/pipermail/auth_ldap/2003-December/001494.html

http://www.edugeek.net/forums/nix/7453-apache-winbind-authentication-2.html

http://www.held-im-ruhestand.de/software/apache-ldap-active-directory-authentication

http://enarion.net/web/htaccess/redirect-www-and-no-www/

https://www.digicert.com/ssl-certificate-installation-apache.htm

https://www.digitalocean.com/community/tutorials/how-to-install-linux-apache-mysql-php-lamp-stack-on-centos-6

http://httpd.apache.org/docs/2.2/mod/mod_ssl.html

http://stackoverflow.com/questions/24144552/how-to-set-hsts-header-from-htaccess-only-on-https

http://xmodulo.com/how-to-uninstall-and-remove-apache2-on-ubuntu-debian.html

http://codeconnoisseur.org/ramblings/apache-22-and-active-directory-and-group-restrictions

Mainos / Advertisement: