Last revised: April 28, 2002
Apache can respond to browser requests from machines on your local network (i.e. an "Intranet" Web server) or from the Internet. The installation of the Solaris OS installed and set up most of the necessary Apache files. As a result, if you want to use your system as a Web server you only need to modify one file.
The file we need to edit is Apache's primary configuration file, httpd.conf which is stored in the /etc/apache directory. Actually, you have to create this file using an example file as a template.
With the existance of the httpd.conf file the Apache server will start automatically whenever you boot your system (it's the "httpd started" you'll see on screen while the system is booting). For now you can start it manually by opening a "This Host" window and entering the following command:
You should now be able to access the default Apache home page by using Netscape on the same machine by entering the following URL:
You should also be able to access it from a different machine on the same local network using the machine's IP address. Example:
Naturally, you'll need to have your ISP edit your "A" record on their DNS servers to point to your system's IP address in order for the system to act as a Web server for your domain (i.e. one that the public can access by entering your domain name for a URL). You'll also have to modify httpd.conf accordingly.
There are several key file locations (directories) you should be aware of:
If you want to host several Web sites you don't need several separate servers. Apache allows you to configure "virtual hosts" that appear as multiple Web servers to those who visit the sites.
In addition to setting up multiple virtual Web servers, the virtual host configuration statements also allow you to customize the behavior of each individual virtual server. This includes specifying file locations for DocumentRoot and CGI-BIN files.
The virtual host configuration statements are also in the httpd.conf file. They basically duplicate the configuration statements found earlier in the file enclosed in a set of VirtualHost directives.
<VirtualHost 172.18.254.38> ServerName www.my2nddomain.com ServerAdmin firstname.lastname@example.org ScriptAlias /cgi-bin/ /home/httpd/cgi-bin/my2nddomain/ DocumentRoot /home/httpd/html/my2nddomain/ <Directory /home/httpd/html/my2nddomain> AddHandler server-parsed .shtml AddType text/html .shtml Options +Includes </Directory> ErrorLog logs/my2nddomain-error_log CustomLog logs/my2nddomain-access_log common </VirtualHost>
Note that it's helpful to create a separate subdirectories in the DocumentRoot directory and the CGI-BIN directory for each additional site you will be hosting. This allows you to keep their pages and scripts separate. Giving the access and error logs site-specific names (or storing them in site-specific subdirectories) is also helpful.
The <Directory /home/httpd/html/> directive (and it's associated closing statement) are only necessary if you want to change any of the default values. The "default" values are those which are inherited from the main site's configuration values. In other words, if you were to use +Includes in the main site's options configuration it would not be necessary here.
If Includes is not enabled in the main site's configuration and you want to enable it you have to explicitly state so using the above commands for each virtual site. Enabling Includes allows you to use SSI directives (like include and exec ) on your Web pages.
Note that the above Directory directive references the DocumentRoot directory for the virtual site which, in this case, means that only the HTML document files stored in this directory are the ones that will be parsed to see if they contain SSI directives (provided the files have a .shtml extension).
It's important to remember that each Web site you host must have it's own static, public IP address. This is because the DNS record for the domain must point to a specific IP address. As a result, you'll have to assign multiple IP addresses to the system's single network interface.
Copyright © 2002 by Keith Parkansky. All rights reserved.
Thanks to Keith Parkansky for his contribution and maintenance of the article.