installing apache2 with php5 and mysql support on ubuntu 12.04 lts (lamp)

15
Options For This Howto VMware Images: Apache2 With PHP5 And MySQL Support On Ubuntu 12.04 LTS (LAMP) (x86_64) (635.7 MB) (05/02 /2012) VMware Image Import Guide List of all VMware Images Free Support Paid Support Navigation [+] Expand [-] Collapse Howtos Linux Android CentOS Debian Fedora Kernel Mandriva PCLinuxOS SuSE Ubuntu Web Server Apache Cherokee Lighttpd nginx Backup Control Panels ISPConfig DNS BIND MyDNS PowerDNS djbdns Desktop Email Anti-Spam/Virus Postfix FTP High-Availability Monitoring MySQL Register Login Contribute Subscribe RSS News FAQForge ISPConfig Subscribe Contribute Forums Howtos Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php... 1 of 15 03/06/2013 03:51 PM

Upload: sanjay-sangwan

Post on 01-Dec-2015

47 views

Category:

Documents


3 download

DESCRIPTION

apache2 with php5

TRANSCRIPT

Page 1: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Options For ThisHowto

VMware Images:

Apache2 With PHP5And MySQL SupportOn Ubuntu 12.04 LTS(LAMP) (x86_64)(635.7 MB) (05/02/2012)

VMware Image ImportGuide

List of all VMwareImages

Free SupportPaid Support

Navigation

[+] Expand [-] Collapse

Howtos

Linux

Android

CentOS

Debian

Fedora

Kernel

Mandriva

PCLinuxOS

SuSE

Ubuntu

Web Server

Apache

Cherokee

Lighttpd

nginx

Backup

Control Panels

ISPConfig

DNS

BIND

MyDNS

PowerDNS

djbdns

Desktop

Email

Anti-Spam/Virus

Postfix

FTP

High-Availability

Monitoring

MySQL

Register Login Contribute Subscribe RSS

NewsFAQForgeISPConfigSubscribeContributeForumsHowtos

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

1 of 15 03/06/2013 03:51 PM

Page 2: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Programming

C/C++

PHP

Samba

Security

Anti-Spam/Virus

Storage

Virtualization

KVM

OpenVZ

VMware

VirtualBox

Xen

Other

FreeBSD

Commercial

Mini-Howtos

Forums

Contribute

Subscription

Login

Site Map/RSS Feeds

User login

Username:

Password:

Remember Me?

Log in

Create a new accountRequest new password

Facebook

HowtoForge

Like 4,783

Who's online

There are currently 2 usersand 3342 guests online.

HowtoForgeForums

Add Templates forresellers

Create multiplelocal IP

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

2 of 15 03/06/2013 03:51 PM

Page 3: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Posts to Mailmanlist bouncing-User unknown

ISPConfigVirtualHost issue

User underISPCONFIG 3.0.5.1cant' see allmails

ISPConfig notupdating server

Db's dumps inseperate files?

Roundcube +Postfix send itemsproblems

Open ISCONFIG

ERROR: Unable toload SQL-Dump intodatabase ...

News

Humble Bundle withAndroid 5!

Acer set to ship 7MAndroid tablets in 2013

Valve's Steam Box WillMost Likely Use An X.OrgServer

OpenOffice versusLibreOffice versus TheWorld

Spec aims to advanceinteroperable carconnectivity

A fresh litter of PuppyLinux releases: Wary, Racyand Quirky

Linus Torvalds really likesGoogle's ChromebookPixel

Installing Nginx With PHP5(+ PHP-FPM) And MySQLSupport On Scientific Linux6.3

'Blender Master Class'Gets A+ in 3D GraphicsInstruction

Apache OpenOfficereaches 40 milliondownload milestone

more

Recent comments

ask3 hours 54 min ago

I'm running 11.04Natty10 hours 26 min ago

no chroot jail?11 hours 7 min ago

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

3 of 15 03/06/2013 03:51 PM

Page 4: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

19 TweetTweet 55

doesn't work w/Apache 2.411 hours 8 min ago

Re: Sorrrrrrrrrrrrrrrrrrrrrrrrrry19 hours 16 min ago

Bash script to automatethis install23 hours 40 min ago

Re: Virtualization usingLVM -- Install guest OSs1 day 28 min ago

Nice one Thanx1 day 5 hours ago

read the file1 day 22 hours ago

Quick Courier Config2 days 10 hours ago

Newsletter

Subscribe toHowtoForgeNewsletterand stay informed aboutour latest HOWTOs andprojects.

enter email address

Submit

(To unsubscribe fromour newsletter, visit thislink.)

English | Deutsch | Site Map/RSS Feeds | Advertise

You are here: Home » Howtos » Linux » Ubuntu » Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.04 LTS (LAMP)

Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.04 LTS (LAMP)

Want to support HowtoForge? Become a subscriber!

Submitted by falko (Contact Author) (Forums) on Thu, 2012-05-10 17:45. :: Ubuntu | Web Server |Apache | MySQL | PHP

Installing Apache2 With PHP5 And MySQL Support OnUbuntu 12.04 LTS (LAMP)

Version 1.0

Author: Falko Timme <ft [at] falkotimme [dot] com>

Follow me on Twitter

Last edited 05/02/2012

Like 49 Send

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

4 of 15 03/06/2013 03:51 PM

Page 5: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

LAMP is short for Linux, Apache, MySQL, PHP. This tutorial shows how you can

install an Apache2 webserver on an Ubuntu 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 address 192.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 user root@localhost as well as

[email protected], 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, and you should see the Apache2 placeholder page (It works!):

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

5 of 15 03/06/2013 03:51 PM

Page 6: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Apache's default document root is /var/www on Ubuntu, and the configuration file is /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.

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 lots of useful details about our PHP installation, such as the installed PHP version.

vi /var/www/info.php

<?phpphpinfo();?>

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

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

6 of 15 03/06/2013 03:51 PM

Page 7: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

As you see, PHP5 is working, and it's working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll

further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don't have

MySQL support in PHP5 yet.

6 Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. 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:

apt-cache search php5

Pick the ones you need and install them like this:

apt-get install php5-mysql php5-curl php5-gd php5-intl php-pear php5-imagick php5-imap php5-mcryptphp5-memcache php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpcphp5-xsl

Now restart Apache2:

/etc/init.d/apache2 restart

Now reload http://192.168.0.100/info.php in your browser and scroll down to the modules section again. You should now

find lots of new modules there, including the MySQL module:

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

7 of 15 03/06/2013 03:51 PM

Page 8: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

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/:

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

8 of 15 03/06/2013 03:51 PM

Page 9: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

19 TweetTweet 55

8 Links

Apache: http://httpd.apache.org/

PHP: http://www.php.net/

MySQL: http://www.mysql.com/

Ubuntu: http://www.ubuntu.com/

phpMyAdmin: http://www.phpmyadmin.net/

Copyright © 2012 Falko Timme

All Rights Reserved.

add comment | view as pdf | print

Please do not use the comment function to ask for help! If you need help, please use our forum.Comments will be published after administrator approval.

Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.04 LSubmitted by Anonymous (not registered) on Sat, 2012-12-08 13:05.

ottimo ha funzionato subito

perfetta e chiara, complimenti

reply | view as pdf

Problem with installing phpmyadminSubmitted by Ravi Kumar (not registered) on Sat, 2012-12-08 08:01.

Thank you very much for your nice guidelines.

It worked pretty well up to step 6 but get stucked at 7th step. During 7th step it asked two questions, in first case i allowed - "Apache2" and

in 2nd question which was long with with some other information also (e.g do you have any database etc) then i choose the option as "NO".

Then after refreshing the page with replacing info.php to phpmyadmin, there was not any sign of phpmyadmin page.

What should i do now ?. Thank you again for your help.

Ravi Kumar

reply | view as pdf

Re: Problem with installing phpmyadminSubmitted by Ravi Kumar (not registered) on Mon, 2012-12-10 18:43.

Hi everyone,

After 2-3 days i got the simple solution of my problem. In my case upto step 6 (localhost/php.info) everything worked very well but 7th

step i.e localhost/phpmyadmin didn't show anything.

I came to know from another tutorial that phpmyadmin is poor in making automatic link with apache2, so you have to makeup a

symbolic link as:

cd /var/www

sudo ln -s /usr/share/phpmyadmin phpmyadmin

and that's it. It worked !!!

I login as "username =root" and "password=rootpassword" , please enter the correct password while u entered during ur mysql

Like 49 Send

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

9 of 15 03/06/2013 03:51 PM

Page 10: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

installation. It worked for me, n i hope it will definitely work for you too.

Ravi Kumar (BIC, IMTECH)

Chandigarh

reply | view as pdf

Re: Re: Problem with installing phpmyadminSubmitted by Kamil (not registered) on Sat, 2013-02-09 22:20.

Thanks dude! I had the same problem and you helped me a lot!

reply | view as pdf

Re: Re: Problem with installing phpmyadminSubmitted by Anonymous (not registered) on Fri, 2013-01-04 23:40.

Thanks Ravi, had the same problem.

reply | view as pdf

Re: Re: Problem with installing phpmyadminSubmitted by Cristian (not registered) on Wed, 2012-12-26 21:39.

Thanks Ravi!

reply | view as pdf

this is really a wonderfulSubmitted by uday (not registered) on Tue, 2012-10-16 17:48.

this is really a wonderful tutorial

reply | view as pdf

GreatSubmitted by KBC (not registered) on Fri, 2012-09-21 14:51.

good job buddy nice and easy to understand guide. TNX

reply | view as pdf

ThanksSubmitted by Randi\y III (not registered) on Tue, 2012-09-18 06:48.

thanks for your help....

it is a big help for me....^^

reply | view as pdf

access to var/wwwSubmitted by Afandi (not registered) on Thu, 2012-09-06 21:58.

Hi, many thanks

I have successed until no #4 but when create info.php, I can save the file into var/www

it said you do not have the permission.

Please advise thanks

reply | view as pdf

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

10 of 15 03/06/2013 03:51 PM

Page 11: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Re: access to var/wwwSubmitted by Anonymous (not registered) on Wed, 2012-10-24 07:05.

save your file on the desktop

try this on terminal

su

your password

cd Desktop

mv info.php /var/www

reply | view as pdf

Re: access to var/wwwSubmitted by Kunal (not registered) on Tue, 2012-09-11 18:13.

Use sudo before the command and enter password when prompted.

like

sudo vi /etc/www/info.php

reply | view as pdf

Great!!!, all went well,Submitted by INCH-5 (not registered) on Wed, 2012-08-29 13:20.

Great!!!, all went well, tried it on my Vmware, just that i was confronted with "username/password" option - but after a while i figured it out

Username = root

Password = "yourrootsqlpassword" one provided during Msql installation.

reply | view as pdf

Thanks,Submitted by Anonymous (not registered) on Thu, 2012-08-23 16:57.

Thanks, it worked first time without any problem

reply | view as pdf

after the command-apt-getSubmitted by Anonymous (not registered) on Tue, 2012-08-14 09:42.

after the command-

apt-get install mysql-server mysql-client

i wasnt prompted for the user name or password!!!

what could be the problem

reply | view as pdf

tasksel shortcutSubmitted by Gg (not registered) on Wed, 2012-08-01 08:55.

Thanks for the nice and pretty tutorial!

I just wanted to mention that it might be worth considering the tasksel utility too. A little less control on things, but overall a quite immediate

approach.

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

11 of 15 03/06/2013 03:51 PM

Page 12: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

You just need to install the tasksel package from repos:

sudo apt-get update

sudo atp-get install tasksel

Then just run tasksel as superuser:

sudo tasksel

What you get on screen is a whole bunch of configurations you can change your system into. Just scroll to "LAMP server", select it with space

bar and press enter. All packages to be installed are automatically included for you. Along the installation you'll be asked to provide pretty

much the same info such as MySQL password etc. Once done, you'll have your LAMP server (or any other config you selected) ready to go.

Hope it helps!

Gg

reply | view as pdf

Good jobSubmitted by Hakob (not registered) on Wed, 2012-07-18 19:22.

Thanks for this tutorial. It is really best tutorial for this kind of installations...

reply | view as pdf

Perfect, worked first try.Submitted by Allan (not registered) on Sat, 2012-07-07 21:19.

Perfect, worked first try.

reply | view as pdf

Thank you for the superbSubmitted by Anonymous (not registered) on Thu, 2012-07-05 08:50.

Thank you for the superb guide.

Although regarding phpmyadmin, have to say that I need to do the:\

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.confsudo /etc/init.d/apache2 reload

as suggested in https://help.ubuntu.com/community/phpMyAdmin.

But I have to comment out the

Include /etc/phpmyadmin/apache.conf

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

12 of 15 03/06/2013 03:51 PM

Page 13: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

to ensure it works (since I followed the help step-by-step).

Hope this will help others having the same problem.

reply | view as pdf

Re: Thank you for the superbSubmitted by jda (not registered) on Wed, 2012-11-07 23:57.

Quote 'Although regarding phpmyadmin, have to say that I need to do etc '

Me too...

reply | view as pdf

Re: Thank you for the superbSubmitted by gaodayue (not registered) on Sat, 2012-09-08 14:25.

thanks for your remind and the helpful link

reply | view as pdf

Re: Thank you for the superbSubmitted by dbdyp_leo (registered user) on Sun, 2012-08-19 13:27.

Thank you for your details.

I did this as follows:

sudo dpkg-reconfigure -plow phpmyadmin

sudo ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf

sudo /etc/init.d/apache2 reload

as suggested in https://help.ubuntu.com/community/phpMyAdmin.(My Ubuntu version is 11.04)

reply | view as pdf

Re: Re: Thank you for the superbSubmitted by Wim Anckaert (not registered) on Thu, 2012-09-13 08:40.

tx, this worked also on ubuntu 12.04

reply | view as pdf

Great Post!Submitted by Josir (registered user) on Wed, 2012-07-04 16:37.

Thanks for your post. I got a LAMP server in 5 minutes!!! Work like a charm!

You could also insert some performance tips after the basic install.

reply | view as pdf

Great tutorial. I did thisSubmitted by Anonymous (not registered) on Thu, 2012-06-28 01:03.

Great tutorial. I did this really fast. I have to add that I needed to add the line:

Include /etc/phphmyadmin/apache2.conf

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

13 of 15 03/06/2013 03:51 PM

Page 14: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

to the file /etc/apache2/apache2.conf for getting the phphmyadmin page to work.

reply | view as pdf

ThanksSubmitted by Luiz (not registered) on Fri, 2012-06-22 00:33.

Your tutorial saved me days of work.

Thanks a lot.

Luiz

reply | view as pdf

goog installationSubmitted by Anonymous (not registered) on Thu, 2012-06-21 00:36.

thanks my friend cool, please add symbol link phpmyadmin direct acces

reply | view as pdf

Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.04..Submitted by Anonymous (not registered) on Thu, 2012-05-31 05:22.

Spent a day trying to get tomcat to do some simple stuff. Man was I happy to land on this website! I stopped the tomcat service, installed

Apache2 (already had the L, M & P) and BAM! default web page, NO PROB!!! Took me all of five minutes! Now, I'm in tall cotton; even the

food tastes better :-)) MANY THANKS!!!

reply | view as pdf

Re: Installing Apache2 With PHP5 And MySQL Support On Ubuntu 12.Submitted by sigma (not registered) on Sat, 2013-02-16 23:15.

huge! Works the same on ubuntu12.10. Thanks for this great tutorial

reply | view as pdf

Howtos | Mini-Howtos | Forums | News | Search | Contribute | SubscriptionSite Map/RSS Feeds | Advertise | Contact | Disclaimer | Imprint

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

14 of 15 03/06/2013 03:51 PM

Page 15: Installing Apache2 With PHP5 and MySQL Support on Ubuntu 12.04 LTS (LAMP)

Copyright © 2013 HowtoForge - Linux Howtos and TutorialsAll Rights Reserved.

Installing Apache2 With PHP5 And MySQL Support On ... http://www.howtoforge.com/installing-apache2-with-php...

15 of 15 03/06/2013 03:51 PM