Install MySQL DB, Apache2 Web Server and PHP5 Scripting Language on Ubuntu

MySQL

MySQL is a fast, multi-threaded, multi-user, and robust SQL database server. It is intended for mission-critical, heavy-load production systems as well as for embedding into mass-deployed software.

Installation

To install MySQL, open “terminal window”. Applications > Accessories > Terminal


run the following command from a terminal prompt:

sudo apt-get install mysql-server

You have to enter your user password and also during the installation process you will be prompted to enter a password for the MySQL root user here are the screen shots:

Once the installation is complete, the MySQL server should be started automatically. You can run the following command from a terminal prompt to check whether the MySQL server is running:

sudo netstat -tap | grep mysql

When you run this command, you should see the following line or something similar:

tcp 0 localhost.localdomain:mysql *:* LISTEN –

If the server is not running correctly, you can type the following command to start it:

sudo /etc/init.d/mysql restart

Apache2 Web Server

Apache is the most commonly used Web Server on Linux systems. Web Servers are used to serve Web Pages requested by client computers. Clients typically request and view Web Pages using Web Browser applications such as Firefox, Opera, or Mozilla.

Installation

At the terminal prompt enter the following command: (see above for the Terminal Window)

sudo apt-get install apache2

Enter the user password on promt and confirm with Y on question promt.

After finish Open you browser and type http://localhost un url adress, you will have this page:

DocumentRoot directive specifies where Apache should look for the files that make up the site. The default value is /var/www.

PHP5 – Scripting Language

PHP is a general-purpose scripting language suited for Web development. The PHP script can be embedded into HTML. This section explains how to install and configure PHP5 in Ubuntu System with Apache2 and MySQL.

Installation

To install PHP5 you can enter the following command in the terminal prompt:

sudo apt-get install php5 libapache2-mod-php5

You can run PHP5 scripts from command line. To run PHP5 scripts from command line you should install php5-cli package. To install php5-cli you can enter the following command in the terminal prompt:

sudo apt-get install php5-cli

You can also execute PHP5 scripts without installing PHP5 Apache module. To accomplish this, you should install php5-cgi package. You can run the following command in a terminal prompt to install php5-cgi package:

sudo apt-get install php5-cgi

To use MySQL with PHP5 you should install php5-mysql package. To install php5-mysql you can enter the following command in the terminal prompt:

sudo apt-get install php5-mysql

To verify your installation, you can run following PHP5 phpinfo script:

PHP Info

And you will have this page:

That’s all! Thanks for reading this tutorial, if you have any questions please leave it like a comment.

Share your love

One comment

Leave a Reply

Your email address will not be published. Required fields are marked *