Saturday, July 16, 2011

Install Apache + PHP5 + Mysql in Ubuntu 11.04

Install Apache + PHP5 + Mysql in Ubuntu 11.04

We need the following package.
  - apache2
  - php5
  - libapach2-mod-php5
Install Apache2:

Lets install then.

  $ sudo apt-get install apache2
  
With apache2, Itinstaled following package too.
  - apache2
  - apache2-mpm-worker
  - apache2-utils
  - apache2.2-bin
  - apache2.2-common
  - libapr1
  - libaprutil1
  - libaprutil1-dbd-sqlite3
  - libaprutil1-ldap

Let check the apache is running or not.
If apache is running then stop with following command.
  $ sudo apache2ctl stop

Apache setup file: [/etc/apache2/apache2.conf]

Install PHP5:

  $ sudo apt-get install php5
  
  This installed following package.
  - apache2-mpm-prefork
  - libapache2-mod-php5
  - php5-cli
  - php5-common
  
Confirm php and apache is running well.
  $ sudo apache2ctl restart
  
  If you want to work with your user then set the owner for Document root.
  $ sudo chown -R <user>:<user> /var/www
  
  Next let make phpinfo file in the Document root.
  $ sudo vim /var/www/phpinfo.php

  <?php
  phpinfo();
  ?>
  Save the file and access on the link [http://localhost/phpinfo.php]
  If you seen the PHP information then its working fine.

Install Mysql:

Lets install mysql server.
  $ sudo apt-get install mysql-server

  This installed following package.
  - libdbd-mysql-perl
  - libdbi-perl
  - libhtml-template-perl
  - libmysqlclient16
  - libnet-daemon-perl
  - libplrpc-perl
  - mysql-client-5.1
  - mysql-client-core-5.1
  - mysql-common
  - mysql-server
  - mysql-server-5.1
  - mysql-server-core-5.1
When installing mysql on you box, Its asked root password for Myaql db server.

  Lets check mysql is working or not.
  $ sudo service mysql start
  $ which mysql
  /usr/bin/mysqlc
  
  $ mysql -u root -p
  Enter Password: ********
  Welcome to the MySQL monitor.  Commands end with ; or \g.
  Your MySQL connection id is 34
  Server version: 5.1.54-1ubuntu4 (Ubuntu)
 
  Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
  This software comes with ABSOLUTELY NO WARRANTY. This is free software,
  and you are welcome to modify and redistribute it under the GPL v2 license
 
  Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
  
  mysql> show databases;
  +--------------------+
  | Database           |
  +--------------------+
  | information_schema |
  | mysql              |
  +--------------------+
  2 rows in set (0.00 sec)
 
  mysql> exit
  Bye
  
  If you find the above message then it work fine.
  

Lets link apache2 + PHP5 + mysql together:
  Just run command below.
  $ sudo apt-get install php5-mysql
  
  $ sudo service apache2 restart
  Access on the link [http://localhost/phpinfo.php] and just check there is mysql or not.
  If there is mysql then you done.
  Have fun, Enjoy!

No comments:

Post a Comment