Installing Apache


Apache is a complex piece of software because of the many features and standards it supports. Most of these features are added through optional modules that can be loaded dynamically and configured through Apache's configuration files.

To install Apache (Fedora Core)

Installing Apache on Fedora Core is as simple as pulling in the prebuilt binary package.

1.

Log in as root, or use su to become root.

2.

up2date --install httpd

Use the up2date command to install the latest version of the Apache HTTP daemon (Code Listing 9.1).

The prebuilt package for Apache is downloaded and installed.

3.

service start httpd

Start our new HTTP service. If your machine is visible to the outside world, you should probably start it after Apache has been configured.

4.

Launch the Services control panel (from the Applications menu in the top left of your screen choose System Settings > Server Settings > Services).

5.

Scroll down the list of services until you find the httpd enTRy (Figure 9.1).

Figure 9.1. Activating the Apache server on Fedora Core.


As you can see in the screen shot, the httpd service isn't set to start at boot time (it has no check mark). Also, you can see that I've started it by hand (in step 3) because the Status section is listing several process IDs for the httpd.

6.

Check the box next to httpd to make Apache start when the system boots, and then close the Service Configuration window.

Code listing 9.1. Using up2date</GG> to install Apache on Fedora Core.
 [root@dhcppc1 ~]# up2date --install httpd ... The following packages were added to your selection to satisfy dependencies: Name           Version        Release ------------------------------------- apr            0.9.4          23 apr-util       0.9.4          17 httpd-suexec   2.0.52         3.1 [root@dhcppc1 ~]# service start httpd Starting httpd: [OK] 

To install Apache (FreeBSD)

Naturally, the FreeBSD ports system has an entry for the latest Apache.

1.

cd /usr/ports/www/apache2

Change to the Apache 2.x directory in the ports tree (Code Listing 9.2). Apache 1.3.x is also available, which is why there isn't an "apache" directory in the ports tree.

2.

make install clean

Download the Apache source code (plus any dependencies), compile it, and install it, then clean up.

3.

Edit the /etc/rc.conf file with your favorite text editor.

4.

Add the following line to start Apache during the boot process:

 apache2_enable="YES" 

5.

Save the rc.conf file and exit your editor.

6.

/usr/local/etc/rc.d/apache2.sh start

Start the Apache HTTP server.

Code listing 9.2. Using the ports system to install Apache on FreeBSD.
 bsd# cd /usr/ports/www/apache2 bsd# make install clean ... bsd# vi /etc/rc.conf ... bsd# /usr/local/etc/rc.d/apache2.sh start Starting apache2. 

To install Apache (Cygwin)

Cygwin has a port of Apache 1.3 but no port of Apache 2, so we're going to break form and install the "native" Windows Apache, and then hook it up with Cygwin's file system.

1.

Use your favorite Web browser to visit the Apache Software Foundation site ( www.apache.org) (Figure 9.2).

Figure 9.2. The Apache group's Web site.


2.

Click the "HTTP Server" link in the project list on the left-hand side to visit the Apache HTTP Server Project page.

3.

Click the "from a mirror" link under Download! in the table of contents along the left-hand side.Your Web browser displays the download page.

4.

Scroll down to the "Apache 2.0.52 is the best available version" section, then click the "Win32 Binary (MSI Installer)" link.

5.

Save the installer file to your desktop.

6.

Double-click the installer file to launch the Apache HTTP Server 2.0 Installation Wizard (Figure 9.3).

Figure 9.3. The Apache installation wizard on Windows.


Click Next to continue.

7.

Read the License Agreement (Figure 9.4), then click the "I accept the terms in the license agreement" radio button.

Figure 9.4. The Apache license agreement.


Click Next to continue.

8.

Read the Read This First information (Figure 9.5).

Figure 9.5. The Apache Read This First information.


Click Next to continue.

9.

In the Server Information pane(Figure 9.6), enter your Web server's information in the following areas:

  • Network Domain This can be a real registered domain or something like "local" for your LAN. The default is to use your computer's domain.

  • Server Name The hostname, plus Network Domain. The default is your computer's fully qualified domain name.

  • Administrator's Email Address The email address of the owner of this server. You might want to set up a new email address for this; visitors will send you problem reports, but the address will also start to get a lot of spam email.

  • A choice between having the server run as a service (the default) or manually. You want the default.

Figure 9.6. Entering server information in the Apache installation wizard.


Click Next to continue.

10.

Choose Typical (the default) in the Setup Type pane (Figure 9.7).

Figure 9.7. Choosing the Typical or Custom installation in the Apache installation wizard.


Choosing Custom lets you install the headers and libraries needed to compile additional Apache modules, but they won't be compatible with the compiler installed with Cygwin.

11.

Click Next to continue.

12.

In the Destination Folder pane (Figure 9.8), click the Change button.

Figure 9.8. Choosing the destination folder in the Apache installation wizard.


13.

In the Change Current Destination Folder pane, use the file selector to navigate to C:\cygwin\usr\local\ (Figure 9.9), then click OK.

Figure 9.9. Using the file selector to install Apache in our Cygwin directory.


Click Next in the installation wizard to continue.

14.

Click the Install button in the installation wizard to install Apache.

15.

Click the Finish button in the installation wizard to exit the installer.

Tip

  • If your Apache 2 server is causing problems on Windows (corrupted or incomplete file downloads, unexplained error messages, or conflicts with software), add the following directives to Apache's configuration file, and then restart the server:

     EnableSendfile Off EnableMMAP Off Win32DisableAcceptEx 


To install Apache (Mac OS X)

Although Mac OS X comes with an older version of Apache, we'd like to use the current version, and Fink can help us install it.

1.

sudo fink install apache2

Tell Fink to install the latest version of Apache (Code Listing 9.3) and any dependencies it might have.

Code listing 9.3. Using Fink to install Apache on Mac OS X.

[View full width]

 bender:~ chrish$ sudo fink install apache2 Password: Information about 1977 packages read in 3 seconds. fink needs help picking an alternative to satisfy a virtual dependency. The candidates: (1) apache2-mpm-worker: Apache2 Server Binary - [MPM WORKER] (2) apache2-mpm-perchild: Apache2 Server Binary - [MPM PERCHILD *EXPERIMENTAL*] (3) apache2-mpm-prefork: Apache2 Server Binary - [MPM PREFORK] (4) apache2-mpm-leader: Apache2 Server Binary - [MPM LEADER *EXPERIMENTAL*] (5) apache2-mpm-threadpool: Apache2 Server Binary - [MPM THREADPOOL *EXPERIMENTAL*] Pick one: [1] ... The following package will be installed or updated: apache2 The following 7 additional packages will be installed:  apache2-common apache2-mpm-worker apr apr-common apr-shlibs db42 db42-shlibs Do you want to continue? [Y/n] ... bender:~ chrish$ cd /Library/StartupItems/ bender:/Library/StartupItems chrish$ sudo mkdir Apache2 bender:/Library/StartupItems chrish$ cd Apache2 bender:/Library/StartupItems/Apache2 chrish$ sudo ln -s /sw/sbin/apachectl Apache2 bender:/Library/StartupItems/Apache2 chrish$ sudo sh -c "sed -e 's/Apache/Apache 2/g' <  /System/Library/StartupItems/Apache/StartupParameters.plist > StartupParameters.plist" bender:/Library/StartupItems/Apache2 chrish$ sudo ./Apache2 start 

2.

You'll be prompted to satisfy a "virtual dependency" with five different candidates:

  • apache2-mpm-worker The standard multiprocessing model (MPM), which uses multiple server processes and multiple threads to service large numbers of requests.

  • apache2-mpm-perchild An experimental MPM, which isn't currently finished. Don't use this.

  • apache2-mpm-prefork This MPM behaves like Apache 1.3, by creating sub-processes to handle requests without using multiple threads. This is useful only if you need to use libraries that aren't thread-safe for an add-on module. I'd suggest fixing the old library instead, but that's a personal preference.

  • apache2-mpm-leader An experimental MPM that uses a Leader/Follower design pattern to coordinate work between threads.

  • apache2-mpm-threadpool An experimental MPM similar to the "worker" MPM, but slower. It uses a pool of idle threads to handle requests.

Press Enter to go with the default (apache2-mpm-worker), unless you want to experiment with one of the unfinished MPMs listed above.

3.

Fink resolves Apache's dependencies, lists the additional packages required to install Apache, and asks, "Do you want to continue? [Y/n]"

Press Enter to install Apache and its dependencies.

4.

cd /Library/StartupItems

Change to the local StartupItems directory.

5.

sudo mkdir Apache2

Create a new directory for our Apache startup script and .plist file.

6.

cd Apache2

Change to our new Apache directory.

7.

sudo ln -s /sw/sbin/apachectl Apache2

Apache kindly includes a startup script (apachectl) that accepts the start, stop, and restart arguments required for a Mac OS X startup script, so all we need to do is put a symbolic link to it here.

8.



 sudo sh -c "sed -e 's/Apache/Apache 2/' < /System/Library/ StartupItems/Apache/ StartupParameters.plist > StartupParameters.plist" 

Copy the StartupParameters.plist that Mac OS X uses with its version of Apache, change "Apache" to "Apache 2" inside, and create our own StartupParameters.plist file (Code Listing 9.4).

You could also use your favorite text editor, but that can be tricky if it happens to be a GUI editor. You'll probably have to save it somewhere and then use a sudo cp command to copy it here.

9.

sudo ./Apache2 start

Launch our new version of Apache. If you've got Apple's Personal Web Sharing active, launching our Apache will fail, because there's already a service (the Personal Web Sharing) running on the default HTTP port.

Tip

  • Mac OS X comes with an old version of Apache (1.3.29) installed and configured as Personal Web Sharing in the Sharing pane of System Preferences (Figure 9.10). The current version of Apache 1.3 is 1.3.33, which fixes several known security issues present in 1.3.29. If you don't want to install and configure Apache 2, 1.3 is stable and well known, despite these minor security vulnerabilities.

    Figure 9.10. Mac OS X's Personal Web Sharing is actually an Apache 1.3 server.



Code listing 9.4. The StartupParameters.plist file for Apache on Mac OS X.
 {   Description = "Apache 2 web server";   Provides = ("Web Server");   Requires = ("DirectoryServices");   Uses = ("Disks", "NFS");   OrderPreference = "None"; } 



    Unix Advanced. Visual QuickPro Guide
    Unix Advanced: Visual QuickPro Guide
    ISBN: 0321205499
    EAN: 2147483647
    Year: 2003
    Pages: 116

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