Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Install PHP5, Apache, MySQL and phpMyAdmin on Linux

This guide builds a basic web server on Linux. It uses PHP 5, Apache, MySQL and phpMyAdmin.

Databases2 min read11 steps

Note: You need root access, which is full control of the server. This guide suits VPS and dedicated server owners. It uses Ubuntu or Debian commands.

Tip: PHP 5 is very old and no longer gets security fixes. Newer versions work in a similar way. Use php instead of php5 and a newer release when you can.

What are these parts?

  • Linux is the operating system, the base software of the server.
  • Apache is the web server. It sends web pages to visitors.
  • MySQL is the database. It stores data in tables.
  • PHP is the language many websites use.
  • phpMyAdmin is a web page to manage MySQL.

Steps

  1. Connect to your server with SSH. SSH lets you type commands on the server.
  2. Update the list of software.
apt-get update

This refreshes the list of available packages.

  1. Install Apache.
apt-get install apache2
  1. Install MySQL. It asks you to set a root password. Pick a strong one and save it.
apt-get install mysql-server
  1. Install PHP 5 and the parts that join it to Apache and MySQL.
apt-get install php5 libapache2-mod-php5 php5-mysql
  1. Install phpMyAdmin. Choose apache2 when asked which server to set up.
apt-get install phpmyadmin
  1. Restart Apache so it loads the new parts.
service apache2 restart

Test it

  1. Make a test file.
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
  1. Open http://your-server-address/info.php in a browser. You should see a PHP information page.
  2. Open http://your-server-address/phpmyadmin. You should see the login page.
  3. Delete the test file when you finish.
rm /var/www/html/info.php

This removes the file, since it shows details attackers could use.

Warning: Do not leave phpMyAdmin open to the world without a strong password. Keep your software updated.

Quick recap

  • Install Apache, MySQL, PHP and phpMyAdmin with apt-get.
  • Restart Apache after you install.
  • Test with /info.php and /phpmyadmin.
  • Delete the test file afterwards.
  • PHP 5 is old, so use a newer version when possible.