Logo
  • PHP
    • HipHop / HHVM
    • Modern PHP
    • PHPStorm
    • LAMP
    • Laravel
    • Composer
    • PDO
  • JavaScript
    • node.js
    • AngularJS
  • CSS
    • SASS
    • “CSS4” (CSS level 4)
  • HTML
  • Git
  • LAMP
  • Vagrant
  • UI / UX
  • Architecture of …
  • Off-Topic
With ♥ from Berlin
How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS

How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 14.04 LTS

This little tutorial shows how to setup Apache, MySQL and PHP on a Linux server, in this case Ubuntu 14.04

April 21, 2014
Chris
LAMP, Linux, Local Development, PHP, Ubuntu
9
PreviousNext

This little tutorial shows how to setup Apache, MySQL and PHP on a Linux server, in this case Ubuntu 14.04 LTS (by the way, if you want to know what LTS means, have a look into the wikipedia article). Most tutorials are making it overcomplicated, and most commands (like apache restarting etc.) are not necessary anymore today. In this example I’ll use a clean and fresh untouched installation of Ubuntu 14.04 LTS on a $5-server at DigitalOcean.

First, log into your server….

1. Do an update and an upgrade to keep everything up-to-date:

sudo apt-get update
sudo apt-get upgrade

2. Install Apache (this will install Apache 2.4.x by default):

sudo apt-get install apache2

3. Install PHP (this will install PHP 5.5.x by default):

sudo apt-get install php5

4. Install MySQL (5.5), mysql module for PHP and PDO stuff:

sudo apt-get install mysql-server
sudo apt-get install php5-mysql

Provide a new mysql root password when asked. Then restart the server:

sudo service apache2 restart

By the way, then you think you messed something up while installing a package then you can remove the package and its config files via

sudo apt-get --purge remove XXXXXX

 

Have a look on your server to make sure Apache runs (simply type the IP of your server into your browser), you should see a page like this. For everybody being surprised why this looks so “new”: We are using Apache 2.4 here, not 2.2 anymore, and this version simply has a new default index page. Please read this page carefully (and make a screenshot or something similar) as it explains all the Apache-basics perfectly.

apache-2-4-on-ubuntu-14-04-lts

 

Wonderful! To check which versions of the packages are installed, you can always do

apache2 -v
php -v

 

Now let’s install PHPMyAdmin to make sure PHP and the MySQL server run and work together:

sudo apt-get install phpmyadmin

Select “apache2” when asked, select with SPACE and confirm with ENTER. Press ENTER when asked for auto-configuration and provide a new password for the phpmyadmin root user and mysql root passwords when asked for password (I use the same for this, to keep things simple). You don’t need to restart anything and there’s no need to config anything right now.

Have a look on PHPMyAdmin via

http://YOUR_IP/phpmyadmin/

and you’ll see the phpmyadmin login screen. Log in to prove that everything runs fine (usually with “root” and the password you provided).

Done!

NOTE: in a real live application you should not log into the server as the root user, not provide the root password to phpmyadmin and in general not have phpmyadmin available on the live server, but for a development server that’s totally okay.

In Apache 2.2, all public content was in /var/www by default. Now, in Apache 2.4, all public content is in

/var/www/html

You can change this for sure in the configs. By default this folder contains an index.html with the HTML markup we’ve seen when we navigate to the server with the browser. Delete this file. A graphical interface to easily navigate within your server is really helpful, for Windows users I can recommend WinSCP, for Linux users Nautilus or Konqueror, on Mac OS CyberDuck is a good choice. These tools allow graphical FTP-style interaction with the server while offering real command line SSH at the same time.

To get a perfect overview over the installed modules, extensions and general PHP configs, create a file called index.php inside /var/www/html and put this inside:

<?php
phpinfo();

and then have a look into browser:

lamp-php-mysql-pdo-phpmyadmin-ubuntu-14-04-lts

 

Before you ask: The OpenSSL Hearthbleed Bug thing:

A side-note for everybody who just got a heart-attack reading the OpenSSL-section of the phpinfo() output which seriously shows OpenSSL 1.0.1f: The Hearthbleed Bug affects versions 1.0.1 to 1.0.1f, all versions after 1.0.1f (which means 1.0.1g) are fixed. However, this version 1.0.1f on Ubuntu 14.04 LTS comes with a special patch included that fixes the Hearthbleed Bug without upgrading to 1.0.1g. My personal opinion on that: WHAT THE FUCK ? This will bring a lot of confusion to the world, but .. that’s how it is. More info in this StackOverflow post here. Ubuntu has published an official warning notice about 12.04 LTS, 12.10 and 13.10, but not for 14.04 LTS. By the way, you can test the OpenSSL “version” by doing “sudo openssl version -a”. It will show 1.0.1f, but with the notice “built on: Mon April 7 … 2014”, which was the day the fix was integrated. More on that topic in another article.

This article was written quite a while ago (9 years), please keep this in mind when using the information written here. Links, code and commands might be outdated or broken.

Random articles

  • How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1
  • [RePost] Goodbye LAMP: Going Nginx, NoSQL, HHVM (41min conference talk with Arne Blankerts)[RePost] Goodbye LAMP: Going Nginx, NoSQL, HHVM (41min conference talk with Arne Blankerts)
  • Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)Hochlastseiten mit PHP, MySQL und Apache am Beispiel stern.de (deutscher Artikel)
  • Generate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one clickGenerate Vagrant boxes with Laravel, HipHop, Nginx, WordPress, MySQL, MariaDB, MongoDB, RabbitMQ etc. with one click
  • Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)Install Laravel 4 on Ubuntu 12.04 LTS (a how-to tutorial)
  • How to setup a local server (in a virtual machine) with Vagrant in PHPStormHow to setup a local server (in a virtual machine) with Vagrant in PHPStorm
  • How to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPetHow to setup a (or multiple) server/LAMP-stack inside a virtual machine for local development with Vagrant and PuPHPet
  • PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !PHPMyAdmin not found after installation ? Here’s a fix (Ubuntu 12.04) !
  • How to setup / install PHP 5.6 on Ubuntu 14.04 LTSHow to setup / install PHP 5.6 on Ubuntu 14.04 LTS
apacheLAMPMySQLPHPphpmyadminUbuntu
Share this

9 Comments

  • zrmsolutions
    October 10, 2021 9:10 pm

    ZRMSolutions consulting over 5 years of experience we’ll ensure you always provide the best guidance. We serve a clients at every level of their organization, in whatever circumstances, we deliver the most useful and act as a trusted advisor.

    Reply
  • nux
    March 31, 2015 6:55 am

    i hope you make guidelines for nginx

    thank in advance

    Reply
  • Michael
    March 18, 2015 8:00 pm

    Thanks this was way less complicated than anything else I could find and worked great. The only hitch I had was I had to add the line Include /etc/phpmyadmin/apache.conf to the file /etc/apache2/apache2.conf or else navigating to localhost/phpmyadmin would throw a 404 – Not Found error.

    Reply
  • Ole Schelde
    May 3, 2014 11:37 am

    The phpMyAdmin gives an error message saying that: The mcrypt extension is missing. Please check your PHP configuration which is weird to me because for Ubuntu Linux it’s already in the file /etc/php5/conf.d/mcrypt.ini. Anyway, to correct this edit the file php.ini and add the following line at the Dynamic Extensions section.

    extension=mcrypt.so

    Reply
    • Chris
      May 3, 2014 7:14 pm

      Cannot reproduce this! In all demo installations of 14.04 LTS phpmyadmin ran without any errors. Can you confirm that you are on a fresh, clean, untouched and up-to-date Ubuntu 14.04 LTS ?

      Reply
      • Ole Schelde
        May 3, 2014 7:18 pm

        I did the installation on at newly created ubuntu 14.04 LTS on VMware Fusion and I did it 2 times and in both cases I got this error.

        Reply
        • Bo Christensen
          February 28, 2015 1:18 pm

          I get get the same error on a clean installed Ubuntu 14.04.2 Desktop on my laptop.
          The following fixed the proplem.
          sudo php5enmod mcrypt
          sudo service apache2 restart

          Reply
  • halibegic
    April 21, 2014 8:58 pm

    Or sudo apt-get install lamp-server^

    Reply

Leave A Comment Cancel reply

october cms

[Link] How To Install October CMS on a VPS running Ubuntu 14.04

Quick tutorial on how to install October CMS on Ubuntu 14.04 by DigitalOcean. Worth a bookmark, does the job. I

Joshua Davis – my hero of Flash – in two excellent interviews (audio, video)

Joshua Davis is the reason why I’ve started to code. Seriously. Back in the late 90ies, the internet was a

Microsoft announces “holographic” 3D interfaces (promo video)

Microsoft has just announces the damn future in business und consumer electronics! Interactive, “holographic” 3D environments, usable without a keyboard,

php

How to use the PHP 5.5 password hashing functions

PHP 5.5 introduced some very interesting password hashing functions that will make your life much much easier, the web much

Frontend Ops Conf 2014 – Paul Irish: Delivering The Goods In Under 1000ms (40min video)

This article was written quite a while ago (8 years), please keep this in mind when using the information written

You made a mess with Git ? Here’s a flowchart guideline on how to fix

Extremely useful. Originally created by Justin Hileman in the presentation Changing History, or How to Git pretty. You’ll also find

ubuntu-14-04-lts lamp

How to install/setup a basic LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu 12.04 or Debian 7.0/7.1

This little tutorial shows how to setup Apache, MySQL and PHP on a Linux server, in this case Ubuntu 12.04

[Link] Making a website vertically responsive

Very useful tutorial by Ian Yates: How to make a website VERTICALLY responsive, adapting its content for small heights. Interesting

nginx php 5.5

[Link] Set up Nginx with PHP 5.5 easily

As there are surprisingly no good tutorials on how to set up NGINX with PHP 5.5 properly, here’s an excellent

What’s new in PHPStorm 9

PHPStorm 9 has just been released a few days ago, and as a PHP developer you should definitly give it

1/4

Categories

Search

css
How to center a div vertically and horizontally (modern methods, without fixed size!)
PHPStorm: 42 Tips and Tricks (47min video talk by Mikhail Vink at Dutch PHP Conference 2015)
php
PHP 5.6.0 RC1 is available
Serious hard-to-fix bug in OAuth and OpenID discovered, lots of major sites affected
forbes 30 under 30
Need motivation ? Check out these 2 awesome “FORBES 30 under 30” lists (web, UI, games)
phpstorm-github-code-color-syntax-theme
Get Github’s code colors in PHPStorm (2014 style)
composer
How to install Composer on Windows 7 / 8 or Ubuntu
Increase your HTML / CSS coding speed with EMMET
vagrant
How to setup a local server (in a virtual machine) with Vagrant in PHPStorm
photoshop-cc-deal
Adobe offers Photoshop for $9.99 per month (limited deal)
Compare 250+ cloud server plans with Cloud Cost Calculator
php
How to install PHP 7.0 on Ubuntu 14.04 LTS
mod-rewrite-ubuntu-14-04-lts
EOL lists of Ubuntu, Debian and CentOS for your server plannings
phpstorm-8
PHPStorm 8 (early access version) released – for free
php
How to install/setup latest version of PHP 5.5 on Debian Wheezy 7.0/7.1/7.2 (and how to fix the GPG key error)

Tags

apache bash centos composer conference coupon CSS debian fonts framework git GitHub hack HHVM HipHop HTML HTML5 IDE JavaScript JS LAMP laravel linux mod_rewrite MVC MySQL Nginx optimization PHP PHP 5.5 PHP 5.6 phpmyadmin PHPStorm security server SSD Ubuntu UI UX vagrant video virtual machine voucher VPS wordpress
Side-Project: Wordle-Solver:
www.wordle-helper.info

Pages

  • Privacy Policy
 
We use cookies on our website to give you the most relevant experience by remembering your preferences and repeat visits. By clicking “Accept”, you consent to the use of ALL the cookies.
Do not sell my personal information.
Cookie SettingsAccept
Manage consent

Privacy Overview

This website uses cookies to improve your experience while you navigate through the website. Out of these, the cookies that are categorized as necessary are stored on your browser as they are essential for the working of basic functionalities of the website. We also use third-party cookies that help us analyze and understand how you use this website. These cookies will be stored in your browser only with your consent. You also have the option to opt-out of these cookies. But opting out of some of these cookies may affect your browsing experience.
Necessary
Always Enabled
Necessary cookies are absolutely essential for the website to function properly. These cookies ensure basic functionalities and security features of the website, anonymously.
CookieDurationDescription
cookielawinfo-checkbox-analytics11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics".
cookielawinfo-checkbox-functional11 monthsThe cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional".
cookielawinfo-checkbox-necessary11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary".
cookielawinfo-checkbox-others11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other.
cookielawinfo-checkbox-performance11 monthsThis cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance".
viewed_cookie_policy11 monthsThe cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data.
Functional
Functional cookies help to perform certain functionalities like sharing the content of the website on social media platforms, collect feedbacks, and other third-party features.
Performance
Performance cookies are used to understand and analyze the key performance indexes of the website which helps in delivering a better user experience for the visitors.
Analytics
Analytical cookies are used to understand how visitors interact with the website. These cookies help provide information on metrics the number of visitors, bounce rate, traffic source, etc.
Advertisement
Advertisement cookies are used to provide visitors with relevant ads and marketing campaigns. These cookies track visitors across websites and collect information to provide customized ads.
Others
Other uncategorized cookies are those that are being analyzed and have not been classified into a category as yet.
SAVE & ACCEPT