Installing Apache 2.2, PHP5, MySQL5

POSTED BY Khurrum ON Aug 1st 2009
|

Apache 2.2 PHP5 MySQL5This article will serve as the root for a lot of other tutorials that I will post. Many important linux programs such as MediaWiki, Request Tracker, Nagios etc. require either a webserver, database, or/and PHP. This tutorial will cover how to install Apache2.2, MySQL5, and PHP5 on a debain based operating system such as Ubuntu. The screenshots used are taken from Ubuntu 8.04 (Long Term Support). This will not cover installing these packages from source because I plan on writing a longer article for that.

Install Apache using apt-get

$ sudo apt-get install apache2

apt-get install apache

This is going to automatically install the following packages:

  • apache2-mpm-worker: MPM stands for multi-processing module. This is flavor of the web-server binary is recommended for high-traffic sites.
  • apache2-utils: This adds helpful addons such as logrotate, benchmarking tools, basic authentication tools etc.
  • apache2.2-common: This installs the common configuration and support scripts for apache

After installation is complete, open your browser, and enter the IP address of your machine (or type http://localhost/ ). If Apache2.2 is installed then it will say "It works!"

it works

Install PHP5 using apt-get

$ sudo apt-get install php5

apt-get install php5

This will automatically install the following packages:

  • apache-mpm-prefork: This is required because the php5 module for apache only works with prefork. This Multi-Processing Module (MPM) implements a non-threaded, pre-forking web server that handles requests in a manner similar to Apache 1.3. It is appropriate for sites that need to avoid threading for compatibility with non-thread-safe libraries. It is also the best MPM for isolating each request, so that a problem with a single request will not affect any other.
  • libapache2-mod-php5: This package provides the PHP5 module for the Apache 2 webserver
  • php5: This is the actual PHP5 package
  • php5-common: This provides common files, documentation, and utilties for use with php5.

2. Restart apache

$ sudo /etc/init.d/apache2 force-reload

3. Test if php5 is working

$ sudo nano /var/www/index.php

Paste the following in the file called index.php:

<? phpinfo() ?>

Next, go to your web browser and visit http://localhost/index.php and you should see a php configuration information screen:

php5 works

Install MySQL5 using apt-get

$ sudo apt-get install mysql-server

apt-get install mysql5

This is going to install the following packages:

  • mysql-server-5.0: The main package
  • mysql-common: Common Files required for mysql
  • mysql-client-5.0: Client for mySQL
  • libdbd-mysql-perl:
    DBD::mysql implements the standard Perl5 DBI interface to give you access to MySQL databases.
  • libdbi-perl: DBI: (DataBase Interface) is a Perl framework that provides a common interface to access various backend databases in a uniform manner
  • libnet-daemon-perl: Net::Daemon is an abstract base class for implementing portable server applications in a very simple way.
  • libplrpc-perl: Perl RPC simplifies the writing of Perl based client/server applications.

During the install, it will ask you for a mysql administrative root password. Be sure to enter a strong password that you can remember for future steps.

Finally, go ahead and install phpmyadmin. This package will install a very useful web-based mysql administration frontend.

$ sudo apt-get install phpmyadmin

You will be asked about which webserver to configure for use with phpmyadmin. Since we have just installed Apache2, choose that.

phpmyadmin

Next, go to http://localhost/phpmyadmin and you will see the log on screen. Use the username root and the password that you created while installing mysql here.

login to phpmyadmin

You can now create new users, databases, and manage your databases from phpmyadmin.

If no errors were encountered, you now have working versions of Apache 2.2, PHP5, and MySQL5 on your server.



Comments

Post new comment

  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd>
  • Lines and paragraphs break automatically.

More information about formatting options