Basic Server Setup for Beginner
Tutorial for beginners to deploy a basic web server with LAMP stack. (below 5 minutes)
Pre-requisite: have a newly setup linux server with Debian-based OS such as Ubuntu. If you've installed other than Debian-based, please use their respective package manager.1
- Update and upgrade packages:
sudo apt update && sudo apt upgrade -y
- Install web server:
sudo apt install apache2 -y
- Install mySQL client and server:
sudo apt install mysql-client mysql-server -y
- Harden the mySQL installation:2
sudo mysql_secure_installation
- Install PHP and its module:3
sudo apt install php libapache2-mod-php php-mysql php-common -y
- Start and enable auto-start the web server:
sudo systemctl start apache2 && sudo systemctl enable apache2
- Start and enable auto-start the mySQL server:
sudo systemctl start mysql && sudo systemctl enable mysql
- Check server status:
sudo systemctl status apache2 && sudo systemctl status mysql
- Allow incoming request to server:
sudo ufw allow in "Apache Full"
- Test the server by visiting http://<server-ip>/
Want to automate this process using a script?
- Copy the script below
#!/bin/bash
sudo apt update && sudo apt upgrade -y
sudo apt install apache2 -y
sudo apt install mysql-client mysql-server -y
sudo mysql_secure_installation
sudo apt install php libapache2-mod-php php-mysql php-common -y
sudo systemctl start apache2 && sudo systemctl enable apache2
sudo systemctl start mysql && sudo systemctl enable mysql
sudo systemctl status apache2 && sudo systemctl status mysql
sudo ufw allow in "Apache Full"
echo "LAMP setup complete!"
- Save as
Setup.sh
- Make it executable:
sudo chmod +x Setup.sh
- Run it:
sudo ./Setup.sh