πŸ–₯️ How to Setup a LAMP Server at Home (Beginner-Friendly Guide)

A

Alan Varghese

Guest
Ever wondered how websites like WordPress run behind the scenes? At the heart of many websites lies the LAMP stack β€” Linux, Apache, MySQL, and PHP.

In this guide, we’ll walk through setting up your very own LAMP server at home step by step. By the end, you’ll have a fully functioning web server to host your personal projects or learn server administration.

πŸ› οΈ Prerequisites


  • A computer running Linux (Ubuntu/Debian recommended).


  • Basic knowledge of the terminal.


  • Internet connection to install packages.


  • (Optional) A spare machine or virtual machine (VM).

βš™οΈ Step 1: Update Your System

Always start with updating your system packages:

sudo apt update && sudo apt upgrade -y

This will make sure that all the existing softwares are up to date by synchronizing the repository with the version of package files in your local system.

🌐 Step 2: Install Apache (Web Server)

Apache is the web server that serves your websites to the visitors.

sudo apt install apache2 -y

Check if the Apache is running:

sudo systemctl status apache2

Now, open your browser and visit:

http://localhost

To see the Apache2 Ubuntu Default Page, that way we can confirm that Apache server is running.

πŸ—„οΈ Step 3: Install MySQL (Database Server)

MySQL stores your website’s data such as users, posts, and configurations.

sudo apt install mysql-server -y

Secure your MySQL installation:

sudo mysql_secure_installation

During this step, you’ll have to:


  • Set a root password.


  • Remove anonymous users.


  • Disallow root login remotely.


  • Remove test databases.

πŸ’» Step 4: Install PHP (Scripting Language)

PHP allows dynamic content and interaction between Apache and MySQL.

sudo apt install php libapache2-mod-php php-mysql -y

To check its version:

php -v

πŸ§ͺ Step 5: Test PHP

Create a PHP test file:

sudo nano /var/www/html/info.php

Paste this code:

<?php phpinfo(); ?>

Save and exit.

This will show the PHP info page.

Now, open your browser:

http://localhost/info.php

You should be able to see a PHP info page.

πŸ“‚ Step 6: Adjust Permissions (Optional)

If you plan to upload files frequently, adjust these permissions:

sudo chown -R $USER:$USER /var/www/html

πŸ”’ Step 7: (Optional) Access Your Server from Another Device

If you’re setting this up on a home server, find your local IP:

hostname -I

Then, from another device on the same network, visit:

http://<your-local-ip>

🎯 Conclusion

You’ve successfully set up a LAMP server at home! πŸŽ‰

With this, you can:


  • Host static/dynamic websites.


  • Install WordPress or other CMS.


  • Learn about databases and server management.

πŸ’‘ Next steps:


  • Secure your server with UFW firewall.


  • Add a domain name.


  • Explore Let’s Encrypt SSL for HTTPS.

πŸ“ Final Thoughts

Setting up a LAMP server is an excellent way to learn the foundations of web hosting and DevOps. With just a few commands, you’ve created the backbone of the modern web, right from your home.

Continue reading...
 


Join 𝕋𝕄𝕋 on Telegram
Channel PREVIEW:
Back
Top