Overview
This document describes how to start, stop and install Apache on Linux in our classroom. We install and run Apache 2.0 on Red Hat Linux version 7.3. If you want to install at home, you may want to use the instructions from Apache for Linux/Unix or Windows.
If you are unfamiliar with using Linux, try a tutorial such as Linux Survival. If you have some experience using Linux (or UNIX) but need a reference, try the One Page Linux Manual (HTML version).
About Apache
Apache is an open-source HTTP server for modern operating systems including UNIX and Windows NT. It has been the most popular web server on the Internet since April of 1996. The Netcraft Web Server Survey maintains the current rankings of web server usage on Internet connected computers.
On This Page
back to top
Starting Linux in the Class Room
Note: Do not turn on the power before you select the disk drive.
- Before turning on the power, press the middle button of the drive selectors
- Turn on the power
- The computer will boot up into RedHat Linux.
- At the login prompt use:
- Login: cis164
- Password: password
back to top
Starting Apache
The following instructions assume that Apache is installed already. If not, see the Installing Apache section.
- Open a terminal emulation window by clicking the icon in the bottom panel

- Login as the superuser, if you are not already.
su -l root
You will be prompted for the root password
- To start Apache, type the following and press the Enter key:
/usr/local/apache2/bin/apachectl start
After a few moments, the command prompt will return. If no error message is reported, then Apache started successfully.
If SSL is installed and configured, you can instead start Apache and SSL service with:
/usr/local/apache2/bin/apachectl -D SSL -k start
- To test that Apache is working, start your browser and enter into the address bar: localhost
A default test page should appear in your browser. If not, then Apache is not running.
- You can now exit super-user mode, if desired.
exit
Note that you can see the processes that Apache started by using the process status (ps) command:
ps -ef | grep httpd
Any process with the name httpd on the end was started by the Apache server.
back to top
Stopping Apache
The following instructions assume that Apache is installed already. If not, see the Installing Apache section.
- Open a terminal emulation window by clicking the icon in the bottom panel

- Login as the superuser, if you are not already.
su -l root
You will be prompted for the root password
- To stop Apache, type the following and press the Enter key:
/usr/local/apache2/bin/apachectl stop
After a few moments, the command prompt will return. If no error message is reported, then Apache stopped successfully.
- To test that Apache is stopped, start your browser and enter into the address bar: localhost
If the default test page does not appear in your browser, then Apache is stopped.
- You can now exit super-user mode, if desired.
exit
back to top
Installing Apache
- Find the best available version of Apache on the Apache Downloads page.
- Download the Unix Source:
httpd-2.0.44.tar.gz version
Clicking on the link presented on the page will open a downloading window.
- Save the download into your
/home/cis164 directory.
Your home directory provides a convenient location to store files.
- Open a terminal emulation window by clicking the icon in the bottom panel

- Login as the superuser, if you are not already.
su -l root
You will be prompted for the root password.
- Change directory to
/usr/local.
cd /usr/local
- Copy the file you downloaded to the
/usr/local directory.
cp /home/cis164/httpd-2.0.44.tar.gz .
Do not forget to include the dot (.) at the end of the command line.
- Unpack the files and create the directory.
tar xzvf httpd-2.0.44.tar.gz
This will create a directory named httpd-2.0.44.
- Change directory to the installation directory to verify the installation.
cd httpd-2.0.44
You can list the contents of the directory and view files if you like.
- Configure the installation using the default settings.
./configure --enable-mods-shared=most --enable-ssl=shared
You must be in the /usr/local/httpd-2.0.44 directory to run the configuration script. You will see lots of information scroll by as the script runs. If the end of the list does not report an error, then the configuration step completed successfully.
- Compile the source code using the
make utility.
make
Compiling will take about five minutes to complete. All the source code is converted to machine code during this step. If the end of the list does not report an error, then the make step completed successfully.
- Install the configuration using the
make install command.
make install
Installation is much shorter, only about 30 seconds long. If the end of the list does not report an error, then the install step completed successfully.
- Start Apache to test the installation
/usr/local/apache2/bin/apachectl start
- To test that Apache is working, start your browser and enter localhost into the address bar.
A default test page should appear in your browser. If not, then Apache is not running and you should ask the instructor for help.
- You can now exit super-user mode, if desired.
exit
For more information see: Compiling and Installing.
back to top
Installing PHP on Apache
The following instructions assume that Apache is installed already. If not, see the Installing Apache section.
- Download the latest version of PHP from the PHP Downloads page.
- Make certain to get the tar.gz version (e.g. PHP 4.3.1 (tar.gz)
- Save the download into your
/home/cis164 directory.
Your home directory provides a convenient location to store files.
- Open a terminal emulation window by clicking the icon in the bottom panel

- Login as the superuser, if you are not already.
su -l root
You will be prompted for the root password.
- Change directory to
/usr/local.
cd /usr/local
- Copy the file you downloaded to the
/usr/local directory.
cp /home/cis164/php-4.3.1.tar.gz .
Do not forget to include the dot (.) at the end of the command line.
- Unpack the files and create the directory.
tar xzvf php-4.3.1.tar.gz
This will create a directory named php-4.3.1.
- Change directory to the installation directory to verify the installation.
cd php-4.3.1
You can list the contents of the directory and view files if you like.
- Configure the installation using the Apache 2.0 settings.
./configure --with-apxs2=/usr/local/apache2/bin/apxs
You must be in the /usr/local/php-4.3.1 directory to run the configuration script. You will see lots of information scroll by as the script runs. If the end of the list does not report an error, then the configuration step completed successfully.
- Compile the source code using the
make utility.
make
Compiling will take about five minutes to complete. All the source code is converted to machine code during this step. If the end of the list does not report an error, then the make step completed successfully.
- Install the configuration using the
make install command.
make install
Installation is much shorter, only a few seconds long. If the end of the list does not report an error, then the install step completed successfully.
- Create a php.ini file in
/usr/local/lib by copying one from the make directory
cp php.ini-dist /usr/local/lib/php.ini
- Open the Apache
httpd.conf file using an editor such as gedit
gedit /usr/local/apache2/conf/httpd.conf &
- Edit the
httpd.conf file to add the following two lines
LoadModule php4_module modules/libphp4.so
AddType application/x-httpd-php .php
Adding these lines after the other LoadModule statements is a good location.
- Save the file and restart Apache to test the installation
/usr/local/apache2/bin/apachectl stop
/usr/local/apache2/bin/apachectl start
- To test that PHP is working, create a file named
hello.php in the document root directory
gedit /usr/local/apache2/htdocs/hello.php &
Go ahead and let gedit create the file.
- Save the following code in the
hello.php file
Cannot find file: /home/edparr2/public_html/cis164/03s/supplements/hello.php
- Start your browser and enter localhost/hello.php into the address bar.
A page showing "Hello PHP World!" should appear in your browser. If not, then PHP is not running and you should ask the instructor for help.
- You can now exit super-user mode, if desired.
exit
For more information see: Servers-Apache 2.0.
back to top
Home
| WebCT
| Announcements
| Schedule
| Expectations
| Syllabus
| Help
| FAQ's
| HowTo's
| Links
Last Updated: 7/16/2003 4:45:32 PM
|