Friday 11 May 2012

LAMP INSTALLATION STEPS UBUNTU12

http://tuxtweaks.com/2012/04/installing-lamp-on-ubuntu-12-04-precise-pangolin/


Installing LAMP on Ubuntu 12.04 Precise Pangolin

 

When working on web development, I prefer to work within the privacy of my own development environment located on my computer. I'd rather make the majority of my mistakes where no one else can see them rather than out in the wild of the Internet. In order to have that private development environment, I install a LAMP configuration. If you're not familiar with LAMP, it stands for Linux, Apache, MySQL, php (and/or Perl). LAMP is one of the most common web hosting platforms on the Internet, so it's a great environment to build and test your website. Follow these step by step instructions to install and configure LAMP  on Ubuntu 12.04. If you have a reasonably fast broadband connection, you should be done in less than half an hour.

Install LAMP on Ubuntu

The developers at Ubuntu have made it really easy to install and configure the packages for LAMP with a single terminal command. So open up a terminal window and let's get started.
sudo apt-get install lamp-server^
Yes, you read that right. Don't leave out the caret (^) at the end. The command won't work without it. It's magical!
sudo apt-get install lamp-server^
sudo apt-get install lamp-server^
The apt package manager will now show the packages to be installed and ask for confirmation. Hit <Enter> to confirm and continue with the install.
Install LAMP packages
Install LAMP packages
After some time downloading packages, you will be prompted to set a password for the root user for MySQL.
Set MySQL root password
Set MySQL root password
Enter the password you want to use for MySQL. Do not leave it blank. You'll be prompted a second time to confirm your password.
Confirm MySQL root password
Confirm MySQL root password
After confirming your password, apt will continue installing the remaining packages.
Remaining LAMP package installation
Remaining LAMP package installation
Your LAMP installation is now complete. Wow, that was easy! Now there's just a few more steps to get things configured to make it easy to work with your system.

Test Apache

Open a web browser window and enter the address http://localhost/. You should see a web page that says "It Works!"
Apache works
Apache works

Test php

Now that you've confirmed that the Apache web server works, you want to make sure that your php installation is working. To do that you need to create a file in /var/www called testing.php. You can use your favorite text editor as root, or you can use the following terminal command:
echo "<?php phpinfo(); ?>" | sudo tee /var/www/testing.php
Go back to your web browser and enter the address http://localhost/testing.php/ and you should see a page displaying information about your php installation.
php information
php information

Fix Apache fully qualified domain name

You may have noticed an error message from Apache about the server's fully qualified domain name.
apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1 for ServerName
This is not a big deal, but if it bothers you, you can fix it with the following commands.
echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn
Now reload the Apache web server.
sudo service apache2 reload
You should no longer see the error message.

Configure MySQL

Since this tutorial is for setting up a local web development environment, the MySQL needs to be bound to the localhost IP address. By default this should be 127.0.0.1 on your system. Just in case, you can verify it with these commands.
cat /etc/hosts | grep localhost
You should see something like
127.0.0.1 localhost
::1     ip6-localhost ip6-loopback

You now  want to verify that you have the correct bind address in MySQL's my.cnf file.
cat /etc/mysql/my.cnf | grep bind-address
You should see:
bind-address = 127.0.0.1
If the bind address doesn't match the one set for localhost on your system, you'll need to edit /etc/mysql/my.cnf as root to correct it.

Install phpMyAdmin

You don't need to install phpMyAdmin, but unless you're a wizard with SQL, you'll want it to do administrative tasks on your MySQL databases.
You can install phpMyAdmin with this terminal command:
sudo apt-get install libapache2-mod-auth-mysql phpmyadmin
You'll be prompted to confirm that you want to install the packages. Hit <Enter> to continue.
Install phpMyAdmin packages
Install phpMyAdmin packages
You'll next be prompted to select a web server to configure with phpMyAdmin. This is important! Use the arrow keys on your keyboard to highlight apache2 and then used the space bar to select it. Then hit <Enter> to continue. Make sure to click the picture below to see it in full size to see what I'm describing.
Configure phpMyAdmin for Apache
Configure phpMyAdmin for Apache
The next screen will ask if you want to configure phpMyAdmin with a database called dbconfig-common. Select "Yes" and hit <Enter>.
phpMyAdmin configure dbconfig-common
phpMyAdmin configure dbconfig-common
You'll next be prompted to enter the MySQL root password you created earlier so that the new database can be created. So enter your MySQL root password and hit <Enter>.
Enter MySQL root password
Enter MySQL root password
The next prompt is to create a MySQL application password for phpMyAdmin. You can hit <Enter> if you want a random password to be created. I usually use the same password that I used for the MySQL root password. It's probably not the greatest idea in terms of security, but since this is for a closed development environment, it's probably low risk.
phpMyAdmin MySQL application password
phpMyAdmin MySQL application password
Finally, you'll be prompted to confirm your MySQL application password. Type the same password as the previous step and hit <Enter>.
Confirm MySQL application password
Confirm MySQL application password
Installing and configuring phpMyAdmin is now complete.

Testing phpMyAdmin

The last step is to make sure that phpMyAdmin is working. Open a web browser and enter the address http://localhost/phpmyadmin/. You should see a page that looks like this.
phpMyAdmin login screen
phpMyAdmin login screen
You should now be able to log in with the username root and the root password that you created earlier.
phpMyAdmin logged in
phpMyAdmin logged in
Congratulations, you are now done installing and configuring LAMP and phpMyAdmin on Ubuntu 12.04. You can now start building the local version of your website. If you are only working on one site, you can place your files in /var/www. Note that /var/www is owned by the user and group root, so you will either need to copy files over as root, or change the ownership and/or permissions of that directory so you can write your files there. As an alternative, you can do some additional Apache configuration so that you can keep your files somewhere under your home directory. You can even set up multiple sites that way.



Tags: Apache, HowTo, LAMP, linux, php, phpMyAdmin, precise, Ubuntu, web development

Comments

15 Responses to “Installing LAMP on Ubuntu 12.04 Precise Pangolin”







LAMP [Linux,Apache,Mysql,PHP] is the most winning combination in today s growning internet to develop dynamic PHP applications. The linux part is replaced by any linux distro like Ubuntu 11.10, Fedora 15, Opensuse 12.1, Debian etc… Linux is the most fast and safest platform to develop PHP applications for todays web.

How to install an Apache2 webserver on an Ubuntu 11.10 with Mysql and PHP is the most popular question. The answer is very simple. With some command line commands or a search in Latest Ubuntu Software center everyone can install the LAMP stack in ubuntu 11.10.

How To Install LAMP (Linux, Apache, MySQL, PHP) On Ubuntu 11.10

All the commands will be executed in the terminal. You can open a terminal using Ctrl+Alt+T shortcut.

Install Mysql 5 on Ubuntu 11.10

The first step is to install Mysql Server in Ubuntu 11.10. Just paste the command in the terminal and press enter:
sudo apt-get install mysql-server mysql-client
This will install the mysql server and mysql client on your ubuntu 11.10. After that it will as the password for the root user of mysql. You can set a password for that. By using this password you can enter into a mysql command mode.

Install Apache 2 Server on Ubuntu 11.10

The next step is install Apache server in ubuntu 11.10. The apache server is used to execute PHP files in the server. By default the server will run on http://localhost and port 80. You can change the server names and ports in apache configuration file.
sudo apt-get install apache2
After installing the apache server Just open firefox and type http://localhost.
You will get a message.
IT Works! This is the default web page for the server. The web server software is running but no content has been added. yet
This is the default apache welcome page. You can edit this file in /var/www/index.html file.
The configuration file for apache server is at  /etc/apache2/apache2.conf.
Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.

Install PHP 5 on Ubuntu 11.10

The next step is to install php5 on ubuntu 11.10 and extensions for php5.
We can install PHP5 and the Apache PHP5 module by using the following commands.
sudo apt-get install php5 libapache2-mod-php5
We must restart Apache afterwards:
/etc/init.d/apache2 restart

Get the PHP information in Ubuntu 11.10

Get the detailed information of PHP 5 from apache server.
For that just create a file info.php on /var/www
sudo gedit /var/www/info.php
put the following code
<?php
phpinfo();
?>

Just call the file in your web browser using the url : http://localhost/info.php.
You will get the complete information of your current php installation.

Getting MySQL Support In PHP5 on Ubuntu 11.1o

To get MySQL connectivity in PHP, we want to install   the php5-mysql package. For that use the following command:
sudo apt-get install php5-mysql

Install PHP Modules on Ubuntu 11.10

It’s a good idea to install some other PHP5 modules as well as you might need them for your applications.
You can search for available PHP5 modules like this:
sudo apt-cache search php5
Install the PHP modules in ubuntu 11.10 by using the following command:
sudo apt-get install  php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt
php5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl
These are the php modules to use gd library, curl, pear modules, image magic, mcrypt extension, memmory cache, tidy, xmlrpc, sqllite database etc
Now restart Apache2 Server
sudo /etc/init.d/apache2 restart
Now refresh http://localhost/info.php in your firefox browser and scroll down to the modules section again.
You should now find lots of new modules there, including the MySQL module:

Install phpMyAdmin in Ubuntu 11.10

phpMyAdmin is a great programme to manage mysql database from your web browser. The latest version includes very nice interface and great utilities like inplace edit etc.. By using phpMyAdmin you can create database, edit tables, insert data, export mysql database etc..
To install PHPMyAdmin use the command:
sudo apt-get install phpmyadmin
You will see the following questions after installation:
Web server to reconfigure automatically: <– apache2
Configure database for phpmyadmin with dbconfig-common? <– No
Afterwards, you can access phpMyAdmin under http://localhost/phpmyadmin/

Chive

Chive is also another great programme to manage mysql database from a web browser. This is project is developed using YII PHP frame work. You can download chive from their website.
To install chive on ubuntu 11.10 just extract the zip file and copy the directory chive to /var/www . and then you can access chive mysql manager from web browser http://localhost/chive
You can also use libreoffice base to access and edit mysql database. There is a mysql query builder and entity relation manger in libreoffice base.

Install PHP IDE Geany in Ubuntu 11.10

For developing PHP application you need a good IDE. Geany is a light weight fast ide developed using GTK library. You can install geany by using the command:
sudo apt-get install geany
There are other IDEs like PHP Eclipse, Komodo Edit, Netbeans, gPhpedit, bluefish etc for editing and developing php applications.
Also there are lot of php frameworks available for developing great applications in php like Codeigniter, Cake PHP, Fuel PHP, Kohana, Yii, Zend Framework, Symphony etc… You can try one.









No comments:

Post a Comment