Karakas Online

3.6.5. Apache, PHP and MySQL on Red Hat Linux

For some obscure reason, Red Hat 8.0 does not connect the PHP package to that of MySQL and we have to resort to some tricks to make them work together. Thus, for Red Hat, you have to proceed as follows:

If Apache, PHP and MySQL are not already installed, install the appropriate packages. For Red Hat 8.0, choose the "Packages" menu entry as shown in Figure 3-22.

Figure 3-22. Red Hat Menu: Packages.

Red Hat Menu: Packages.

Red Hat Menu: Packages.



Once you have entered the system (as root), you can choose the three necessary pieces (Apache, PHP and MySQL):

To see what is contained in each section, click on the "Details" link (Figure 3-23).

Figure 3-23. Red Hat: Package Sections.

Red Hat: Package Sections.

Red Hat: Package Sections.



After the selection of packages, you must click on "Update" and Red Hat will go on to install them, after it has checked their dependencies.

Now, Apache, PHP and MySQL are installed, but unfortunately, we are not yet done: we must ensure that PHP will talk to MySQL. To this end, we must do 2 things:

  1. Edit the php.ini file, so that PHP supports also files that start with "<?" - and not only those that start with "<?php".

  2. Install the mysql.so file.

We recall that, in order to edit a system file, we must be root. We can nevertheless do our edits without logging out first, if we do the following:

The only thing that remains now, is to restart the services. We can do this from the command-line of a terminal window and also through a graphical tool. For the novice user, we will describe the graphical way - again, an advanced user will know how to do this from the command-line (see GNU/Linux Command-Line Tools Summary for a compact summary of command-line tools in Linux).

Figure 3-24. Red Hat: Service Configuration Panel.

Red Hat: Service Configuration Panel.

Red Hat: Service Configuration Panel.



The activation or restart of the service we are interested in takes place by selecting the appropriate entry for that service in the Service Configuration Panel (httpd is the service for Apache, while mysqld is the service for MySQL), then click on "activate" or "restart" respectively (Figure 3-24).

Note that in order for our changes in PHP to take effect, we will have to restart Apache.

Now you can connect to your server by pointing your browser to http://localhost or to http://127.0.0.1.

Tip Apache and the hosts file
 

If the Apache service does not start, it may be because it cannot resolve "localhost" correctly. This name for the local computer is given the IP address 127.0.0.1 in the hosts file (usually under /etc). You can try to change

127.0.0.1 localhost.localdomain localhost

in /etc/hosts to:

127.0.0.1 dhcppc0 localhost.localdomain localhost

The folder that is expected to hold the HTML files is again /var/www/html. Note that, again, in order for the normal user to be able to modify the HTML files, you will have to change the permissions of that folder to 777 (see Section 3.2.3).

It is also comfortable to create a link to that folder on the client's desktop, so that he does not have to click his way through the path each time.

Last updated Sun Aug 7 21:14:12 CEST 2005 Permalink: http://www.karakas-online.de/EN-Book/red-hat-linux-apache-php-mysql.html All contents © 2004 Chris Karakas, Claudio Erba