p_quarles
July 22nd, 2007, 10:28 PM
I found that the default installation of Apache, MySQL and PHP in the server edition of Ubuntu has some frustrating limitations. The file structure, for instance, is sufficiently different from the source builds of these applications that I found it very difficult to follow some of the tutorials I found on implementing advanced features. Because of this, I decided to reinstall these applications from the latest source code.
Much of this guide is based upon instructions I received from Julie Meloni's Teach Yourself PHP, MySQL and Apache, though these basic procedures are widely available in many locations. I modified these instructions considerably based on my experience installing these applications in Ubuntu. Specifically, I performed this installation on an Intel Pentium 4 1.8 GHz machine with 384 MB of memory running the 32-bit version of Ubuntu 7.04.
Obviously, if you're happy with your LAMP server setup, there is no reason for you to follow this how-to. I just wanted to share my experience with those who might also find it useful.
I am offering this tutorial "as is," meaning that while I will try to answer any questions you may have, I don't feel confident enough to promise any support. This is a very basic setup, so this is not recommended for anyone who doesn't know (or doesn't want to bother learning) how to further configure these applications. This will, however, give you an installation that integrates the three for the purposes of web development.
As long as you follow the recommended file placement given below, this is very easy to undo. Simply delete the directories containing the respective applications, which will all be subdirectories of /usr/local/
Preparing
I was able to retrieve all necessary dependencies for this source code using apt-get:
sudo apt-get build-dep apache2 php5 mysql-serverInstalling MySQL
You can find the latest source code for MySQL at http://dev.mysql.com/downloads
Get the source (tar.gz) file appropriate for your system, and place it in the directory /usr/src/
Before unpacking, you need to create a user for the MySQL daemon. If you have had another version of MySQL running on your server in the past, you will already have this user.
sudo groupadd mysql
sudo useradd -g mysql mysqlNow unpack the tarball:
cd /usr/local
sudo gunzip < /usr/src/mysql-5.0.45-linux-i686.tar.gz | sudo tar xvf -Make a symbolic link to the MySQL directory (unless you want to type out the entire version number to get there)
sudo ln -s mysql-5.0.45-linux-i686 mysql
cd mysqlOpen the file called INSTALL-BINARY (using the cat command, or a text editor). This provides you with very accurate instructions for getting through the rest of the basic installation. I found two things useful at this point: 1) copying the INSTALL-BINARY file to a separate window while I went through the instructions. 2) I found it more convenient to log in as root (sudo su or sudo bash) during this process. This saves you from having to sudo every single command. If you do this, remember to type "exit" to get back to user mode after you're done.
Finally, to start MySQL in safe mode (non-root process), type:
sudo bin/mysqld_safe --user=mysql &Installing Apache
Get the latest source code from http://httpd.apache.org/download.cgi
and place it in the /usr/src/ directory and unpack it:
sudo gunzip < httpd-2.2.4.tar.gz | sudo tar xvf -The following "configure" command will setup Apache in preparation to share objects with PHP (again, more convenient to login as root):
cd apache2
./configure --prefix=/usr/local/apache2 --enable-module=soIf you get a "configure ok" message at the end of this process, you can proceed to enter the "make" and "make install" commands to finish compiling and installing the code. After this is done, check to see if installation was successful:
sudo /usr/local/apache2/bin/httpd -vTo start the web server daemon, type:
sudo /usr/local/apache2/bin/apachectl startInstalling PHP
Get the latest source code from http://www.php.net/downloads.php#v5
and place it in the /usr/src/ directory.
Unpack it:
sudo gunzip < /usr/src/php-5.2.3.tar.gz | sudo tar xvf -And configure it to work with Apache and MySQL(I used a root login):
cd php-5.2.3
./configure --prefix=/usr/local/php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxsThis will take some time. After this, you can use the "make" and "make install" commands to finish the work.
To test PHP's web-readiness, make a file called info.php and place it in the /usr/local/apache2/htdocs/ directory. The file should contain the PHP script:
<?php phpinfo(); ?> Point your browser to the {hostname}/info.php . You should be greeted with information about the PHP version and its installation on your system.
One other minor tweak you may want: use the recommended php.ini file by typing:
sudo cp php.ini-recommended /usr/local/lib/php.iniPlease feel free to suggest additions, request corrections, or add any other information that might help streamline or optimize this installation.
Much of this guide is based upon instructions I received from Julie Meloni's Teach Yourself PHP, MySQL and Apache, though these basic procedures are widely available in many locations. I modified these instructions considerably based on my experience installing these applications in Ubuntu. Specifically, I performed this installation on an Intel Pentium 4 1.8 GHz machine with 384 MB of memory running the 32-bit version of Ubuntu 7.04.
Obviously, if you're happy with your LAMP server setup, there is no reason for you to follow this how-to. I just wanted to share my experience with those who might also find it useful.
I am offering this tutorial "as is," meaning that while I will try to answer any questions you may have, I don't feel confident enough to promise any support. This is a very basic setup, so this is not recommended for anyone who doesn't know (or doesn't want to bother learning) how to further configure these applications. This will, however, give you an installation that integrates the three for the purposes of web development.
As long as you follow the recommended file placement given below, this is very easy to undo. Simply delete the directories containing the respective applications, which will all be subdirectories of /usr/local/
Preparing
I was able to retrieve all necessary dependencies for this source code using apt-get:
sudo apt-get build-dep apache2 php5 mysql-serverInstalling MySQL
You can find the latest source code for MySQL at http://dev.mysql.com/downloads
Get the source (tar.gz) file appropriate for your system, and place it in the directory /usr/src/
Before unpacking, you need to create a user for the MySQL daemon. If you have had another version of MySQL running on your server in the past, you will already have this user.
sudo groupadd mysql
sudo useradd -g mysql mysqlNow unpack the tarball:
cd /usr/local
sudo gunzip < /usr/src/mysql-5.0.45-linux-i686.tar.gz | sudo tar xvf -Make a symbolic link to the MySQL directory (unless you want to type out the entire version number to get there)
sudo ln -s mysql-5.0.45-linux-i686 mysql
cd mysqlOpen the file called INSTALL-BINARY (using the cat command, or a text editor). This provides you with very accurate instructions for getting through the rest of the basic installation. I found two things useful at this point: 1) copying the INSTALL-BINARY file to a separate window while I went through the instructions. 2) I found it more convenient to log in as root (sudo su or sudo bash) during this process. This saves you from having to sudo every single command. If you do this, remember to type "exit" to get back to user mode after you're done.
Finally, to start MySQL in safe mode (non-root process), type:
sudo bin/mysqld_safe --user=mysql &Installing Apache
Get the latest source code from http://httpd.apache.org/download.cgi
and place it in the /usr/src/ directory and unpack it:
sudo gunzip < httpd-2.2.4.tar.gz | sudo tar xvf -The following "configure" command will setup Apache in preparation to share objects with PHP (again, more convenient to login as root):
cd apache2
./configure --prefix=/usr/local/apache2 --enable-module=soIf you get a "configure ok" message at the end of this process, you can proceed to enter the "make" and "make install" commands to finish compiling and installing the code. After this is done, check to see if installation was successful:
sudo /usr/local/apache2/bin/httpd -vTo start the web server daemon, type:
sudo /usr/local/apache2/bin/apachectl startInstalling PHP
Get the latest source code from http://www.php.net/downloads.php#v5
and place it in the /usr/src/ directory.
Unpack it:
sudo gunzip < /usr/src/php-5.2.3.tar.gz | sudo tar xvf -And configure it to work with Apache and MySQL(I used a root login):
cd php-5.2.3
./configure --prefix=/usr/local/php --with-mysqli=/usr/local/mysql/bin/mysql_config --with-apxs2=/usr/local/apache2/bin/apxsThis will take some time. After this, you can use the "make" and "make install" commands to finish the work.
To test PHP's web-readiness, make a file called info.php and place it in the /usr/local/apache2/htdocs/ directory. The file should contain the PHP script:
<?php phpinfo(); ?> Point your browser to the {hostname}/info.php . You should be greeted with information about the PHP version and its installation on your system.
One other minor tweak you may want: use the recommended php.ini file by typing:
sudo cp php.ini-recommended /usr/local/lib/php.iniPlease feel free to suggest additions, request corrections, or add any other information that might help streamline or optimize this installation.