HOWTO: Quick and Easy Apache, PHP, MySQL, Mod_Gzip

O.K. first things you will need to download the source tarballs for each file Apache 1.3.24 (http://www.apache.org/dist/httpd/apache_1.3.26.tar.gz) PHP 4.2.2 (http://ca.php.net/do_download.php?download_file=php-4.2.2.tar.gz) MySQL 3.23.51 (http://www.mysql.com/Downloads/MySQL-3.23/mysql-3.23.51.tar.gz) and the pre-compiled Mod_Gzip 1.3.19.1a Module (http://www.remotecommunications.com/apache/mod_gzip/src/1.3.19.1a/mod_gzip.so)

(*Note* These are the current versions of the software as of the date 07/31/2002)

Once you have downloaded and saved all those files start by uncompressing MySQL by typing ‘gzip -dc mysql-3.23.51.tar.gz | tar xvvf -‘ followed by ‘cd mysql-3.23.51’.
The next step will be to run the configure script. This is done by typing:
‘./configure –prefix=/usr/local/mysql’ ( the –prefix flag will tell the config script where to install mysql too, in this case its /usr/local/mysql, you can use something different, but this is what I use 🙂 )
After it is done going through the configuration process and it makes all the make files you can type ‘make’. After it is done building the last command you have to do is ‘make install’. Now that, ‘make install’ has finished you may think your done, but your not. Follow these simple directions and you will be completed the first task.

Type the following commands at the command prompt:

‘groupadd mysql’ This will add the mysql group
‘useradd -g mysql mysql’ This will add a mysql user to the mysql group
‘scripts/mysql_install_db’ This will install the default databases
‘chown -R root /usr/local/mysql’ This will change the ownership of /usr/local/mysql
‘chown -R mysql /usr/local/mysql/var’ Same with this one
‘chgrp -R mysql /usr/local/mysql’ This changes the group
‘cp support-files/my-medium.cnf /etc/my.cnf’ Copies the conf file
‘/usr/local/mysql/bin/safe_mysqld –user=mysql &’


There now you are done installing mysql.

Now onto the next step. It’s a fairly simple step. All as you have to do is type the following:

‘gzip -dc apache_1.3.26.tar.gz | tar xvvf -‘
‘cd apache_1.3.26’
‘./configure –prefix=/usr/local/apache’ You can also place this wherever you like.


That is all you have to do so far for apache.

Now for php. Type the following commands:

‘gzip -dc php-4.2.2.tar.gz | tar xvvf -‘
‘cd php-4.2.2’
‘./configure –with-mysql=/usr/local/mysql –with-apache=../apache_1.3.26’ Point –with-apache to your apache src dir
‘make’
‘make install’

When its done compiling php is done. Just a couple more things to do and your done. Go back to your apache directory and type:

‘./configure –prefix=/usr/local/apache –enable-module=so –activate-module=src/modules/php4/libphp4.a’
‘make’
‘make install’

The last and final step, is to copy mod_gzip.so to /usr/lib/apache/

There, you are now done building your packages, now to configure them.

Change the directory to /usr/local/apache/conf (or wherever/you/put/apache/conf) and edit the httpd.conf

Find the line that contains ‘DirectoryIndex index.html’ and make it look like ‘DirectoryIndex index.html index.php’

This step allows index.php to be recognized as an index file.

Now open up /usr/local/apache/conf/httpd.conf and insert the following line:

AddType application/x-httpd-php .php

Now php is ready to work with apache, onto mod_gzip.
Look for the line that contains ‘# LoadModule foo_module modules/mod_foo.so’ And right below it add the line. ‘LoadModule gzip_module modules/mod_gzip.so’

Then right below that add the following lines:
# [mod_gzip configuration]
mod_gzip_on Yes
mod_gzip_minimum_file_size 300
mod_gzip_maximum_file_size 0
mod_gzip_maximum_inmem_size 100000
mod_gzip_keep_workfiles No
mod_gzip_temp_dir /tmp
mod_gzip_dechunk Yes
mod_gzip_item_include file \.htm$
mod_gzip_item_include file \.html$
mod_gzip_item_include file \.php$
mod_gzip_item_include file \.pl$
mod_gzip_item_include file \.cgi$
mod_gzip_item_include file \.phps$
mod_gzip_item_include mime text/.*

Save what you just did as httpd.conf (Don’t worry, overwrite the current httpd.conf) Then run ‘/usr/local/apache/bin/apachectl configtest’ If you edited your config file right (which you should have) you will see the line ‘Syntax OK’
You can now start your apache server by typing ‘/usr/local/apache/bin/apachectl start’
Now, to see if it is all working:
To see if apache and mysql are running type:

‘ps -aux | grep apache’ (If apache is running it will show running apache processes)
‘ps -aux | grep mysql’ (If mysql is running, again, it will show)

Now to see if php worked. Make a file in ‘/usr/local/apache/htdocs’ called ‘test.php’ and insert the following line of code into it: <? phpinfo(); ?>

Now load http://localhost/test.php in your browser. You will get fairly large page with all your php information in it.