Skip to Content
All memories

LAMP Stack on Ubuntu

 — #linux#lamp

LAMP (Linux, Apache, MySQL, PHP) stack is a common, free and open-source web stack used for hosting web content in a Linux environment. Many consider it the platform of choice on which to develop and deploy high-performance web apps.

1. Update your system

sudo apt update

2. Install Apache 2.4

sudo apt install apache2

To add a virtual host you should go and edit the file:

nano /etc/apache2/sites-available/000-default.conf
<Directory /var/www/example>
        Require all granted
</Directory>
<VirtualHost *:80>
        ServerName example.com
        ServerAlias www.example.com
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/example

        ErrorLog /var/www/example/error.log
        CustomLog /var/www/example/access.log combined

</VirtualHost>

3. Install MySQL Database

sudo apt install mysql-server

4. Install PHP 7.0

We’ll also install PHP Extension and Application Repository, Apache support, and MySQL support

sudo apt install php7.0 libapache2-mod-php7.0 php7.0-mysql

Optionally, install additional cURL, JSON, and CGI support:

sudo apt install curl mcrypt php7.0-mcrypt php7.0-mbstring php7.0-curl php7.0-json php7.0-cgi

Enable php modules:

sudo phpenmod mcrypt
sudo phpenmod curl

Enable rewrite apache module:

sudo a2enmod rewrite

In the end you should restart Apache:

sudo systemctl restart apache2

5. Install phpMyAdmin

sudo apt install phpmyadmin

Access phpMyAdmin at http://localhost/phpmyadmin

6. Check the installation

Check php version

php -v

Check apache version

apachectl -v

Check mysql version

mysql --version

You should open http://localhost/ and confirm that everything is working fine.