How To Set Up A Ubuntu/Debian LAMP Server

Hello, now I'm going to give some tutorial to set up LAMP Server and to use it. Some people are confused to use this local server at UBuntu/Debian. Other linux will catch up later.

Firstly, you need to have this things inside your ubuntu/debian
  • Apache 2 - Linux Web server
  • MySQL 5 - MySQL Database Server
  • PHP4/5 - PHP Scripting Language
  • phpMyAdmin - Web-based database admin software.
You need a system that has a minimum requirement of Debian/Ubuntu version of linux with at least 256MB of RAM available. Anything less than this minimum ram will cause lot of problems since we are running a server along especially mysql and webmin requires lot of RAM to run properly. Mysql will give you this nasty error "cannot connect to mysql.sock" if you dont have enough memory in your server. But I recommend you to have at least 512 of RAM available for more better performance.

Download PuTTy if you are accessing your server through SSH. Just enter the IP of your server with root login to access your host. You also can use Webmin, Webmin is a freely available server control panel and we will setup this once we have completed the LAMP server and Mail Server. Webmin makes more easier for us to fine tune our linux box. You need to use both of those software.

OK, now all things are set up perfectly, now you need to refresh the repositories in your ubuntu/debian by typing: sudo apt-get update

After following those steps, now we're ready to perform the installation.

1. Installing Apache + PHP


Apache is one of the most famous web server which runs on most linux based servers. With just few commands you can configure apache to run with PHP 4 or PHP 5. You can choose the PHP type there 4 and 5, and pick one of the (DO NOT INSTALL BOTH OF THEM) Choose between PHP 4 or PHP 5.

PHP 4 & apache Command(Type in terminal):
sudo apt-get install apache2 php4 libapache2-mod-php4

Or
PHP 5 & apache Command(Type in terminal):
sudo apt-get install apache2 php5 libapache2-mod-php5

Apache configuration file is located at: /etc/apache2/apache2.conf and your web folder is /var/www.

To check whether php is installed and running properly, just create a test.php in your /var/www folder with phpinfo() function exactly as shown below.

Type: nano /var/www/test.php

And here is the results after you type at the terminal:

# test.php


Point your browser to http://ip.address/test.php or http://domain/test.php and this should show all your php configuration and default settings.Use konqueror or firefox to perform this.You can edit necessary values or setup virtual domains using apache configuration file.

2. Installing MySQL Database Server

Installing mysql database server is always necessary if you are running a database driven ecommerce site. Remember running mysql server to a fair extend requires atleast 256mb of RAM in your server. So unless you are running database driven sites you dont absolutely need mysql. The following commands will install mysql 5 server and mysql 5 client

type:
sudo apt-get install mysql-server mysql-client php5-mysql
OR
If you have already installed php4, you should make a slight change like this:
sudo apt-get install mysql-server mysql-client php4-mysql

N.B: The configuration file of mysql is located at: /etc/mysql/my.cnf

Creating users to use MySQL and Changing Root Password

By default mysql creates user as root and runs with no passport. You might need to change the root password.

To change Root Password:

mysql -u root
mysql> USE mysql;
mysql> UPDATE user SET Password=PASSWORD('new-password') WHERE user='root';
mysql> FLUSH PRIVILEGES;

You must never use root password, so you might need to create a user to connect to mysql database for a PHP script. Alternatively you can add users to mysql database by using a control panel like webmin or phpMyAdmin to easily create or assign database permission to users. We will install Webmin and phpmyadmin during later once we complete basic installation.

3. PhpMyAdmin Installation

PhpMyAdmin is a really nice web based database management and administration software and easy to install and configure under apache. Managing databases with tables couldnt be much simpler by using phpmyadmin. And here is the code to install PhpMyAdmin:
sudo apt-get install phpmyadmin

The phpmyadmin configuration file is located at: /etc/phpmyadmin folder.

To set up under Apache all you need to do is include the following line in /etc/apache2/apache2.conf(put this code inside the apache2.conf): Include /etc/phpmyadmin/apache.conf

Now restart Apache by typing this code:

/etc/init.d/apache2 restart

Point your browser to: http://domain/phpmyadmin

That's it! MySQL and phpMyAdmin are ready. Log in with your mysql root password and create users to connect to database from your php script. You can perform some installation and I already provide the tutorial to installing joomla at your apache, please visit this link to install joomla at your LAMP: http://allforlinux.blogspot.com/2008/05/installing-joomla-in-ubuntu-tutorial.html



Bookmark and Share

9 comments:

  1. bro, for newbies I suggest them to use XAMPP for Linux. It's much easier and faster to setup a web server plus have all necessary program such as apache, php,mysql and ftp..newbies out there, you all can check a xampp tutorial running on ubuntu at http://melayubuntu.blogspot.com/2008/07/jalankan-web-server-anda-sendiri.html (in malay).

    by the way, nice job bro..I also did the same as yours in my PCLinuxOS Bussiness Edition server..serving as inhouse web server and file sharing for almost 2 years..

    ReplyDelete
  2. Great step by step instructions. Worked a treat! Thanks!

    ReplyDelete
  3. You reаlly make it seem so eaѕy
    with your preѕentation but I find thiѕ matter to be аctuallу something that I thіnκ I woulԁ nеver unԁerstanԁ.
    It seemѕ too comρlicateԁ anԁ eхtгemely broad fοг
    me. I am looking forwarԁ for your nеxt ρost, I
    wіll try to get the hang of іt!

    Have a look at my webpagе - multiregion Website

    ReplyDelete
  4. Τhе other day, while Ι wаs
    at wοrκ, my siѕter ѕtοle mу iPad and tested to see if it can survive a thirty foоt drop, just so she can bе a youtube sensation.
    My iΡad is noω ԁestroyed and she has 83 νiеws.

    I know this is completely off topic but I had to ѕhare it wіth someonе!



    Haνe a looκ at my blog; website erstellen programm freeware mac

    ReplyDelete
  5. Fοr the reason thаt the admin of this web site is working, no uncertainty very quicκly іt will be famous, due to its qualitу
    contents.

    Mу homеpage - register domain privately

    ReplyDelete
  6. Excellent weblog right here! Aԁditіonallу your website loads up very fast!
    What ωeb host aгe you the uѕe of? Сan Ι
    am getting youг affiliate link οn your host? I
    desire my site loаded up as fast as youгѕ lol

    Chесκ out mу pаge: diseño web

    ReplyDelete
  7. Hello! I rеalіze this is kind of оff-tοpic but I had tо asκ.
    Dоes managing а well-establіsheԁ websіte like yours геquiгe a
    largе amount οf worκ? I аm completely
    neω to oрeratіng а blog howevег I do wrіte in my journal on a daily basіѕ.
    ӏ'd like to start a blog so I can easily share my personal experience and views online. Please let me know if you have any suggestions or tips for brand new aspiring bloggers. Appreciate it!

    My web-site: maak website

    ReplyDelete
  8. I blog quite often anԁ Ӏ rеally appreciаte your content.
    Thіs grеat aгtіclе has truly pеakеd my interest.

    I am gоing to booκmаrk yοur sitе аnd keeр checking for nеw informаtіon about once a week.
    I оρted in for your Feed too.

    my wеbsite ... Como criar um site

    ReplyDelete
  9. What і dοn't realize is in reality how you're not actually
    a lot more ѕmartlу-liκеd
    thаn уou may be гight now. You're so intelligent. You understand therefore considerably in relation to this matter, made me in my view believe it from a lot of varied angles. Its like men and women don't seеm to bе іnteгeѕted exceрt it's one thing to do with Woman gaga! Your personal stuffs nice. All the time handle it up!

    Feel free to visit my homepage - http://www.sahmeran-board.biz/forum//index.Php/index.php?page=user&Userid=612

    ReplyDelete

Please feel free to fill the comments, you can use English, Bahasa Indonesia/Melayu, Chinese, and French. PLEASE! DO NOT SPAM THE COMMENT FORM.