Difference between revisions of "Apache"

From Linuxintro
imported>ThorstenStaerk
m (Reverted edits by 91.207.8.78 (talk) to last revision by ThorstenStaerk)
imported>ThorstenStaerk
(reducing memory footprint)
Line 3: Line 3:
 
= https =
 
= https =
 
See [[set up Apache with https]].
 
See [[set up Apache with https]].
 +
 +
= Apache needs too much memory - what to do =
 +
I have a web server at [[rackspace]] and every MB RAM costs me on a per-month base. Often, Apache needed more RAM than I had. So I reduced Apache's memory footprint by editing /etc/apache2/server-tuning.conf. I set
 +
StartServers 2
 +
MinSpareServers 2
 +
MaxSpareServers 6
 +
ServerLimit 15
 +
MaxClients 15
 +
and now Apache, wikipedia, dokuwiki, mysql and php fit into 512 MB.
  
 
= WebDAV under Apache2 =
 
= WebDAV under Apache2 =

Revision as of 19:31, 21 May 2012

Apache is a popular http daemon. In other words it is the software for web servers.

https

See set up Apache with https.

Apache needs too much memory - what to do

I have a web server at rackspace and every MB RAM costs me on a per-month base. Often, Apache needed more RAM than I had. So I reduced Apache's memory footprint by editing /etc/apache2/server-tuning.conf. I set

StartServers 2
MinSpareServers 2
MaxSpareServers 6
ServerLimit 15
MaxClients 15

and now Apache, wikipedia, dokuwiki, mysql and php fit into 512 MB.

WebDAV under Apache2

With Apache2, the DAV module is already included. You will need to activate the two needed modules dav_fs and dav using a2enmod. Afterwards, restart apache using

/etc/init.d/apache2 force-restart

In /etc/apache2/mods-available/dav_fs.conf you should find something like:

DAVLockDB /var/lock/apache2/DAVLock

The user-account Apache is running under (www or www-data) needs read-and write privileges in this folder.

Enter into /etc/apache2/apache2.conf:

Alias /daten /var/data
<Directory /var/data/>
DAV On
ForceType text/plain
AuthType Basic 
AuthName "WebDAV Daten" 
AuthUserFile /etc/apache2/htpasswd 
Require valid-user 
</Directory>

Create "/var/data" and issue

chown www-data:www-data /var/data

Create the FIRST user with:

htpasswd -c /etc/apache2/htpasswd benutzername

For further users, leave out the -c (create).

switch off Apache - Directory-Listing

Remove

Indexes 

from the options, then the content of the folders will no longer be shown.

Alias

An alias allows you to point a URL to a file like this:

Alias /skins /srv/www/htdocs/skins

Imagine we have a home page www.myhomepage.com and have a mediawiki running on it. The URL http://myhomepage.com/skins would now be processed by mediawiki. But we want it to contain pure files. So we make this alias.

Proxy

For software like shell in a box or guacamole you want apache to fetch data from another port than 80.

Set mod_proxy

You want to store a user list with passwords in /etc/apache2/.htpasswd.

root@linuxintro:/etc/apache2/mods-enabled# cat proxy.conf 
<IfModule mod_proxy.c>
        #turning ProxyRequests on and allowing proxying from all may allow
        #spammers to use your proxy to send email.

        ProxyRequests Off

        <Proxy *>
                AddDefaultCharset off
                AuthUserFile /etc/apache2/.htpasswd
                AuthName Wuhuuu
                AuthType Basic
                require valid-user
                Order deny,allow
                Allow from all
                #Deny from all
                #Allow from .example.com
        </Proxy>

        # Enable/disable the handling of HTTP/1.1 "Via:" headers.
        # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
        # Set to one of: Off | On | Full | Block

        ProxyVia On
</IfModule>

Use ProxyPass

Under Ubuntu 10.04 I go to /etc/apache2/sites-enabled and edit 000-default:

  <IfModule mod_proxy.c>
    <Location /shell>
      ProxyPass http://127.0.0.1:4200
    </Location>
  </IfModule>