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
- Connect to your server with SSH. SSH lets you type commands on the server.
- Update the list of software.
apt-get update
This refreshes the list of available packages.
- Install Apache.
apt-get install apache2
- Install MySQL. It asks you to set a root password. Pick a strong one and save it.
apt-get install mysql-server
- Install PHP 5 and the parts that join it to Apache and MySQL.
apt-get install php5 libapache2-mod-php5 php5-mysql
- Install phpMyAdmin. Choose apache2 when asked which server to set up.
apt-get install phpmyadmin
- Restart Apache so it loads the new parts.
service apache2 restart
Test it
- Make a test file.
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
- Open
http://your-server-address/info.phpin a browser. You should see a PHP information page. - Open
http://your-server-address/phpmyadmin. You should see the login page. - 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.phpand/phpmyadmin. - Delete the test file afterwards.
- PHP 5 is old, so use a newer version when possible.