Friday, September 24, 2010

Apache and BIND on Slackware

Introduction
Apache is the most popular web server since April 1996. It was originally based on NCSA httpd, and
has grown into a full-featured HTTP server. Slackware Linux currently uses the 1.3.x branch of
Apache. This chapter is based on Apache 1.3.x.

Installation
Apache can be installed by adding the apache package from the “n” disk set. If you also want to use PHP, the php (“n” disk set) and mysql (“ap” disk set) are also required. MySQL is required, because the precompiled PHP depends on MySQL shared libraries. You do not have to run MySQL itself. After installing Apache it can be started automatically while booting the system by making the /etc/rc.d/rc.httpd file executable. You can do this by executing:

# chmod a+x /etc/rc.d/rc.httpd
The Apache configuration can be altered in the /etc/apache/httpd.conf file. Apache can be
stopped/started/restarted every moment with the apachectl command, and the stop, start and
restart parameters. For example, execute the following command to restart Apache:
# apachectl restart
/usr/sbin/apachectl restart: httpd restarted

User directories
Apache provides support for so-call user directories. This means every user gets web space in the
form of http://host/~user/ . The contents of “~user/” is stored in a subdirectory in the home directory
of the user. This directory can be specified using the “UserDir” option in httpd.conf, for example:
UserDir public_html
This specifies that the public_html directory should be used for storing the web pages. For
example, the web pages at URL http://host/~snail/ are stored in /home/snail/public_html.

Virtual hosts
The default documentroot for Apache under Slackware Linux is /var/www/htdocs. Without using
virtual hosts every client connecting to the Apache server will receive the website in this directory.
So, if we have two hostnames pointing to the server, “www.example.org” and “forum.example.org”,
both will display the same website. You can make separate sites for different hostnames by using
virtual hosts.
In this example we are going to look how you can make two virtual hosts, one for “www.example.org”, with the documentroot /var/www/htdocs-www, and “forum.example.org”,
with the documentroot /var/www/htdocs-forum. First of all we have to specify which IP addresses Apache should listen to. Somewhere in the /etc/apache/httpd.conf configuration file you will find the following line:
#NameVirtualHost *:80
This line has to be commented out to use name-based virtual hosts. Remove the comment character
(#) and change the parameter to “BindAddress IP:port”, or “BindAddress *:port” if you want
Apache to bind to all IP addresses the host has. Suppose we want to provide virtual hosts for IP
address 192.168.1.201 port 80 (the default Apache port), we would change the line to:
NameVirtualHost 192.168.1.201:80
Somewhere below the NameVirtualHost line you can find a commented example of a virtualhost:
#
# ServerAdmin webmaster@dummy-host.example.com
# DocumentRoot /www/docs/dummy-host.example.com
# ServerName dummy-host.example.com
# ErrorLog logs/dummy-host.example.com-error_log
# CustomLog logs/dummy-host.example.com-access_log common
#
You can use this example as a guideline. For example, if we want to use all the default values, and
we want to write the logs for both virtual hosts to the default Apache logs, we would add these lines:



DocumentRoot /var/www/htdocs-www
ServerName www.example.org


DocumentRoot /var/www/htdocs-forum
ServerName forum.example.org


BIND


Introduction
The domain name system (DNS) is used to convert human-friendly host names (for example
www.slackware.com) to IP addresses. BIND (Berkeley Internet Name Domain) is the most widely
used DNS daemon, and will be covered in this chapter.
Delegation One of the main features is that DNS requests can be delegated. For example, suppose that you own the “linuxcorp.com” domain. You can provide the authorized nameservers for this domain, you nameservers are authoritative for the “linuxcorp.com”. Suppose that there are different branches within your company, and you want to give each branch authority over their own zone, that is no problem with DNS.
You can delegate DNS for e.g. “sales.linuxcorp.com” to another nameserver within the DNS configuration for the “linuxcorp.com” zone. The DNS system has so-called root servers, which delegate the DNS for millions of domain names and extensions (for example, country specific extensions, like “.nl” or “.uk”) to authorized DNS servers. This system allows a branched tree of delegation, which is very flexible, and distributes
DNS traffic.


DNS records
The following types are common DNS records:
Table.27 DNS records
Prefix Description
AAn a records points to an IP address.
CNAMEA CNAME record points to another DNS entry.
MXA MX record specifies which should handle mail for the domain.

Masters and slaves
Two kinds of nameservers can be provided for a domain name: a master and slaves. The master server DNS records are authoritative. Slave servers download their DNS record from the master servers. Using slave servers besides a master server is recommended for high availability and can be used for load-balancing.

Making a caching nameserver
A caching nameserver provides DNS services for a machine or a network, but does not provide DNS for a domain. That means it can only be used to convert hostnames to IP addresses. Setting up a nameserver with Slackware Linux is fairly easy, because BIND is configured as a caching nameserver by default. Enabling the caching nameserver takes just two steps: you have to install BIND and alter the initialization scripts. BIND can be installed by adding the bind package from the “n” disk set. After that bind can be started by executing the named(8) command. If want to start BIND by default, make the /etc/rc.d/rc.bind file executable. This can be done by executing the
following command as root:
# chmod a+x /etc/rc.d/rc.bind
If you want to use the nameserver on the machine that runs BIND, you also have to alter
/etc/resolv.conf.

1 comment:

  1. thank's..
    http://projectprojects.donanza.com/

    ReplyDelete