Saturday, October 31, 2009

Installing lamp (apache mysql php) in linux

Everything can be done easily through the command line

sudo apt-get install apache2

this will install apache server on your system

can be checked by typing
http://localhost in your browser window

if you get a message It Works! then its success

now to install php
type

sudo apt-get install php5 libapache2-mod-php5

and now restart the apache to see if its working

type

sudo /etc/init.d/apache2 restart

now create a file say with the name testphp.php in your www folder(/var/www)

you should open it as root so
type: sudo gedit /var/www/testphp.php

and type


phpinfo();
?>


now if you type http://localhost/testphp.php in your browser you will get the file giving the information on php installed on your system

Once again open up Terminal and then copy/paste this line:
sudo apt-get install mysql-server

(optional). In order for other computers on your network to view the server you have created, you must

first edit the "Bind Address". Begin by opening up Terminal to edit the my.cnf file.

gksudo gedit /etc/mysql/my.cnf

Change the line

bind-address = 127.0.0.1


And change the 127.0.0.1 to your IP address.

To change the password of the root user

type in terminal, this will take you to the mysql console
mysql -u root

Following that copy/paste this line:

mysql> SET PASSWORD FOR 'root'@'localhost' = PASSWORD('yourpassword');

(Make sure to change yourpassword to a password of your choice.)

To intall phpMyAdmin

To install a program called phpMyAdmin which is an easy tool to edit databases.Copy/paste the following line into Terminal:
sudo apt-get install libapache2-mod-auth-mysql php5-mysql phpmyadmin

After that is installed our next task is to get PHP to work with MySQL. To do this we will need to open a file
entitled php.ini. To open it type the following:

gksudo gedit /etc/php5/apache2/php.ini

Now we are going to have to uncomment the following line by taking out the semicolon (;).
Change this line:

;extension=mysql.so

To look like this:

extension=mysql.so


Now just restart Apache and you are all set!

sudo /etc/init.d/apache2 restart

5 comments:

  1. Installing lamp (apache mysql php) in lunx

    "lunx"
    What is that?

    ReplyDelete
  2. very nice blog sherin...useful info here...keep it up!

    ReplyDelete
  3. dude i think it is <? phpinfo(); ?>. You missed the first "<?".
    and dont install lamp in " lunx "..do it in linux

    IRFAN

    irfantechinfo.blogspot.com

    ReplyDelete
  4. hehe... that was typing mistake.

    what irphan said is correct

    but the blog is ignoring the first line.

    ReplyDelete
  5. Instead of doing all this, you can do the following -

    1.) sudo tasksel in command prompt
    2.) check the option of LAMP server using spacebar
    3.) press enter & you are done !

    ReplyDelete