Friday, November 25, 2005

Simple LAMP Setup

Installation

To install, we first need to extract each package. To do this, go into the directory containing the files you have just downloaded. Then type the following command:

# tar -xzvf apache_1.3.xx.tar.gz

# tar -xzvf mysql-3.23.xx.tar.gz

# tar -xzvf php-4.x.x.tar.gz

Next, We need to compile PHP and Apache. In this article we are going to opt for the fastest and best way to run PHP and Apache. That is by compiling them together into one executable. To do this, go into the apache directory and type the following:

# ./configure --prefix=/usr/local/apache

Next, Back out of the apache directory and go into the php directory. Then type the following:

# ./configure --with-mysql --with-xml --enable-track-vars --with-apache=../apache_1.3.xx

# make

# make install

Then, Back out again and go back into the apache directory and type:

# ./configure --prefix=/usr/local/apache --enable-module=rewrite --activate-module=src/modules/php4/libphp4.a

# make

# make install

This will compile and install Apache and PHP into the /usr/local/apache directory.

Now we need to compile and install the MySQL software. To do this, go into the mysql directory and type the following:

#./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --disable-maintainer-mode --with-mysqld-user=mysql --enable-large-files -without-debug

# make

# make install

This will compile MySQL and install its files to /usr/local/mysql. Next, We need to create the user account 'mysql'. This user account is the account mysql runs as. To do this type the following:

# groupadd mysql

# useradd -g mysql mysql

Then we need to install the database files and make some minor ownership changes as follows:

# ./scripts/mysql_install_db

# chown -R root:mysql /usr/local/mysql

# chown -R mysql:mysql /usr/local/mysql/data

Then add the line to your '/etc/ld.so.conf' file:

/usr/local/mysql/lib/mysql

Next we run the mysql daemon. To do this, type the following:

# cd /usr/local/mysql/bin

# ./safe_mysqld --user=mysql &

Finally, we set the root password of the mysql database. To do this, type the following:

# ./mysqladmin -u root password new_password

We should now have Apache, PHP, and MySQL compiled and installed. We now just need to configure them.

Configuration

To configure PHP, copy the php.ini-dist from the php directory to '/usr/local/lib/php.ini'. This file contains most of the settings you would want but you may want to edit it. The one setting you might want to enable is 'register_globals' to 'On' since a lot of PHP scripts use global variables for form data. Other than you may leave it unchanged.

Next we configure Apache. To do this open the file '/usr/local/apache/conf/httpd.conf ' and add the following line right after the line 'AddType image/x-icon .ico':

AddType application/x-httpd-php .php

Then we start the Apache daemon. To do this, type the following:

# /usr/local/apache/bin/apachectl start

To test our PHP and Apache setup create a file in the '/usr/local/apache/htdocs' directory called test.php and put the following code:



Finally, Fire-up your web browser and point it to 'http://localhost/test.php' and you should see a php info webpage complete with settings of php.

Apache, MySQL, and PHP are all configured now and are ready to go!


Originally found here: http://www.sysbotz.com/articles/amp.htm