Browse:  GUI  JavaScript  Linux  OpenBSD  PHP  Software  Web  Windows  Deals
 

Installing Apache, MySQL, and PHP
by Cory Rauch 2007-02-06 Category: Linux-System

In this article we are going to cover the basic steps to setting up Apache, MySQL, and PHP software on Linux. Because this combination has become increasingly popular to use and a lot of tutorial currently on the web seem somewhat outdated, I thought a simple article to get a user up and running might be of great help. So lets get started!

Downloads

First we need to download a copy of the latest Apache, MySQL, and PHP software. Below is links to each project's homepage, which should point you to the latest files.

Apache

MySQL

PHP

NOTE: You can download either the RPM or source tar-balls. In this tutorial we will cover compiling each software package, but if you want to use RPM packages instead, simply install them with the standard 'rpm -i' command and then skip to the configuration section.

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:

<? phpinfo(); ?>

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!

Conclusion

Hopefully you found this article helpful, and now that you have Apache, PHP, and MySQL setup the world of PHP/MySQL software solutions is available to you. We invite you to check back for our next tutorial.

Other ImprovedSource Articles:
Boot Fedora Linux Faster: How I Modified Fedora To Boot In Under 25 Seconds
Linux Fastest Boot Time Challenge
How to make a System Restore CD-ROM

[ Back ]

ImprovedSource. Copyright 2007 + Contact Us + Home + Search + RSS Feed