tonywhitmore.co.uk  

      blog : gallery : wiki : articles : projects : shell scripts : wallpaper : cv : links :
 Project Homepage

Apache
Apache Logo

Preparation

  1. Download the Apache source code from httpd.apache.org.
    • Visit httpd.apache.org and click on the "Download: from a mirror" link.
    • You will be asked to choose a mirror site to use. Choose one closest to you.
      • This example uses an HTTP mirror, rather than an FTP mirror.
    • Click on the link for the source code of the latest version of Apache. You will need the source code in .tar.gz format.
      • At the time of writing the latest version of Apache was version 2.0.40, so the file downloaded was httpd-2.0.40.tar.gz.
    • You will be asked to where you wish to save the file. Chose a safe place and make a note of it.
    • The download is about 4.5Mb and will take at least half an hour over a modem, but a lot less over a broadband connection.
    • If you are using a download accelerator program, it will save the file to your default download directory.
    • Burn the file httpd-2.0.40.tar.gz and your webpages to a CD. This page assumes that the subdirectory /apps is used for the .tar.gz file and that the subdirectory /html is used for the webpages. The CD-ROM can be a multi-session disk.
      • Use your CD burning software to create an ISO9660 disc image with the file httpd-2.0.40.tar.gz in the /apps directory.
      • Put your webpages in a directory called /html on the CD.
      • Burn the CD and verify the data stored on it.

Back to simple version

Booting

  1. Boot your Core Linux PC.
  2. Login as root. You will need to enter the password at the prompt.
    • Wait for the following text to appear:
      localhost login:
    • Type root and press Enter.
    • The screen will display this message:
      Password:
    • Enter the password for root that you set earlier.
    • You will be shown a prompt that looks like this:
      [~]#

Back to simple version

Extract the source

  1. Place the CD-R in the CD-ROM drive. Mount the CD-ROM drive under /mnt/cdrom.
    • At the prompt enter:
      mount /dev/hdb /mnt/cdrom
    • You will see the following line appear:
      mount: block device /dev/hdb is write-protected, mounting read-only
  2. Change to the /apps directory on the CD-R.
    • At the prompt enter:
      cd /mnt/cdrom/apps
    • The prompt will change to:
      [/mnt/cdrom/apps]#
  3. Copy the httpd-2.0.40.tar.gz file to the directory /usr/src.
    • At the prompt enter:
      cp httpd-2.0.40.tar.gz /usr/src
    • The system will not display a message if everything is OK.
  4. Change to the /usr/src directory and extract the source from the .tar.gz file.
    • At the prompt enter:
      cd /usr/src
    • The prompt will change to:
      [/usr/src]#
    • At the prompt enter:
      tar -zxvf httpd-2.0.40.tar.gz
    • A long stream of unzipping files and directories should scroll up the screen for a few seconds.

Back to simple version

Configure and compile

  1. Change to the /usr/src/httpd-2.0.40 directory.
    • At the prompt enter:
      cd httpd-2.0.40
    • The prompt will change to:
      [/usr/src/httpd-2.0.40]#
  2. Run the ./configure script.
    • At the prompt enter:
      ./configure
    • N.B. If you wish the software to be installed in a directory other than the default directory of /usr/local/apache2 then use the alternative command:
      ./configure --prefix=PREFIX
      where the word PREFIX is replaced by your alternative directory path.
    • A long stream of processes should scroll up the screen for about two mintues.
    • The script finishes with the line:
      config.status: executing default commands
  3. Run the make program.
    • At the prompt enter:
      make
    • A long stream of processes should scroll up the screen for about two mintues.
    • The program finishes with the line:
      make[1]: Leaving directory '/usr/src/httpd-2.0.40'
  4. Run the make program with the argument install.
    • At the prompt enter:
      make install
    • A long stream of processes should scroll up the screen for about a minute.
    • The program finishes with the line:
      make[1]: Leaving directory '/usr/src/httpd-2.0.40'

Back to simple version

Initial Testing

  1. Add the user nobody.
    • At the prompt enter:
      useradd nobody
    • The system will not display a message if everything is OK.
  2. Start the Apache webserver using /usr/local/apache2/bin/apachectl start.
    • At the prompt enter:
      /usr/local/apache2/bin/apachectl start
    • The following message will appear on the screen:
      httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
  3. Using your other computer, see if you can access the web server.
    • Launch your web browser.
    • In the address bar type the IP address of your Core Linux PC. In the installation guide the Core Linux PC was set up with the IP address 192.168.0.10. The line entered should read:
      http://192.168.0.10
    • Press Enter.
    • Your web browser should load a page with the title "Test Page for Apache Installation":
  4. If the test page loaded successfully then you have correctly compiled and installed the Apache webserver. You may want to spend some time browsing the site to learn about more advanced configuration of the Apache webserver.

Back to simple version

Setting up Apache

  1. Change to the /usr/local/apache2/conf directory.
    • At the prompt enter:
      cd /usr/local/apache2/conf
    • The prompt will change to:
      [/usr/local/apache2/conf]#
  2. Backup httpd.conf to httpd.conf.bak
    • At the system prompt enter:
      cp httpd.conf httpd.conf.bak
    • The system will not display a message if everything is OK.
  3. Edit the httpd.conf file.
    • At the prompt enter:
      nano httpd.conf
    • The screen will show the contents of httpd.conf with information about the file at the top and bottom of the screen. The file is 1036 lines long.
    • Navigate the file using the arrow keys.
  4. Configure the Server Name. If you are planning to access your webserver using only its IP address then you do not need to complete this stage. Also, you will not be able to access your webserver using the specified address just be including in the configuration file. As there will be no DNS servers referencing it, no potential clients will be able to convert find the IP address for your machine from the given Server Name.
    • Press Ctrl+w on the keyboard.
    • The white text bar at the bottom of the screen will change to read:
      Search:
    • Enter the search string:
      ServerName
    • Press Enter.
    • The screen will change to show the first occurance of the search string in the file.
    • Scroll down 11 lines using the down arrow to find the following line:
      #ServerName new.host.name:80
    • Remove the # symbol from the beginning of the line.
    • Change the text to reflect the FQDN of your webserver.
  5. Configure the Server Admin e-mail address.
    • Press and hold PageUp until you return to the top of the document.
    • Press Ctrl+w on the keyboard.
    • The white text bar at the bottom of the screen will change to read:
      Search:
    • Enter the search string:
      ServerAdmin
    • Press Enter.
    • The screen will change to show the first occurance of the search string in the file.
    • Scroll down 4 lines using the down arrow to find the following line:
      ServerAdmin you@your.address
    • Change the dummy e-mail address you@your.address to your e-mail address.
    • Press Ctrl+w on the keyboard.
    • The white text bar at the bottom of the screen will change to read:
      Search:
    • Enter the search string:
      ServerSignature
    • Press Enter.
    • The screen will change to show the following line:
      ServerSignature On
    • Change the line to read:
      ServerSignature Email
  6. Configure the user and group as which Apache will run.
    • Press and hold PageUp until you return to the top of the document.
    • Press Ctrl+w on the keyboard.
    • The white text bar at the bottom of the screen will change to read:
      Search:
    • Enter the search string:
      User
    • Press Enter.
    • The screen will change to show the first occurance of the search string in the file.
    • Scroll down 11 lines using the down arrow to find the following line:
      User nobody
    • Change the line to:
      User httpd
    • Scroll down 1 line using the down arrow to find the following line:
      Group #-1
    • Change the line to:
      Group httpd
  7. Configure the Document Root. This is the directory from which your webpages will be served. The default location is the location of the "Test Page for Apache Installation" files.
    • Press and hold PageUp until you return to the top of the document.
    • Press Ctrl+w on the keyboard.
    • The white text bar at the bottom of the screen will change to read:
      Search:
    • Enter the search string:
      DocumentRoot
    • Press Enter.
    • The screen will change to show the first occurance of the search string in the file.
    • Scroll down 4 lines using the down arrow to find the following line:
      DocumentRoot "/usr/local/apache2/htdocs"
    • Change the line to reflect the directory from which you wish your website to be served. This example uses the following directory:
      /home/httpd/html
  8. Save the file and exit the text editor.
    • Press Ctrl+x on the keyboard.
    • The contents of the white line at the bottom of the screen will change to read:
      Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
    • Type y.
    • The contents of the white line at the bottom of the screen will change to read:
      File Name to write: httpd.conf
    • Press Enter.
    • You will be returned to the system prompt.

Back to simple version

Creating the Document Root

  1. Change to the /home directory.
    • At the prompt enter:
      cd /home
    • The prompt will change to:
      [/home]#
  2. Create the directory httpd/html.
    • At the prompt enter:
      mkdir -p httpd/html
    • The system will not display a message if everything is OK.
  3. Add the user and group httpd.
    • At the prompt enter:
      groupadd httpd
    • The system will not display a message if everything is OK.
    • At the prompt enter:
      useradd -M -g httpd httpd
    • The system will not display a message if everything is OK.
  4. Change the ownership of the /home/httpd directory to the user httpd and the group httpd.
    • At the prompt enter:
      chown -R httpd:httpd /home/httpd
    • The system will not display a message if everything is OK.
  5. Change the access permissions of the /home/httpd directory to 0755.
    • At the prompt enter:
      chmod 0755 /home/httpd /home/httpd/html
    • The system will not display a message if everything is OK.

Back to simple version

Copying the webpages

  1. Copy the webpages from the CD-R to the Document Root directory.
    • At the prompt enter:
      cd /mnt/cdrom
    • The prompt will change to:
      [/mnt/cdrom]#
    • At the prompt enter:
      cp -rf html /home/httpd
    • The system will not display a message if everything is OK.
  2. Change to the /home/httpd/html directory.
    • At the prompt enter:
      cd /home/httpd/html
    • The prompt will change to:
      [/home/httpd/html]#
  3. Change the ownership of the files in the /home/httpd/html directory to the user httpd and the group httpd.
    • At the prompt enter:
      chown -R httpd:httpd *
    • The system will not display a message if everything is OK.
  4. Change the access permissions of the files in the /home/httpd/html directory to 0755.
    • At the prompt enter:
      chmod -R 0755 *
    • The system will not display a message if everything is OK.

Back to simple version

Checking and restarting Apache

  1. Check the syntax of your edited httpd.conf file using /usr/local/apache2/bin/apachectl configtest.
    • At the prompt enter:
      /usr/local/apache2/bin/apachectl configtest
    • The following message will appear on the screen:
      Syntax OK
  2. Restart Apache using the command /usr/local/apache2/bin/apachectl restart.
    • At the prompt enter:
      /usr/local/apache2/bin/apachectl restart
    • The system will not display a message if everything is OK.
    • If you skipped the section on initial testing, then you will not have started server yet, and the screen will display will show the following:
      httpd not running, trying to start

Back to simple version

Stopping Apache

  1. Stop the Apache webserver using /usr/local/apache2/bin/apachectl stop.
    • At the prompt enter:
      /usr/local/apache2/bin/apachectl stop
    • The system will not display a message if everything is OK.

Back to simple version

Automating Apache

  1. Append the following line to the /etc/rc.d/rc.mu script:
    /usr/local/apache2/bin/apachectl start
    You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.mu
    • The screen will show the contents of /etc/rc.d/rc.mu with information about the file at the top and bottom of the screen.
    • Add the following text to the end of the file:
      # Start Apache
      /usr/local/apache2/bin/apachectl start
      echo Apache Started
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.mu
      • Press Enter.
      • You will be returned to the system prompt.
  2. Insert the following line at the second line of the /etc/rc.d/rc.rb script:
    /usr/local/apache2/bin/apachectl stop
    You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.rb
    • The screen will show the contents of /etc/rc.d/rc.rb with information about the file at the top and bottom of the screen.
    • Insert the following text at the second line of the file:
      # Stop Apache
      /usr/local/apache2/bin/apachectl stop
      echo Apache Stopped
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.rb
      • Press Enter.
      • You will be returned to the system prompt.
  3. Insert the following line at the second line of the /etc/rc.d/rc.ha script:
    /usr/local/apache2/bin/apachectl stop
    You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.ha
    • The screen will show the contents of /etc/rc.d/rc.ha with information about the file at the top and bottom of the screen.
    • Insert the following text at the second line of the file:
      # Stop Apache
      /usr/local/apache2/bin/apachectl stop
      echo Apache Stopped
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.ha
      • Press Enter.
      • You will be returned to the system prompt.
  4. Reboot the system and check that Apache is running.
    • At the system prompt enter:
      shutdown -r now
    • Wait for the system to reboot.
    • As the system reboots, watch for any error messages.
    • Once the system has rebooted, try to access the webserver using the web browser on your other PC.

Back to simple version

Creative Commons License
The text of this page is licensed under a Creative Commons License.


Valid CSS!     Valid HTML 4.0!     Valid RSS
Original design © For oswd.org by SquireCD