Peppermint | Linux OS Community Forum
It is currently Sun Mar 29, 2020 2:18 pm

All times are UTC - 5 hours [ DST ]

Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: [One][Ice][Two] How to install the LAMP stack (server)
PostPosted: Wed May 26, 2010 6:34 pm 
User avatar

Joined: Thu May 20, 2010 8:56 am
Posts: 2132
Class: Installation Howto
Difficulty: Involved
Time: Basic install shouldn't take more than fifteen minutes on a good connection with everything done efficiently
Desirability: Situational: Essential for serving or testing dynamic web content or applications locally


This howto describes the process of installing the LAMP (Linux, Apache, MySQL, php) stack on PeppermintOS. There are two ways of doing this, an automated way and a manual way. Team Peppermint recommend the automated way as virtually nothing should be able to go wrong, at least to begin with.

I've included manual instructions to give users who may need to install manually for whichever reason the basic package names and steps they'll need to take. For example, when installing manually the user may choose to not install one of the components, e.g. MySQL. These instructions also contain guidance on creating a new default site, test the php install and add a table to MySQL.

In both tutorials It is assumed that such users will be prepared to take responsibility for securing and configuring their LAMP installation according to their own needs.

All commands given are to be run from terminal. Remember it is best to understand what these commands will do before running them. Consult manual ("man") pages if necessary with:

man command

The automated way

Open a terminal and enter

sudo tasksel install lamp-server

The program will automatically download and install the LAMP stack. During this process it will ask you to choose the root password for MySQL. It is quite important not to lose this, and if the system is to serve externally it is important that it be secure.

Tasksel won't create any database tables. For that, consult the appropriate section of the manual installation which follows. Because you have already set the root password for MySQL, it is necessary to gain access to it with

mysql -u root -p

and enter the password you created during the installation process.

The manual way

This howto is an adapted version of Ubuntu's old community documentation. Package versions have been updated to reflect current status at the time of writing. This howto is also trimmed down to the essentials, and is intended for users who simply need a quickstart guide to getting LAMP up and running on their local computer.

This tutorial assume a knowledge of installing and removing packages.

Each part of the LAMP stack can be installed independently of the others. For example, I wouldn't normally install MySQL since I don't develop with it.

Starting Over, or How to Remove the LAMP Stack and Have Another Beer

It is with no small sense of irony that I begin with this, as does Ubuntu's documentation, but the LAMP stack installation process is somewhat involved and things can go wrong. The following is the list of all the packages installed by following this howto, incase they need to be removed or purged following an accident.

apache2 apache2-mpm-prefork apache2-utils apache2.2-common libapache2-mod-php5 libapr1 libaprutil1 libdbd-mysql-perl libdbi-perl libmysqlclient16 libnet-daemon-perl libplrpc-perl mysql-client-5.0 mysql-common mysql-server mysql-server-5.1 php5-common php5-mysql

Removing these packages may well necessitate the removal of dependent packages. It is worth doing a simulated run first to check for this.


Install the "apache2" metapackage. It installs the necessary files for the http server.

Also, set an appropriate server name.

echo "ServerName localhost" | sudo tee /etc/apache2/conf.d/fqdn

Virtual Hosts - Optional (Skip to php installation if you're happy using /var/www)

By default, Apache will serve one site which it calls 'default', and is what you see when you navigate to http://localhost or But you can have as many as you like (within reason). This is also ideal for non-production web servers, as it avoids the need to chown /var/www to your regular user.

For example, let's create a site at ~/myMintySite/.

  1. It's probably best to actually
    mkdir ~/myMintySite

    Apache will only give a warning if it's actually not there, but there's maybe not much point if there's no site to serve. Create a landing page, too:
    echo '<b>Hello world!</b>' > ~/myMintySite/index.html
  2. Copy the default website configuration to begin:
    sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/myMintySite
  3. Open the new site configuration file in a text editor
  4. Change the DocumentRoot to the appropriate location (in this example /home/user/myMintySite - replace user with your username!)
  5. Change the Directory directive, replacing <Directory /var/www> to the appropriate location <Directory /home/user/myMintySite/>
  6. If you're planning on serving lots of sites, it's advisable to create separate Error and Custom logs by modifying those lines appropriately
  7. Save the file

To deactivate the default site and activate the new one, two utilities are used:

sudo a2dissite default && sudo a2ensite myMintySite

And do as we're told to restart apache and activate the new configuration:

sudo /etc/init.d/apache2 restart

In a web browser, browse to http://localhost to test the new configuration.


Install the "php5" and "libapache2-mod-php5" packages. Additionally, make sure the mod is activated and restart apache:

sudo a2enmod php5 && sudo /etc/init.d/apache2 restart

Test that it works by adding a link to a test page in the index.html, and creating the test page:

echo '<br/><a href="test.php">Click here to test php</a>' >> ~/myMintySite/index.html && echo '<?php phpinfo(); ?>' > ~/myMintySite/test.php

Reload http://localhost and click on the link. If you see php's diagnostic report then the install's worked. Note: Using Opera, I found that I had to exit and restart Opera to get it to stop offering to download the php page.


Install these packages: "mysql-server", "libapache2-mod-auth-mysql", and "php5-mysql".

Now set the root password:

mysql -u root

(This opens the mysql console, continue with, and replace yourpassword with, well, your password)

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

This should return

Query OK, 0 rows affected (0.00 sec)

Now to create a database, or there wasn't much point to the exercise:

mysql> CREATE DATABASE myMintyDatabase;

and create a user, remembering to replace youruser and yourpassword with the appropriate details for your own user:


All done

Your basic LAMP server is now ready for your development needs, have fun!


Last edited by enginerd on Sat Aug 06, 2011 10:22 am, edited 2 times in total.
Thanks to Kendall for letting me know about tasksel!


Display posts from previous:  Sort by  
Post new topic This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]

Who is online

Users browsing this forum: No registered users and 1 guest

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

Powered by php B.B. © 2000, 2002, 2005, 2007 php B.B. Group
Template made by DEVPPL