Setup LAMP in Ubuntu / Linux Mint using Tasksel with PHPMyAdmin installed and mod_rewrite loaded

As a new Linux user, sometimes it is difficult to setup stuffs in a Linux box. Back in the days where internet connection is scarce in my area, using Ubuntu that time is kinda useless without it. Some software will require or lead you to another dependencies and may require another one and it sucks to do it in a Terminal. The most common installation is building your LAMP stack for development purposes.

So the easiest way to install LAMP is to install Tasksel first, it will still be on Terminal but a single line of command need:

sudo apt-get install tasksel

What it does is you use the command apt-get to install tasksel. After entering that command the Terminal will ask for your root password since we run the command as root. Tasksel will be downloaded and after that it will prompt what build are you going to install. This time select Lamp Server, then proceed. Wait for it until will ask for your MySQL root password and you are done!

To test if our web server is working, open your web browser and enter this URL:


Then you will see a page saying you installed Apache properly!

Now, we need to install PHPMyAdmin for us to easily manage our MySQL database. To do that you need to run Terminal again and enter this command:

sudo apt-get install phpmyadmin

Again, it will ask for your root password.

OK. It looks like we are great to go, we can do some magic stuffs there. So let’s try to create a PHP file to see if it is working. To do that run this command:

sudo gedit

It will open a text editor and take note we used it as root. I’ll explain that later, for now add this code and save it as phpinfo.php in /var/www.

<?php phpinfo(); ?>

If you’ve already messed with some PHP codes or created some PHP websites then this is no brainer to you but for those aren’t then this code will display your PHP’s information such as version, OS, modules, etc.

Additionally, to load the module rewrite run this command:

sudo a2enmod rewrite

Then open the file 000-default in /etc/apache2/sites-enabled with this command:

sudo gedit /etc/apache2/sites-enabled/000-default

Change all AllowOverride None to AllowOverride All and you must restart Apache to apply the changes using this command:

sudo /etc/init.d/apache2 restart

Lastly, to create new files in our www folder what we did is we need to use the account. It’s a little time consuming right? Why not just create in the folder directly? Well, that’s because the www folder is only set for root account, and other accounts doesn’t have a privileges to open it. To allow any user (if you want to) then we need to set the permission of our www folder. To do that open your terminal and run this command:

sudo chmod 777 /var/www -R

Chmod is a command that will change permission of a folder, 777 is parameter that will allow everyone to access it and -R to recursive all the permission settings to its sub directories.