Skip to main content
Image for post: Setting a LAMP enviroment on Linux

Setting a LAMP enviroment on Linux

Yet another tutorial about installing a LAMP on Linux (I'm using Ubuntu). I've found all info I needed online but for it wasn't so easy. All informations are different, for different tools and purposes and you can't find them in single tutorial. Here I'm listing all commands we need to set up a good PHP development enviroment more quickly.


sudo apt-get install apache2

Just open a browser and type http://localhost. If you will see a web page, all is ok. Now you will need these command to interact with the server Restart the server: sudo /etc/init.d/apache2 restart Start the server: sudo /etc/init.d/apache2 start Stop the server:  sudo /etc/init.d/apache2 stop You can add apache utils: sudo apt-get install apache2-utils

Enable mod rewrite

sudo a2enmod rewrite and restart apache with sudo /etc/init.d/apache2 restart or sudo service apache2 restart Now edit the default VirtualHost with

sudo nano /etc/apache2/sites-available/000-default.conf

Search for “DocumentRoot /var/www/html” and add the following lines directly below:

<Directory "/var/www/html">
     AllowOverride All

Save and exit the nano editor via CTRL-X, “y” and ENTER. Restart the server again: sudo /etc/init.d/apache2 restart


Install last PHP version:

sudo apt-get install php5 libapache2-mod-php5

Just type php -v and see if all is ok. if you want to edit the php.ini file:

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

Probably you will need to enable the CURL extension:

sudo apt-get install php5-curl
sudo /etc/init.d/apache2 restart


Download the phar file and move it to /usr/local/bin to install it globally:

sudo mv composer.phar /usr/local/bin/composer

Type composer to check the installation and remember to use sudo for the update:

sudo composer self-update


I've downloaded the phar file on and moved it on /usr/local/bin/:


chmod +x phpunit.phar

sudo mv phpunit.phar /usr/local/bin/phpunit

phpunit --version

Here you can start using PHPUnit very easily. I'm using PHPStorm and if you want the IDE to see PHPUnit for showing autocomplete instructions you must let the IDE see the phar file elsewhere. So download the phar file again and move it in a directory of your choice. Update the PHPStorm settings and add the directory on PHP. File -> Settings -> PHP and add the directory on include path. On PHPUnit tab, let the IDE see the phar file.


sudo apt-get install mysql-server

Follow the install procedure.

sudo /etc/init.d/mysql start
sudo /etc/init.d/mysql stop
sudo /etc/init.d/mysql restart

Client softwares



Git is simply essential. Install it with:

sudo apt-get install git


NodeJS is not a pure PHP tool but today you may need to install it:

sudo apt-get update
sudo apt-get install nodejs

Install npm:

sudo apt-get install npm


Share this post

This website and/or any sub domains use cookies to understand how you to improve your experience.