Install Apache, MySQL, PHP5, and PHPMyAdmin on Debian “Jessie”

This is a quick guide to getting an Amazon EC2 server up and running with LAMP and PHPMyAdmin based on the LTS (Long Term Support) Debian version 8.5 “Jessie”. This guide was written using the Community AMI image debian-jessie-amd64-hvm-2016-04-03-ebs for Debian “Jessie” and assumes you are able to launch the server and connect via SSH.

Amazon assumes an EBS volume of 8GB (t2.nano) or 10GB (t2.micro), but if the server will be storing very little, the real minimum size of the EBS can be calculated safely as:
1.5GB + (RAM x 2)
That is roughly 3GB EBS for t2.nano, and 4GB EBS for t2.micro.

Update Package Info

sudo apt-get update

Install LAMP Packages

sudo apt-get install apache2 apache2-utils mysql-server php5 php5-mysql php5-curl php5-cli libapache2-mod-php5
* Choose a root password for MySQL

Enable Useful Apache Modules

sudo a2enmod headers
sudo a2enmod rewrite

Edit Apache Config for .htaccess Usage

sudo nano /etc/apache2/apache2.conf
Change AllowOveride under <Directory /var/www/> from None to All

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>

Change Server Timezone

sudo dpkg-reconfigure tzdata

Restart Apache & MySQL

sudo service apache2 restart
sudo service mysql restart

Adjust User/Group and Read/Write/Execute on Web Folder

sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 775 /var/www/html
Also add the admin user to www-data group
sudo usermod -aG www-data admin

Install PHPMyAdmin (Answer YES to use DBconfig)

sudo apt-get install phpmyadmin
* Make sure you set a password for the phpmyadmin user

Add PHPMyAdmin to Apache2 Config

sudo nano /etc/apache2/apache2.conf
ADD TO FILE:

Include /etc/phpmyadmin/apache.conf


Tip: How to Workaround No Password Set for User

sudo nano /etc/phpmyadmin/config.inc.php
UNCOMMENT IN FILE:

$cfg['Servers'][$i]['AllowNoPassword'] = true;


Restart Apache, then you will able to login without a password at /phpmyadmin/ (NOT RECOMMENDED).

Share and Enjoy:
  • Facebook
  • Twitter
  • Reddit
  • StumbleUpon
  • Digg
  • del.icio.us
  • Tumblr
  • PDF

4 thoughts on “Install Apache, MySQL, PHP5, and PHPMyAdmin on Debian “Jessie”

  1. Keith

    Worked a treat (with some additional bits n pieces installed I need). Running on a Samsung Galaxy so I can run a mapping application offline. Cheers!

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *