If you have installed linux on your system and are capable of compiling and installing programs from source (aka most linux users) then you will hopefully be able to understand and follow this tutorial.
This tutorial has been written for people who wish to develop web pages using the dynamic scripting language
PHP with the MySQL DBMS and GD Graphics libraries in a *NIX environment. Most likly the reader will have a
professional server to which they are developing a web page for and wish to have a local development environment
to avoid the hassle of constantly uploading files (not to mention perminent internet connection). <plug>
If you don't have a server - feel free to consider Delta IT</plug>.
With the combination of PHP, Apache, MySQL and GD - you will have the tools to be able to develop dynamic database driven web sites
with dynamic imageing capabilities to a fully professional level. Why PHP/Apache/MySQL/GD?? Well they are all
open source, free and installed on just about all *NIX servers (which are the bulk of servers).
This work is derived from the web.blazonry : Server-side : Install Apache+PHP+MySQL
It differs by including the GD library and more updated versions of the software. If you don't want the GD library, then simply
don't download or install the "gd", "zlib", "libpng" "libjpeg" libraries nor include those lines in any configure statements.
Download the Apache, PHP and MySQL packages. If you wish also to use the GD graphics library with PHP, download the zlib, libpng and libjpeg packages.
Unpack the sources.
Installing MySQL is a breeze on red hat - just install the rpm's, and it installs the program. There are no links to the other programs so it usually works like a charm.
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.
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:
You can test the MySQL installation by doing the following:
# mysql mysql (connect to mysql database)
Enter Password:
mysql> SELECT * FROM user; (grab some data out of user table)
This should return the data in the user table. Type exit to leave.
Here are the step by step directions to install Apache and PHP in the directory /usr/local/apache
In the apache source directory (apache_1.3.27/)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:
After editing the config file you need to restart Apache The command to restart
Apache is:
To test Apache and PHP work together create the following PHP file:
test.php
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 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 the Web Database Tutorial on web.blazonry.
|
Apache+PHP (DSO Module)
Another way to install Apache and PHP is by using Apache's DSO module. Apache supports adding modules on instead of embedding them in the httpd binary. This works well when you don't want to re-compile Apache each time a module is updated, or if you want to add on numerous modules for development purposes. Compile Apache with DSO support
# ./configure --prefix=/usr/local/apache \ --enable-module=so --enable-module=rewrite $ make $ make install Install PHP as a Module
# ./configure --with-mysql \ --with-xml \ --enable-track-vars \ --with-apxs=/usr/local/apache/bin/apxs # make # make install This will install Apache and then install the PHP module into the appropiate
Apache directories. The only difference in configuration from above is the module
needs to be added in the Apache httpd.conf file. To add a module in Apache add the
following line in the httpd.conf file (if it is not already there, sometimes the
install script adds it for you)
LoadModule php4_module libexec/libphp4.so
Be sure to following the rest of the configuration instructions above. |
I hope by now you have a good linux development platform. If you have any questions or comments, I direct you to the Tank Ammo programming forums http://tankammo.net/forums/.
Author: William Denniss
Version: 1.0
Last Modified: 19 Feb 2003
Created: 9 Jan 2003