Configuring Web Services


It is possible to enable the Web service right out of the box without making any configuration changes. When you choose this route, a default Web site is started that is located at the IP address of your server. If you have a domain name associated with that IP address, the new site is also available using that name. The default Web site provides access to some documentation and a starting point for accessing any blogs you may have enabled.

It is better, however, to configure your Web service prior to enabling it. The general configuration is very simple and primarily allows you to change a few parameters that balance performance and resource use.

To configure Web services

1.

Launch Server Admin, select Web from the Computers & Services list, and click the Settings tab at the bottom of the screen (Figure 9.1).

Figure 9.1. The General tab of Server Admin's Web services window.


You will follow this first step for all the exercises in this chapter, so you may want to leave Server Admin open.

2.

Click the General tab and choose the options you want to configure:

  • Maximum simultaneous connections is the total number of connections to your Web site at any given time.

  • Connection timeout is the amount of time a browser will wait for your Web site to transfer the requested page code.

  • Minimum and maximum spare servers are the number of additional machines that can be used to serve this site to the Internet.

  • Number of servers to start is the number of Web servers to be used.

  • Allow persistent connections and its related options function when users connect to your site (usually an active connection via a scripting language such as Java) and leave their browser open for extended periods of time.

Please note that enabling the Allow Persistent Connections option is not compatible with the performance cache described in the next task.

3.

When you've finished making changes, click Save.

4.

Click Start Services in the Toolbar to start the Web service.

Now, any time you make a change to Web services, the service itself will automatically restart after you click Save.

Obtaining a Domain Name

To obtain a domain name, it is necessary to register with a domain name registrar. The fees vary from as little as about $3 per year to as much as about $35 per year.

Some popular registrars include:

  • www.networksolutions.com/

  • www.srsplus.com/

  • www.godaddy.com/

  • www.mactechdomains.com/

When you register a domain name, you must specify the name and/or IP address of your name servers. You should have at least two so that if one name server goes offline for any reason, the other server will still be available. Ideally, the two name servers would even be on different networks in different locations.

Once you obtain a domain name, you must set up DNS for your domain. Again, your ISP will often provide DNS services for you at no additional charge, but if you will be maintaining your own DNS, please refer to Chapter 6, "Network Services Options," for detailed instructions. As for building your content, you are on your ownbut if you come up with something wonderful for your Web site, don't forget to mention that you learned how to publish it from this book!


Setting up a Web site

After you have configured the base Web services, it is time to set up your first Web site. In the beginning of the Internet, there was the HTTP 1.0 protocol specification. In this specification, each Web site had an individual IP address. This began to pose a significant problem when the number of sites exploded. To solve this problem, virtual hosting support was added to the HTTP 1.1 specification in 1999.

The Apache Web server (see the sidebar, "Apache Configuration Files") lets you serve up multiple Web sites with either a basic single-Web site-per-IP-address scheme or virtual hosting of multiple Web sites sharing a single IP address. It is most likely that you will be utilizing virtual hosting for your site, and that is the method explained here. If you need to implement the basic scheme, you can emulate it by having just one virtual host assigned to an IP address.

Apache Configuration Files

For Apple, adopting Apache was a nobrainer. Apache has been around for quite some time, and many Unix administrators are familiar with its configuration files. Apache is a very powerful, efficient, extensible, and secure HTTP Web server because of the open source nature of the server, which allows for constant refinement in an environment of shared programming knowledge.

Although the Server Admin interface is handy, some options are available only in the configuration files:

  • The main Apache service configuration file is /etc/httpd/httpd.config.

  • Each Web site has its own configuration file, saved in /etc/httpd/sites/.

You need to remember a couple of rules when you're editing the Apache configuration files. First, always back up any configuration file before you change it! Second, to activate any changes, you must restart the Apache Web service.

Apache is completely free. Legions of technically savvy folks constantly improve the product and can, in turn, help you with yours. For more information, visit httpd.apache.org/.


In the following examples, it is assumed you have already obtained a domain name and have configured DNS to associate that domain name with the IP address assigned to your server. First you'll need to create your content and have it stored in a directory on your server.

To add a Web site

1.

After following step 1 in the previous task, click the Sites tab (Figure 9.2).

Figure 9.2. The default Sites tab in the Web services window.


2.

Click the plus button and the Editing window will appear (Figure 9.3).

Figure 9.3. The General tab within the Sites tab allows for basic configuration of your Web site.


The General tab has been selected by default. The "default (disabled)" text will disappear after the configuration has been completed.

3.

In the Domain Name field, enter the domain name to be associated with this Web site.

You should use the full domain name. For example, notice in Figure 9.4, "book" is included (book.osxit.com).

Figure 9.4. Entering the Web site address in the General tab of Web services.


4.

If there is more than one IP address associated with the server, select the specific IP address to be associated with the Web site (Figure 9.5).

Figure 9.5. Select the IP address for the Web site and then...


5.

For standard browser access to your Web site, leave the port set at 80.

or

If you have special requirements that require you to use another port, set the associated port number in the Port field.

6.

In the Web folder field, select the directory where your Web site is located (Figure 9.6).

Figure 9.6. ...select the appropriate directory for the Web files and the default file on your server using the browse dialog.


The default is /Library/WebServer/Documents/.

7.

In a simple static Web site, the default page to display when no specific page is requested is named index.html.

If you need to add a specific default index page, click the plus button and enter the name of the additional index page.

While you may have multiple defaults, only the first default that actually exists will be used.

8.

Enter the location of the error page for your Web site in the Error file field.

or

If you do not have an error page, you can leave the default value (/error.html) in place (Figure 9.7).

Figure 9.7. Configure the Web site's error file and administrator email.


The server will generate a default "404 file not found" error page. Do not clear the field because it causes Apache to generate an erroneous "500 internal server error" error page.

9.

Enter the Web site administrator's email address in the Administrator email field (see Figure 9.7).

10.

When you've finished making changes, click Save.

You have now configured the basic settings for your Web site.

Tip

  • It's bad practice to leave the default placeholder Web site enabled. That Web page is a good indication to crackers that a server isn't fully configured and is possibly unsecure.


Exploring Web site options

There are, of course, additional options when setting up Web sites. These include accessing Web mail, enabling the performance cache, allowing scripts to run, and creating folder listings. There are some security risks associated with these options, so a thorough analysis is in order (Figure 9.8).

Figure 9.8. Enable any of the optional Web site features.


Web Server Scripts

Web scripts differ from regular Web site files in that they're coded instructions that let the server dynamically generate Web page information. Apache, through its extensive modules, supports common open source scripting languages. The most commonly used scripts are CGI scripts written in Perl or Python and PHP scripts:

  • CGI option 1 The default location for CGI scripts available to all Web sites is /Library/WebServer/CGI-Executables/. In your Web browser, enter http:// sitename/cgi-bin/script.cgi.

  • CGI option 2 If a script will be used by only one specific Web site, you can put it in that Web site's folder. In your Web browser, enter http://sitename/script.cgi.

  • PHP Enable PHP script execution by selecting the php4_module in the Web server Modules list. PHP scripts can be located in any Web site's folder. In your Web browser, enter http://sitename/script.php.


  • Folder Listing enables the automatic generation of index pages listing the contents of the requested directory. Enabling Folder Listings can be a great help while developing and debugging your Web site, but you should disable the option for production Web sites. Also, enabling Folder Listings provides a significant amount of information about your Web site to your users, which hackers can use to attack your Web site. Unless you know you need them, you may wish to keep this option disabled.

  • Enabling WebDAV permits users to connect to your Web site as they would a file server. WebDAV will be covered later in this chapter.

  • CGI Execution enables the execution of Common Gateway Interface (CGI) programs within the Web site. The programs to be executed must have a .cgi filename extension. Unless you know that you need to enable CGI scripts, it is best to disable this option.

  • WebMail is used for the WebMail application within the Web site. For more information on WebMail, refer to Chapter 8, "Enabling Mail Services."

  • Server Side Includes (SSI) enables the use of server-side includes within the Web site. SSIs are still a very popular way to build Web site themes or templates. They provide a relatively powerful way to include HTML fragments and even programmatic content in a Web page. Because of this power, they also pose a security threat if used improperly. Unless you know you need them, it is best to disable this option.

  • Performance Cache loads your Web site into RAM and serves the pages from memory instead of the hard disk. While this may deliver some speed improvements, it requires the Web site to run on a nonstandard port, which can cause problems with firewalls. For this reason, and the fact that the speed increase, if any, is completely mitigated by your most likely limited bandwidth, it's recommended that you deselect the performance cache option.

Modules and options

It's important to remember that the options settingsalias, redirect, SSL, and realmmust be configured separately for each Web site. However, the module settingsMIME type and content handlerwill affect every Web site on your server. And changes to proxy settings won't affect any of your Web site settings.

Also make sure you thoroughly test your Web site options by opening any Web browser and entering the hostname you configured. Modules can be turned on and off via the Modules tab under Settings of the Web service in Server Admin.

Every option and module that you implement can potentially use more RAM, so you may want to keep an eye on RAM usage as you test the various options and modules.

When tweaking the settings for each of your Web sites found under each tab, you may need to enable new Apache modules. These modules, typically installed in /usr/_libexec/httpd/, are coded extensions that add functionality to the Web server. Literally hundreds of freely downloadable Apache modules are available at modules.apache.org:

  • mod_macbinary_apple

  • mod_spotlight_apple

  • mod_auth_apple

  • mod_hfs_apple

  • mod_digest_apple

  • mod_bonjour





Mac OS X Server 10. 4 Tiger. Visual QuickPro Guide
Mac OS X Server 10.4 Tiger: Visual QuickPro Guide
ISBN: 0321362446
EAN: 2147483647
Year: 2006
Pages: 139
Authors: Schoun Regan

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net