Você está na página 1de 3

Dustin's Linux Apache MySQL PHP (LAMP) Guide Created on November 20th, 1999 Last modified on September 1st,

2001. LAMP has become a defacto-standard around the web community in the recent years, here is a guide to help you set it up. LAMP is the combination of Linux + Apache + MySQL + PHP. You probably already have Linux up if you have come this far, if not you can get help setting it up throughout this site and on #LinuxHelp.net on DALnet. Apache is the most popular web server on the net. It is very secure, fast, and reliable. There are may customizations you can make it, such as PHP support (which I am covering), CGI/Perl, SSL, SSI, ePerl, and even ASP. MySQL is the fastest RDBMS in the world. It is very good for web based applications as well. Many tools have been developed for MySQL with PHP, such as phpMyAdmin, a very good web based admin tool for MySQL, which can do anything your heart desires with MySQL. PHP is an up and coming server-side scripting langauge. It was developed by Rasmus Lerdorf, and countless others. It is currently in version 3.0.12. It has many advantages over its competitors (ASP, Cold Fusion, Perl, Java, ...) , such as it is Object Oriented, embedded into HTML, very fast, cross-platform compatible, can run as an Apache Module, it is constantly updated and fixed, and it borrows the best features from many other langauges. Now that I have filled you with my propaganda, let's get started. First of all, download the latest stable sources of Apache, MySQL, and PHP, you can find them at www.apache.org, www.mysql.com, and www.php.net, respectively. I would move them into /usr/local/src for consistancy, as well as making sure you get the tarball versions. Next, unpack them by typing: tar -zxvf filename.tar.gz Now, we are going to setup MySQL first cd into the mysql directory, maybe /usr/locl/src/mysql-3.23.41 Then configure it by typing: ./configure --prefix=/usr/local/mysql This will put it in it's own directory, which I always put things in /usr/local as a standardization. Run the make command: make Run the make install command: make install Now it is installed. You need now to set it up. Add the MySQL Libraries to the ldconfig file: echo "/usr/local/mysql/lib/mysql" >> /etc/ld.so.conf Now have it cache all of the libraries: ldconfig -v | grep libmysqlclient You should now see something returned like: libmysqlclient.so.10 => libmysqlclient.so.10.0.0 Now have MySQL start at boot time: echo "/usr/local/mysql/bin/safe_mysqld --skip-networking >> /dev/null &" >> /etc/rc.d/rc.local

1 of 3

Now you must make the initial databases the MySQL needs to run: ./scripts/mysql_install_db Now start up the service daemon for MySQL: /usr/local/mysql/bin/safe_mysqld --skip-networking >> /dev/null & Now add it to the path: PATH="$PATH:/usr/local/mysql/bin" Now you should test MySQL: mysqladmin version This should give you back all kinds of info on MySQL. Now create a password for the SuperUser: mysql -u root -p It will then prompt your for a password: Enter password: And MySQL should be setup. Now the next part is making the new Apache/PHP setup. If you are currently using Apache and have stuff that you would like to keep, do a backup on your data. Now blow away the old Apache, delete it by any means possible. Now change into the Apache source directory: cd /usr/local/src/apache_X.X.X Configure apache: ./configure --prefix=/usr/local/apache Now change into the PHP source directory: cd /usr/local/src/php-X.X.XX And run the configuration of php to support MySQL and Apache: ./configure --with-apache=../apache_X.X.X --with-mysql=/usr/local/mysql Now run the make command: make Now run the make install command: make install Now change back into the apache source directory: cd ../apache_X.X.X Now you have to reconfigure Apache, because we have added in the PHP Module. This will have it use the module you provided:

2 of 3

./configure --prefix=/usr/local/apache --activate-module=src/modules/php3/libphp3.a This will configure it. Now you must run the the make and make install commands: make make install There is a possibility that it will complain about not having an ANSII C compiler. If so, goto the FAQ on the www.php.net site. There are some common fixes there. If everything went well, you now have a few last minute setup processses to go through. Rename the http daemon: mv /usr/local/apache/bin/httpd-X.X.X /usr/loacl/apache/bin/httpd Now make a sybolic link and startup the http daemon: ln -s /usr/local/apache/bin/httpd /usr/sbin/httpd /usr/sbin/httpd Now that it is up, test and see the version information: httpd -v Now you have to add a couple of pieces of info to the apache configuration files. They are located i /usr/local/apache/conf/ pico httpd.conf Find the AddType section and uncomment these lines:
AddType application/x-httpd-php .phtml AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps

This will make apache understand that it needs to pass these extensioned file to the php3 engine. Now find the DirectoryIndex section and add some info for php. It should look like this:
DirectoryIndex index.html index.phtml index.php index.phps

That should do it. Now restart the Apache http daemon: killall -HUP httpd Apache should be up with support for php. You can now add the phpMyAdmin tool that is found at www.phpwizard.net or anyting else you would like. Come find me in #LinuxHelp.net on DALnet and I will show a few things in php, also I will show you a cool version operation for php.

Having trouble? Got questions? Require further assistance? If so please feel free to visit our Help Forums and ask the experts!

3 of 3

Você também pode gostar