Deprecated: Function eregi() is deprecated in /home/keeline/public_html/ITeachPHP.com/index.php on line 126
Deprecated: Function eregi() is deprecated in /home/keeline/public_html/ITeachPHP.com/index.php on line 126 Installing Red Hat Linux 7.2 with PHP & MySQL
Installing Red Hat Linux 7.2 with Apache, MySQL, and PHP
This tutorial is not intended to replace a full installation guide to these
products. There are excellent sources of documentation available in print
and online. However, this list of steps may assist in organizing your
efforts into a plan which will hopefully work the first time. If you run
into particular difficulties, bring your system (including computer, keyboard,
mouse, and monitor) to one of the monthly "Linux Installfests" which
are offered by the Kernel-Panic Linux User Group (http://www.kernel-panic.org/).
These are held on the Saturday after the group's normal meeting (second Thursday
of the month) in National City at the National City Adult Education center.
There is a map and additional information on the K-P site.
Step 1: Get the software
The first step is to obtain CD-ROMs with the latest versions of the Linux
operating system and support software. These may be purchased from
stores like Fry's or CompUSA in boxed sets with instruction books and varying
levels of support. Some packages offer e-mail support and others have
telephone support. The packaged editions will have from two to nine discs. The
operating system software is on the two binary discs. You can order these
from the Red Hat site as well (http://www.redhat.com).
It is also possible to download the disk images from the Red Hat site.
These are free to download and copy. The Kernel-Panic group sells
copies of these discs for $5 for a 2-disc set at the regular meetings and sometimes
at the installfests.
Because they may be copied, book publishers will often include them in their
books on Red Hat Linux. The current version as of this writing is
7.2 and since some of the instructions are specific to this installation, it
would be simplest to make sure you have that version on hand.
Step 2: Check your system
The next step is to check your hardware. You should have a minimum
of a Pentium I with a clock speed of 100 MHz and at least 48 MB of RAM (the
"graphical" install requires 64 MB). Your hard drive should
have at least 2 GB available. These specifications mean that it is very
possible to run Linux effectively on a "legacy" machine which is five
or so years old. These can sometimes be purchased very inexpensively
as used computers since they don't run the current versions of Windows very
You will need to consider how you will connect to the Internet. The
best way to do this is with a high-speed connection (ie DSL or Cable Modem).
In either of these cases, the modem is connected to the jack supplied by your
broadband provider. The connection to your computer or home network
is achieved through an Ethernet 10BaseT RJ45 connector. This looks like
a thick wire with an extra-wide phone cord connector. If you have several
computers and you wish to share the connection but you only have one static
or dynamic IP address, you may want to consider getting a router such as the
Netgear RT-314 or something similar. Most Ethernet cards will work with
Linux but there is a chance that a very cheap one will not. You can check
the Red Hat site for a list of compatable hardware.
If you are connecting via a modem, you will need to determine if the modem
you have is a real full modem or what is referred to as a "win modem".
These don't work well with Linux because much of the functionality is emulated
with software in Windows.
You can make your system into a "dual boot" which means that when
the computer starts up, a program called LILO (Linux Loader) will ask you which
system you want to boot for a given session. Before you install Linux
on a system which already has Windows 95 or 98 (Windows NT 4.0, Windows ME,
Windows 2000, and Windows XP require special instructions. This is a great project
for the Linux Installfests held by Kernel-Panic.), make sure you defragment
the hard drive to move all of the data to the "bottom" of the hard
disk. This will make it easier to partition.
Step 3: Start the installation process
Rather than detail the entire installation process, this guide will give some
suggestions which you may want to consider.
If permitted by your BIOS settings, configure your system to boot from the
CD-ROM device first, followed by the floppy and primary hard drive. Most
systems require that you press F2, F10, or the Delete key during the Power-On
Self Test (POST).
After this is done, insert the first Red Hat binary disc and boot (or reboot
with Ctrl-Alt-Delete) the computer. A text screen will be displayed with
several options. If you press Enter, the system will start a graphical
installation. Type text and press Enter to begin a text install.
The system will take a few moments to load the Linux operating system and the
installer program. Choose the installation language of your choice and
select a "Custom" installation.
Step 4: Set your hard disk partitions
When you are asked to partition your disk, use Disk Druid since it is easier
to understand than fdisk for Linux. It's a good idea to place the following
Linux directories in their own partition. For sizes, I will assume that
you have an 8GB hard disk. You can refer to the documentation to determine
the minimum sizes.
Typically, you will want to delete any existing partitions. However,
exceptions to this can arise. For example, in a dual boot system, you
would not want to delete the partition(s) holding your Windows data. These
are usually identified as vfat or fat (ie FAT32 or FAT16 for Windows 3.x, 95,
98, ME) or ntfs (for Windows NT, 2000, XP). In some systems (ie Compaq),
a small hard drive partition may contain programs which are used to edit the
Red Hat 7.2 includes options to use the ext3 filesystem. The ext2 filesystem
has been the default for Linux for many years. As you would imagine, ext3
includes new features, the most important of which is that it is a "journaling"
filesystem. Essentially, what this means is that a logfile of disk writes
is made (similar to what databases do during transactions). The advantage
of this is that if the system loses power, it can recover without the extensive
filesystem checks usually required for ext2. It is possible to convert
and ext3 filesystem to a non-journaling version which is compatable with ext2.
In this installation, use ext3.
This partition holds the essential files needed to boot the system such
as the Linux kernel (vmlinuz). It must be a primary partition.
This is usually about 10-30 MB. The small size makes it faster
to check when the system goes down because of a power outage, especially
with the ext2 filesystem.
This is not really a directory but a place on the hard disk to be used
when the system's RAM becomes tight. It is comparable to "Virtual Memory"
in the MacOS or Windows. There is much debate about the size which should be used but a decent rule of thumb is twice the amount of your physical
RAM. It is usually a good idea to make this a primary partition.
This is a very active directory because it contains logfiles, mail spools,
MySQL databases, web pages (by default), and print spools. since a Linux
filesystem can be brought to a halt if it runs out of disk space, it's a good
idea to give this region a set amount of space and a partition accomplishes
this nicely. You can also use some extended attributes in the Linux ext2
filesystem to help safeguard these files (see man lsattr for
details). A good size for this partition is 1 GB for most systems.
This is the place where each user's files are located. For the same reason
as /var it is a good idea to have this on a separate partition. An added
benefit is that if you are installing a new operating system and you know
which device identification (ie /dev/hda5) is used for the /home directory,
you can elect to not format and erase it during the install process.
This can be 1 GB.
This directory is not used on all systems but it is convenient to place
the main web files in a specific location and to make sure that no file uploaded
or created becomes so large that it fills the file space. Depending
on your needs, this can be 1-2 GB.
This section will include all of the remaining directories used by the system.
For this partition, select "grow to fill" on the dialog box. The data
in this section will take about 1GB depending on the packages you elect
Step 5: Choose a boot loader
In past versions of Linux, the main choice for a boot loader was LILO (Linux
Loader) . This program had certain limitations in early versions which
made it difficult to use large hard drives. With Red Hat 7.2, a new option
is available for a boot loader, GRUB (Grand Unified Bootloader). It is
said to be easier to configure than LILO so its use is recommended.
In most configurations, it is appropriate to place the boot loader in the Master
Boot Record (MBR), a special place at the beginning of the hard drive which
is checked by the hardware when the computer is turned on. An exception
to this is when you are trying to make a dual boot system with WindowsNT, 2000,
or XP since these operating systems also want to have control of the MBR.
If you want to create such a system, bring your hardware (with the hard drive
defragmented and Windows installed ahead of time) to one of the Kernel-Panic
Step 6: Set up your network interface(s)
If you have one or more Ethernet cards which are recognized by the installer,
you will be presented with a page to configure them. If you know you will
be using DHCP, you can use the defaults. Otherwise, you will have to supply
the IP address, netmask, and name servers for your location.
If you will only occasionally have your computer connected to a network
(ie: you don't have a network at home or the computer is a laptop with an
Ethernet network adapter), you can "disable" the network connection on boot
and then activate it when it is needed. Generally, Red Hat 7.2 is better
about quickly failing if DHCP is chosen and no network is connected.
Red Hat 7.l could take a minute or longer to fail to find the network.
Step 7: Set your firewall rules
When you are asked to set firewall rules, select "Medium" and then
"Customize". The list below will help you to select appropriate
servers as ports which may receive outside input.
This is the File Transfer Protocol server. it is needed if you will
allow outside FTP connections to your computer. It is better to use
a more secure replacement for the FTP server, like ProFTPD.
Better still, use the scp feature of the sshd
This is the secure replacement for telnet (port 23 below). Traffic
in both directions is encrypted. If you need shell access from outside
your box, this is a good way to do it. A client will need a telnet
program with secure shell capabilities such as ssh or ssh2
on Linux or Unix, Nifty Telnet ssh on the Macintosh, or Putty
Ensure that you are using a recent version of sshd (the version in Red Hat
7.2 is ok). SSH protocol 1 had security flaws.
This is the old way to establish shell access to a system. It is
highly insecure and not recommended.
This is the server used to receive Simple Mail Transport Protocol mail.
In most cases, you will use POP-3 (110) or IMAP (143) to get your mail.
This is needed if your computer will be acting as a DHCP (Dynamic Host
Control Protocol) server. It is not needed if you are using another
machine or device (like a router) as a DHCP server.
This is the Apache web server and you must allow outside traffic to display
This is the way to add SSL (Secure Socket Layers) transaction capability
to your web sites. You will need to add this in the text field below
Step 8: Select your packages
Since we will be adding Apache, MySQL, PHP and Perl separately, do not select
them when selecting the packages to be installed. The following packages
may be desirable on your system if you want to have both a server and some of
the X-Window Graphic User Interface programs.
Use this only if you plan to run a printer from Linux.
It has had security problems in the past.
X Window System
This is needed for the Graphic User Interface programs.
This is a popular desktop manager (you can also install KDE).
This is another popular desktop manager.
Needed to use your Ethernet card to connect to a LAN, DSL,
Needed if you use a phone modem (not a WinModem).
Graphics & Image Manipulation
Very helpful with PHP. Includes the GD library where
PHP can dynamically generage graphics if desired. Also includes The
GIMP, a Photoshop-like image manipulation tool.
This is the NNTP (Network News Transfer Protocol) server.
It is used to let your machine act as a Usenet server. Use it only
if you really intend to.
NFS File Server
This is Network File System which lets other Linux or Unix
computers on your network access portions of your file system as if it were
part of their own. It has had security problems in the past; use it
only if you really need it.
Windows File Server (Samba)
This is a server which will let Windows computers on your
network share files and printers which are part of your Linux system.
Anonymous FTP Server
This package includes the default WU-FTPD server for File
Transfer Protocol. Because of past security problems, it is better
to use a replacement such as ProFTPD.
SQL Database Server
This group has both MySQL and PostgreSQL database servers
and clients. We will install the MySQL client and server manually.
This is the Apache web server. We will install it manually.
Router / Firewall
This is used if your Linux computer will act as a firewall
(with two network cards). There is a kernel-level firewall that we
DNS Name Server
This is the Domain Name Server, BIND 9.1, which should only
be used if you plan to host domains on this computer. Most security
specialists recommend having DNS run on a separate computer.
Network Managed Workstation
Not needed for our purposes.
Authoring and Publishing
Includes the TeX desktop publishing system and various utilities.
This is a very complex text editor and programming environment.
It even includes several games and a Mayan calendar. Use it if
you know it. Many users prefer the simpler vi editor.
Contains many useful programs, including ones which make it
easier to read and write MS-DOS floppy disks.
Legacy Application Support
Not needed for our purposes.
This has all of the C, C++, and Fortran compilers and utilities
needed to compile programs from source code (ie *.tar.gz files).
This mainly includes source code for the Linux Kernel and
is needed if you will recompile the Kernel.
Windows Compatability / Interoperability
Windows Emulator (WINE).
Games and Entertainment
Games? Who needs them?
Other packages not in this list may be installed or not based
on your discretion.
Step 9: Wait for system to install
Depending on the number of packages you chose to install and your hardware,
the process can take 15-45 minutes. Now's a good time to go get a cup
of coffee and read the descriptions of each package being installed so you will
have a sense of what is there. After the packages are installed, you will
be asked to make a boot disk. This is a very good idea.
If your system crashes and won't start up, you can use this 3.5 inch floppy
to get the system started. If you forget your root password, the only
way you can change it is to reboot and type linux single at the
LILO: prompt. You will then be logged in as root and can change the
password with the passwd root command. Restart the system
with the shutdown -r now command.
Step 10: Restart and Log In
After all of the packages have been installed and you make your boot disk,
you will then be told to allow the computer to be restarted. This will
take a couple of minutes. You will see the various servers shut down and
then when the system restarts, you will see them come up again.
After the restart, log in as root.
If you are at the console (ie the actual computer keyboard and monitor),
you can login as root with the appropriate password. However, under
most circumstances, you should log in as an ordinary user and then use su
- to elevate your permissions to those of the administrative user.
In this example, using the dash after the su command causes you
to get root's system environment, otherwise you will inherit the environment
of the user which made the main log in.
Step 11: Gather needed RPM packages
The Red Hat Package Manager is a great way to install binary distributions
of programs. You can use RPM Find (http://www.rpmfind.net/)
to look for packages if they are not on your distribution disks or you want
a more recent version. In our case, all of the packages we need may be
found on the two discs.
You can insert the first Red Hat CD-ROM in your system. After the drawer
is closed, you will need to mount the CD-ROM's file system to make it available
to your Linux system. This is accomplished with the mount /mnt/cdrom
command. Normally, this command would require many more parameters.
However, there are definitions in the /etc/fstab (File System Table)
file which take care of the details and let us use an abbreviated command.
Once the CD-ROM is mounted, a message will usually appear on the command line.
To view the contents of the CD-ROM, we can type the ls -laG /mnt/cdrom
command to list the directories and files at the top level of the CD-ROM file
Red Hat 7.2 has an error which causes the system to forget
how to communicate with the CD-ROM drive. You will note that when you perform a
lsmod command that no mention is made of the CD-ROM drive. The way
to solve this on a temporary basis is to run the command insmod cdrom
which will install the CD-ROM driver code for this session. To make this more
permanent, place the insmod cdrom line as the last line of the
/etc/rc.local file. Although this is perhaps not the very best way
to achive this result, it does work and this approach will work on other types of
problems such as Red Hat 7.1's inability to remember the network gateway.
The files we want are located in a sub directory so we will change to it with
the cd /mnt/cdrom/RedHat/RPMS/ command. The files we want
-rw-r--r-- 1 root 532728 Feb 6 10:04 apache-1.3.20-16.i386.rpm
-rw-r--r-- 1 root 368260 Feb 6 10:04 apacheconf-0.8.1-1.noarch.rpm
-rw-r--r-- 1 root 735582 Feb 6 10:15 libodbc++-0.2.2pre4-12.i386.rpm
-rw-r--r-- 1 root 1215300 Feb 6 10:06 php-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 628202 Feb 6 10:03 php-imap-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 29378 Feb 6 10:03 php-ldap-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 29049 Feb 6 10:03 php-pgsql-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 790030 Feb 6 10:28 unixODBC-2.0.7-3.i386.rpm
Since we are in this directory, we can copy them to root's home directory (/root)
with the following commands:
We now need to insert the second CD-ROM. First, we must change directory
to the top level (cd /). Now we can unmount the CD-ROM file
system (note the spelling!) with the umount /mnt/cdrom command.
Next we need to change into the RPM directory again with the cd /mnt/cdrom/RedHat/RPMS/
command. The files we want from here are:
-rw-r--r-- 1 root 120645 Feb 6 10:10 apache-devel-1.3.20-16.i386.rpm
-rw-r--r-- 1 root 607803 Feb 6 10:10 apache-manual-1.3.20-16.i386.rpm
-rw-r--r-- 1 root 461825 Feb 6 10:10 libodbc++-devel-0.2.2pre4-12.i386.rpm
-rw-r--r-- 1 root 529064 Feb 6 10:11 libodbc++-qt-0.2.2pre4-12.i386.rpm
-rw-r--r-- 1 root 1496174 Feb 6 10:51 lynx-2.8.4-17.i386.rpm
-rw-r--r-- 1 root 4837190 Feb 6 10:11 mysql-3.23.41-1.i386.rpm
-rw-r--r-- 1 root 124580 Feb 6 10:11 mysqlclient9-3.23.22-6.i386.rpm
-rw-r--r-- 1 root 461825 Feb 6 10:11 mysql-devel-3.23.41-1.i386.rpm
-rw-r--r-- 1 root 877039 Feb 6 10:11 mysql-server-3.23.41-1.i386.rpm
-rw-r--r-- 1 root 155043 Feb 6 10:10 php-devel-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 1235218 Feb 6 10:10 php-manual-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 29200 Feb 6 10:10 php-mysql-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 35695 Feb 6 10:10 php-odbc-4.0.6-7.i386.rpm
-rw-r--r-- 1 root 550127 Feb 6 10:32 unixODBC-devel-2.0.7-3.i386.rpm
-rw-r--r-- 1 root 123752 Feb 6 10:32 unixODBC-kde-2.0.7-3.i386.rpm
As before, we can copy them to root's home directory (/root) with the following
If we have not installed the X Window system, we will want to delete the apacheconf
RPM file. Also, since we are not installing PostgreSQL (another client-server
RDBMS) we must delete the php-pgsql RPM file.
rm apacheconf* rm php-pgsql* /root
Step 10: Install the RPM files
At this point, we have all of the RPM files which contain the programs we
want to install. We should change to root's home directory with the cd
/root command. We can install them all at once with the rpm
-Uvh *.rpm command. With this command, the capital "U"
means update the package. The lowercase "v" means
show a list of all packages installed. The "h"
will cause "hash" marks (#) to show the install progress.
Some packages you may wish to install may require that other packages be installed
first. This concept is known as a dependency.
Step 11: Start and test the MySQL server
MySQL is installed but it is not started automatically. We can make
sure it is installed by executing a whereis mysql command.
This will tell us where the MySQL client application and the documentation is
stored. If we try to start the MySQL client with the mysql
command, we will get a cryptic message which tells us that the server is not
running. In Red Hat Linux we can use service mysqld start
to start the server. Now if we try to start the MySQL client (mysql),
In the MySQL client we can perform simple commands such as show databases;
and use mysql; and show tables; and describe
db; to test our implementation. The exit command leaves
the MySQL client application.
Step 12: Start and test the Apache web server
Now we want to test the Apache web server. As with MySQL, it is there
but hasn't been started yet. We can use the whereis httpd
command to find the executable programs and documentation. The web server
is now known as Apache but to the system it has the simple name of httpd (Hypertext
Transaction Protodol Daemon). We can test to see if it is running by using
a text-based web browser called Lynx using the lynx localhost command.
Since it is not running, as with MySQL, we can use the service httpd start
command to get it running. Now when we use lynx localhost
we get the default web page.
Step 13: Test PHP
PHP is an Apache module (mod_php) and to test it we have to write a program
with PHP code and see if it works. The default location for web pages
with this version of the web server is /var/www/html and we can
use the cd /var/www/html command to get to that directory (we can
change this location later in the Apache configuration file /etc/httpd/conf/httpd.conf).
We will use our favorite text editor (vi or pico)
to create a simple PHP page called test.php with the following
Now we can test this with Lynx using the lynx localhost/test.php
command. If the file was stored in the correct location, we should see
the PHP information page which was generated with the phpinfo()
With that working, we want to test to make sure that we can access the MySQL
database. We can do this fairly simply:
When we look at this with lynx localhost/test.php the print message
in large letters will appear only if a database connection could be established.
Step 14: Designate servers which will start upon boot
We have manually started the servers but in order to cause them to start automatically
during the boot process, we can use a system utility called ntsysv
to indicate the servers we want started. We will also use this opportunity
to make sure that we only run the servers which are essential for our system.
This is important for security. Below is a list of the servers we want
to be on and a brief description. For this setup, all others should be
This is a scheduler for computers which are not left on all
This is a one-time scheduler.
This is the main scheduler for a Linux or Unix system.
Many maintenance tasks are performed on a regular basis, such as rotating
logfiles on a weekly basis.
This is the Apache web server.
This is the old way to create an internal firewall.
This is the new way to create an internal firewall.
This is the hardware server which checks for new equipment
installed at boot.
The relational database server we will use.
Needed for ordinary operations and to offer our web pages
to the World.
This is a random number generator used for other system tasks,
including generating password hashes.
Needed if we are going to receive mail from outside the system.
This is the Secure Shell server, a replacement for the insecure telnet
This server generates log files for the system. If your system gets
hacked, this is one of the first things the hacker turns off.
This is the File Transport Protocol server and is needed if we will accept
files from the outside. Note, however, that sshd has
a secure file transfer protocol called scp and it should be
used if possible.
This is the font server for the X-Window system. If you are not
running X-Window, you will not need it.
This is a meta server for other servers. It will start a server
if a request comes in and the requests meets the rules set in files in /etc/xinetd.d/
for IP address, time of day, and service.
Other servers should generally be off for a secure system
unless you are certain that you need them.
Step 15: Restart the computer and test again
To make sure that the proper servers will come up after restart, as root we
can use the shutdown -r now command to reboot the computer.
Once it is up again, we can log in again and as an ordinary user we can use
the ps ax | less command to look through the list of running processes
to make sure that MySQL and Apache are running. Another way to achieve
this is with the following commands:
ps ax | grep httpd
ps ax | grep mysqld
This will list the processes which contain those phrases (httpd
and mysqld) in the description lines. We could also repeat
the tests in steps 11-13 but we should not need to start the servers.
Note that most servers can also be restarted (needed after a change to a configuration
file) with the service server_name restart command.
Step 16: Congratulate yourself
If everything has worked, you have a server with PHP, MySQL, and Apache installed.
Warning: date(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /home/keeline/public_html/ITeachPHP.com/index.php on line 132