Ubuntu_installing apache2 with PhP5 and MySQL support on Ubuntu 12.04 lts (LAMP)

Source: Internet
Author: User
Document directory
  • 1 Preliminary Note
  • 2 installing MySQL 5
  • 3 installing apache2
  • 4 installing PhP5
  • 5 testing PhP5/getting details about your PhP5 Installation
  • 6 getting MySQL support in PhP5
  • 7. phpMyAdmin
  • 9 links

Version 1.0:
Author: Falko Timme <ft [at] falkotimme [Dot] COM>
Follow me on Twitter
Last edited 05/02/2012

Lamp is shortLInux,APache,MYsql,PHP. This tutorial shows how you can install an apache2 webserver on anubuntu 12.04 lts server with PhP5 support (mod_php) and MySQL support.

I do not issue any guarantee that this will work for you!

 

1 Preliminary Note

In this tutorial I use the hostname server1.example.com with the IP address192.168.0.100. these settings might differ for you, so you have to replace them where appropriate.

I'm running all the steps in this tutorial with root privileges, so make sure you're logged in as root:

Sudo Su

 

2 installing MySQL 5

First we install MySQL 5 like this:

Apt-Get install mysql-server mysql-Client

You will be asked to provide a password for the MySQL Root User-this password is valid for the userroot @ localhost as well asroot@server1.example.com, so we don't have to specify a MySQL Root Password
Manually later on:

New password for the MySQL "root" User:
<-- Yourrootsqlpassword
Repeat password for the MySQL "root" User:
<-- Yourrootsqlpassword

 

3 installing apache2

Apache2 is available as an Ubuntu package, therefore we can install it like this:

Apt-Get install apache2

Now direct your browser to http: // 192.168.0.100 (this is yourself IP), And You shoshould see The apache2 placeholder page (it works !) :


Apache's default document root is/var/WWW on Ubuntu, And the configuration file is/etc/apache2/apache2.conf. Additional deployments are stored in subdirectories of the/etc/apache2
Directory such as/etc/apache2/mod-enabled (for Apache modules),/etc/apache2/sites-enabled (for virtual hosts), and/etc/apache2/CONF. d.

 

4 installing PhP5

We can install PhP5 and the Apache PhP5 module as follows:

Apt-Get install PhP5 libapache2-mod-php5

We must restart Apache afterwards:

/Etc/init. d/apache2 restart


5 testing PhP5/getting details about your PhP5 Installation

The document root of the default web site is/var/www. we will now create a small PHP file (info. PHP) in that directory and call it in a browser. the file will display lotsof useful details about our
PHP installation, such as the installed phpversion.

VI/var/www/info. php

<?php
phpinfo();
?>

Now we call that file in a browser (e.g. http: // 192.168.0.100/info. php ):


As you see, PhP5 is working, and it's working through
Apache 2.0 handler, as shown in the server apiline. if you scroll further down, you will see all modules that arealready enabled in php5. MySQL is not listed there which means we don't 'thave MySQL support in PhP5 yet.

 

6 getting MySQL support in PhP5

To Get mysql support in PHP, we can install the php5-mysqlpackage. it's a good idea to install some other PhP5 modules as well asyou might need them for your applications. you can search for availablephp5 modules like this:

Apt-cache search PhP5

Pick the ones you need and install them like this:

Apt-Get install php5-mysql php5-curl php5-gdphp5-intl php5-imagick PHP-pear php5-imap php5-mcrypt php5-memcachephp5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlitephp5-tidy php5-xmlrpc

Now restart apache2:

/Etc/init. d/apache2 restart

Now reload http: // 192.168.0.100/info. phpin your browser and scroll down to the modules section again. youshoshould now find lots of new modules there, including the MySQL module:


 

7. phpMyAdmin

PhpMyAdmin is a Web interface through which you can manage your MySQL databases. It's a good idea to install it:

Apt-Get install phpMyAdmin

You will see the following questions:

Web server to reconfigure automatically:
<-- Apache2
Configure database for phpMyAdmin with dbconfig-Common? <-- No

Afterwards, you can access phpMyAdmin under http: // 192.168.0.100/PHPmyAdmin /:


 

8. Configure phpMyAdmin in Ubuntu

How to install phpMyAdmin-MySQL Database Management

Use the interface Manager:
System-> System Management-> New Software Package Manager-> Search phpMyAdmin-> right-click to mark installation.
Or run the following command: sudo apt-Get install phpMyAdmin to start installation.

PhpMyAdmin settings:
During the installation process, You must select Web server: apache2 or Lighttpd, select apache2, press the tab key, and click OK. Then, you are required to enter the MySQL Database Password of the database's administrative user.
Then, establish a connection between phpMyAdmin and apache2. Take my example: the WWW directory is in the/var/WWW directory, and the phpMyAdmin directory is in the/usr/share/phpMyAdmin directory. Therefore, run the following command: connect sudo ln-S/usr/share/PHPmyAdmin/var/www.

PhpMyAdmin test: Open http: // localhost/phpMyAdmin in the address bar of the browser. OK. No other problems have been encountered. O (distinct _ distinct) O ~~

9 links
  • Apache: http://httpd.apache.org/
  • PHP: http://www.php.net/
  • MySQL: http://www.mysql.com/
  • Ubuntu: http://www.ubuntu.com/
  • PhpMyAdmin: The http://www.phpmyadmin.net/


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.