|Linux, Apache, MySQL & PHP (LAMP) Setup Guide (Version 2)|
Dustin's Linux Apache MySQL PHP (LAMP) Guide v2
You may have heard of the great server-side scripting language, PHP3, as of which I have written a guide. But, PHP3, is pretty much history, and PHP4 with Zend is the future. Bundling it with Apache 1.3.12 and MySQL, they make a powerful team. This guide is a complete rewrite of the original LAMP guide, in tradition of the PHP Engine rewrites. :)
We are going to focus on making Apache very versitile, and adding some enhancements to PHP4. The original LAMP guide has been read by many people, and hopefully they check back for this. PHP4 has been pretty rock solid since beta 2, and now that it is in the final beta stages, and with the release of the Zend Optimizer, I felt it was time for an overhaul. So here we go.
You with need to download the following sources.
PHP4 beta 4 patch level 1
Now move all of these to "/usr/local/src" and unpack them
mv *.tar.gz /usr/local/src/ cd /usr/local/src tar -zxvf apache*.tar.gz tar -zxvf php*.tar.gz tar -zxvf mysql*.tar.gz tar -zxvf Zend*.tar.gz
The first thing to setup here is MySQL. DJG has written a guide on this that is in more depth, but I will give you the minimal stuff here.
cd mysql* ./configure --prefix=/usr/local/mysql make make install cd /usr/local/mysql/bin ./mysql_install_db ./safe_mysqld >/dev/null & ./mysqladmin -u root password 'yourdesiredpasswordhere'
This will get MySQL up and running. You will most likely want it to start on boot so fix that up. To have MySQL load on boot, you will have to place the following line into the files specified below.
./safe_mysqld >/dev/null &
For Red Hat Linux based systems, you will need to place the line in /etc/rc.d/rc.local and for Debian GNU/Linux systems, you will need to place it in /etc/init.d/rcSNext we will want to install Apache. Usually, when you upgrade from an existing version of Apache, you just upgrade, and don't have to mess with the httpd.conf, but since we are going to do this with Dynamic Shared Objects support, which is much better btw, you will want to move the current httpd.conf to httpd.conf.save and use the new http.conf.default instead.
cd /usr/local/apache/conf mv httpd.conf httpd.conf.save cp httpd.conf.default httpd.conf
Now go back to the Apache source directory and let's get this show on the road.
cd /usr/local/src/apache_1.3.12 ./configure --prefix=/usr/local/apache --enable-shared=max make make install
That compiles apache for you just nice. Now you have support for DSO, so you only have to compile Apache again if you are upgrading, and not for new modules. Now we need to do some work on PHP.
cd ../php-4.0b4pl1 ./configure --with-apxs=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/apache/conf \ --with-mysql --enable-debug=no \ --enable-track-vars make make install
Now that compiles and installs PHP with all the nessesary stuff for us. Now we have to work on our config files.
cp php.ini-dist /usr/local/apache/conf/php.ini cd /usr/local/apache/conf
Now edit your httpd.conf. You should need to do only a few things, unless you have a nessecity for other things. First you will want to make sure that you configuration file has support for all of the PHP Module and all of the other modules. You should see some stuff like this:
LoadModule vhost_alias_module libexec... LoadModule... LoadModule php4_module libexec/libphp4.so ClearModuleList AddModule mod_vhost_alias.c AddModule... AddModule mod_php4.c
Make sure that there is a long list of modules there, if not, look in the new httpd.conf.default. They should be there. Make sure that it has the stuff for PHP in there as well, if not, add the lines from above. Next in the httpd.conf, make sure you have the handlers and mime stuff for PHP established. It should look like this, you will have to uncomment it:
AddType application/x-httpd-php .php .php3 .phtml AddType application/x-httpd-php-source .phps
This will have PHP established for you. Now we will install the Zend Optimizer. This is only in beta and has only 3 optimizations. It is pretty much a nice little toy.
mkdir /usr/local/Zend mkdir /usr/local/Zend/lib cp /usr/local/src/Zend*/ZendOptimizer.so /usr/local/Zend/lib/
Now you will need to update you php configuration file, php.ini, and add the following two lines with no additional spaces or anything:
This should have you rolling. Now after you have fully edited httpd.conf, fire up Apache and see if this all worked out right.
cd ../bin ./apachetcl start
<?php phpinfo(); ?>
There is a simple way to verify that everything is running as it should with PHP. What you need to do is place the preceding line into a file called phpinfo.php and then place that file into your web browser's document root folder. Next, using your web browser to view it, go to http://localhost/phpinfo.php and you should see all kinds of information regarding PHP and Apache along with the Zend Optimizer and also MySQL. This concludes our session, and I wish you great fun with PHP!
Having trouble? Got questions? Require further assistance? If so please feel free to visit our Help Forums and ask the experts!
Copyright © 1997 - 2013 Private World Domination Inc. All rights reserved.