|Get best price on Samsung Galaxy S5, Copper Gold 16GB (Verizon Wireless)|
How To Install Apache + PHP + MySQL
This tutorial discusses the setup of Apache, PHP and MySQL for both Windows and Red Hat Linux.
Installing Apache, PHP, MySQL on Windows Computers
Installation of Apache, PHP and MySQL is straightforward for Windows computers.
Installing Apache, PHP, MySQL for Red Hat Linux
Installation is similar on other Linux distributions. The tutorial below covers two approaches. The first discussed is downloading and installing packages. How to use Apache's DSO Module is discussed second.
The following tutorial was written for then current (year 2000) versions. For complete information regarding installation, especially if there are new versions released, you should read the install notes for each of the packages.
This tutorial assumes you are running Linux and it is installed properly. For help with installing and configuring Linux check out some of the related links at the bottom of this page.
Download the PackagesFirst download the required packages to a directory. If you are running a different platform be sure to download the appropiate files for your platform:
Extract the Apache and PHP package into that directory using
# tar xfz apache_1.3.14.tar.gz
# tar xfz php_4.0.3pl1.tar.gz
Note: The pound sign # is the system prompt. You type in only what is after it .
Installing MySQLMySQL is easiest to install on Red Hat systems using the RPM packages. To install MySQL in the same directory as the RPM packages use the command:
# rpm -Uvh *.rpm
Note: You most likely need to do this as the root user. Either log in or
After MySQL is installed you need to set the root password. To do this
use the following commanding changing my_password to the password
you want for the root user to access MySQL.
# mysqladmin -u root password 'my_password'
Note: If the MySQL service is not running, you may have to start it
by hand before trying to set the password. It should start automatically when
the computer boots. The command to start MySQL is:
# /etc/rc.d/init.d/mysqld start
You can test the MySQL installation by doing the following:
Installing Apache with PHPApache with PHP can be installed a few different ways. One way is to statically embed the PHP binary into the Apache binary. This is probably the fastest and best way to run PHP. You can also install PHP as a DSO module (see below)
Here are the step by step directions to install Apache and PHP in the directory /usr/local/apacheIn Apache src directory (apache_1.3.14/)
# ./configure --prefix=/usr/local/apache
In PHP src directory (php-4.0.3pl1/)
# ./configure --with-mysql \
# make install
In Apache src directory (apache_1.3.14)
# ./configure --prefix=/usr/local/apache \
# make install
This will install Apache in the /usr/local/apache directory. The only thing left to do is to configure them.
Configuring Apache and PHP
To configure PHP copy php.ini-dist which is in the PHP src directory to /usr/local/lib/php.ini Edit this file setting the options you wish, generally nothing needs to be edited. However, you can set various options such as a default MySQL username and password.
To configure Apache edit /usr/local/apache/conf/httpd.conf
and set the your document directory and any other Apache settings you may want.
To enable Apache and PHP to work together the following line needs to be added:
AddType application/x-httpd-php .php
Look for this line or something similar already in the httpd.conf file and replace it with the above. Make sure to remove the # comment mark.
After editing the config file you need to restart Apache. The command to restart Apache is:
To test that Apache and PHP work together, create a PHP file. Name it test.php. The entire contents of the file are:
echo("<h1>Yay! PHP and Apache Work!</h1>");
Copy this file to the document directory, if you did not change the document directory in the config file (httpd.conf) then the default document directory is /usr/local/apache/htdocs/ Load this page in your browser by using the following URL: http://localhost/test.php
You should now have Apache, PHP and MySQL all installed and working nicely together. To see how to write a web application using this setup check out my Web Database Tutorial.
Related Links for Apache, PHP, MySQL
Linux Apache Web Server Administration, Second Edition (Craig Hunt Linux Library)
Red Hat Linux Administration: A Beginner's Guide
I was initially turned off by the title, but discovered that this
book assumes a good working knowledge of computers and level
of technical expertise.
Test Google Ads Ver. 2
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Most Popular Pages
Baby Name Generator
U.S. Name Generator
Wu Name Generator
Upload and Resize an Image (PHP)
How To Install Apache + PHP + MySQL
Intro to Web Databases (PHP, MySQL)
Least Popular Pages
iNews Applet (Java)
Site Monitor (Perl)