Ubuntu 16.04 LAMP Installation
In this guide, you will install the LAMP (Linux, Apache, MySQL, PHP) stack on Ubuntu 16.04.
The goal is to make your server ready for dynamic websites and applications.
Technical Summary
This guide installs Apache, MySQL and PHP components together on a single server.
It creates a secure web infrastructure that offers dynamic content to visitors.
Steps: Web server, database, scripting language and testing process.
Prerequisites
Before you start you should have the following ready:
- A server with Ubuntu 16.04 installed
- A user with sudo authority
- Active internet connection
The Linux component is already provided by Ubuntu.
Apache Setup and Firewall
Apache is the main component that handles web requests.
sudo apt-get update
- This command updates the package list.
sudo apt-get install apache2
- This command installs the Apache web server.
1.1 Troubleshooting ServerName Warning
- Apache may issue a warning if the FQDN is not defined.
sudo nano /etc/apache2/apache2.conf
- Add to the end of the file:
ServerName tr1-genixnode-node01.cloud
1. Test the configuration:
sudo apache2ctl configtest
- The result should be Syntax OK.
2. Restart Apache:
sudo systemctl restart apache2
1.2 UFW Firewall Setting
1. Check Apache profiles:
sudo ufw app list
2. Allow HTTP and HTTPS traffic:
sudo ufw allow "Apache Full"
3. Navigate to the server IP address from the browser.
- The default Apache page should appear.
MySQL Installation and Security
- MySQL stores site data.
sudo apt-get install mysql-server
Set a strong root password during installation.
1. Adjust security settings:
sudo mysql_secure_installation
- Remove anonymous users and turn off remote root access.
PHP Installation and Apache Integration
- PHP handles dynamic content.
sudo apt-get install php libapache2-mod-php php-mysql
This command integrates PHP with Apache.
3.1 Setting Directory Priority
1. Let's make Apache run PHP files first.
sudo nano /etc/apache2/mods-enabled/dir.conf
- Edit the following line:
DirectoryIndex index.php index.html index.cgi index.pl index.xhtml index.htm
2. Restart Apache:
sudo systemctl restart apache2
PHP Working Test
1. Let's verify that PHP is working.
sudo nano /var/www/html/info.php
<?php
phpinfo();
?>
- Open from browser:
http://SUNUCU_IP_ADRESI/info.php
The PHP information screen should appear.
4.1 Safety Note
- Be sure to delete the file after the test.
sudo rm /var/www/html/info.php
Frequently Asked Questions (FAQ)
1. Why is LAMP so popular? It is open source and has broad community support.
2. Is the new version recommended instead of Ubuntu 16.04? Yes. Ubuntu 22.04 is more secure.
3. Can I use MariaDB instead of MySQL? Yes. The installation logic is similar.
4. Is there Nginx instead of Apache? It is possible. This structure is called LEMP.
Result
Now your server is ready for dynamic web applications. You can install WordPress, custom PHP projects or APIs.
You can go live this structure within minutes on the GenixNode infrastructure.

