Thursday, January 12, 2012

How to install Lampp/Xampp and how to secure Lampp/Xampp on Unix

INSTALLING LAMPP

1. Download the lampp installation file from http://www.apachefriends.org/en/xampp-linux.html

2. Take terminal and type "sudo su" and enter root password to become root user

3. Extract the file using tar command " tar xvfz {downloaded_file_name} /opt"

    Donot extract the files using any other extractors as it will extract with wrong permissions ! and may lead to not proper working of the server !!

4. After extracting you can Start your server by typing "/opt/lampp/lampp start"

5. To view the default site , fire up your browser and type 127.0.0.1 in the address bar .. You should see the default xampp page here :) 

CHANGE OWNERSHIP TO YOUR ACCOUNT

1. As a root user go to "/opt/lampp" folder using the cd command 

2. Then change the ownership of the htdocs folder by typing this command 
 "chown -R username:username htdocs"

3. Then from here move to /opt/lampp/etc folder to associate your username with the apache server .Find the file called httpd.conf and open it with nano or gedit and find the line  "User nobody" and change it to "user {username}"

4. Now restart lampp to see the effect :)  you can restart lampp by typing this in 
"/opt/lampp/lampp restart"

To view the status if the server type "/opt/lampp/lampp status"
To stop the server type "/opt/lampp/lampp stop" and "/opt/lampp/lampp start" to start the server again 

5. Also go to "/opt/lampp/phpmyadmin"   and type "chown username:username config.inc.php"  to change the ownership of the config files and make it readable .

ENABLING BASIC LAMPP SECURITY FEATURES

1. In the terminal type "/opt/lampp/lampp security"  and give the password for everything and secure it .

RUNNING LAMMP AT STARTUP 


1. Move to "/etc/init.d/" folder and type this commad "sudo vi lampp" and add these lines
 "#!/bin/bash
/opt/lampp/lampp start"
save the file 

2. In the terminal type "sudo chmod +x /etc/init.d/lampp"  to give execute permission for that script .

3. Use update-rc.d to install init scripts to all runlevel by typing 
"sudo update-rc.d lampp defaults"

7 comments:

  1. This is a great guide, thanks.
    In ubuntu 11.10 all goes fine except "RUNNING LAMMP AT STARTUP", didn't work for me:
    To make this work, one more command:
    sudo chmod +x /etc/init.d/lampp

    ReplyDelete
    Replies
    1. Guess i left it out !Thanks for the correction :)

      Delete
  2. Thank you very much for this walkthrough, I have been racking my brain all day dealing with netbeans/xampp setup issues and this really helped me cut off some time.

    ReplyDelete
  3. "3. Then from here move to /opt/lampp/etc folder to associate your username with the apache server . over here find the line "User nobody" and change it to "user {username}""

    where is the line "User nobody"?? - under /etc folder there are several files / subfolders - where is the change to be made?

    ReplyDelete
    Replies
    1. I'd like to know as well?

      Delete
    2. in the /opt/lampp/etc folder find the file called httpd.conf and open it with nano or gedit and find the line

      Delete
    3. it must have been a wrong typo ! its corrected now .

      Delete