LAMP Stack
Install the LAMP Stack on Ubuntu
2 min read
#LAMP StackInstall the LAMP Stack on Ubuntu
Establish a robust foundation for your web applications! This comprehensive guide walks you through installing the LAMP stack (Linux, Apache, MySQL, PHP) on Ubuntu, empowering you to create dynamic and interactive websites.
Prerequisites
- An Ubuntu server with root or sudo privileges.
- Basic understanding of using the command line.
- Access to your server via SSH.
To Get Access via SSH
- Syntax:
ssh -p PORT USERNAME@HOSTIP
- Example:
ssh -p 22 root@216.32.44.12
Instructions
1. Update and Upgrade the System
apt update
apt upgrade
2. Install Apache
apt install apache2
- Optional: If you encounter the error “cannot stat ‘/usr/share/apache2/default-site/index.html’: No such file or directory”, try:
apt purge apache2-data
3. Allow Apache through Firewall
ufw allow "Apache Full"
- Check Server IP on Web Browser: You should see the Apache default page.
4. Install MySQL
apt install mysql-server
5. Install PHP
apt install php libapache2-mod-php php-mysql
- Packages Included:
php
- To install PHP.libapache2-mod-php
- Used by Apache to handle PHP files.php-mysql
- A PHP module that allows PHP to connect to MySQL.
6. Restart Apache
service apache2 restart