P U R E B S D 
OpenBSD and FreeBSD resources 
  /root | OpenBSD | FreeBSD
   >>  Main | System | Network | Daemons | Security | Software | Various

Sections  

DJBDNS  
Qmail  
NTP  
DHCP  
ProFTPD  
Apache  
CVS server  

MySQL  
Apache and OpenBSD

General

Configuration directory:
  /var/www/conf

Most important configuration file:
  /var/www/conf/httpd.conf

Setting the default e-mail address as seen on the 404 pages, edit the ServerAdmin directive in httpd.conf:
  ServerAdmin alex{}purebsd.com

If you want users being able to have a homepage like http://purebsd.com/~alex enable and set the UserDir directive in httpd.conf:
  UserDir public_html

If you'd like to have Apache see index.php too as a valid index file, edit and/or set the DirectoryIndex directive in httpd.conf:
  DirectoryIndex index.php index.html

If you'd like Apache to resolve IP addresses, for usage in logfiles, the REMOTE_HOST variable, /server-status page, etcetera, set the HostnameLookups in httpd.conf to this:
  HostnameLookups On

If you don't like Apache to report its version number and the hostname in 404 error pages, set the ServerSignature directive to Off in httpd.conf:
  ServerSignature Off


Virtual hosts/domains

If you'd like Apache to serve up name-based virtual hosts you first you need to define on which IP address(es) Apache will receive requests for them. Your name-based virtual host names usually resolve to this/these IP(s). So, edit httpd.conf to have something like this:
  NameVirtualHost 192.168.0.1
  NameVirtualHost 42.2.1.21

Now, adding the so called virtual hosts (names) to Apache is rather easy. An purely arbitrary example:

  # (www.)purebsd.com
  <VirtualHost 42.2.1.21>
     ServerName www.purebsd.com
     ServerAlias purebsd.com
     ServerAdmin webmaster@purebsd.com
     DocumentRoot /var/www/htdocs/www.purebsd.com
     ErrorLog logs/www.purebsd.com-ERROR
     CustomLog logs/www.purebsd.com-ACCESS combined
  </VirtualHost>

ServerName is the name of the virtual host you'd like to have Apache serve pages for.

ServerAlias is an optional directive, indicating all possible aliases for the same content (set of pages).

The ServerAdmin sets the e-mail address (only) for this particular virtual host.

DocumentRoot is very important. It tells Apache where to grab the pages/content of the virtual host. More accurately, it betrays the location of the directory holding the pages for the virtual host. http://purebsd.com/hoeba.html is translated into /var/www/htdocs/www.purebsd.com/hoeba.html

The ErrorLog directive dictates to Apache to which file it should log occurring errors.

CustomLog tells Apache about the whereabouts of the file where it should write the non-error events off our virtual host.

Sidenote: as to where the root of the DocumentRoot should be is mostly personal taste. Some like to put websites in /var/www/htdocs/, some in /vol/www/, others in /home/httpd/. Others mix it with a previously mentioned place for their own sites/special sites and use /home/user/htdocs-www.example.org for 3rd party users.

 

Contact | Feedback | License | Copyright © 2000,2001,2002,2003,2004,2005,2006 PureBSD.com
All rights reserved.
simonpam@purebsd.com