Setting Up a LAMP Stack (Linux, Apache, MySQL, PHP)

 

Introduction

A LAMP stack is a popular set of open-source software used to host websites and web applications. LAMP stands for Linux, Apache, MySQL, and PHP. This tutorial will walk you through the process of setting up a LAMP stack on your Linux VPS.

Step-by-Step Guide

Step 1: Update Your System

  1. Log in to your Linux VPS via SSH.
  2. Update your package manager and upgrade existing packages:
    sudo apt update && sudo apt upgrade

Step 2: Install Apache

  1. Install the Apache web server package:
    sudo apt install apache2
  2. Enable Apache to start at boot and start the service:
    sudo systemctl enable apache2
    sudo systemctl start apache2

Step 3: Install MySQL

  1. Install MySQL server:
    sudo apt install mysql-server
  2. Run the secure installation script to set your MySQL root password and secure the installation:
    sudo mysql_secure_installation

Step 4: Install PHP

  1. Install PHP and its Apache module:
    sudo apt install php libapache2-mod-php php-mysql
  2. Restart Apache to enable PHP:
    sudo systemctl restart apache2

Step 5: Test Your LAMP Stack

  1. Create a PHP info page to test PHP processing:
    echo '<?php phpinfo(); ?>' | sudo tee /var/www/html/info.php
  2. Open a web browser and visit http://your-server-ip/info.php to view the PHP info page.
  3. Delete the page after testing for security reasons:
    sudo rm /var/www/html/info.php

Conclusion

Your LAMP stack is now ready to host websites and web applications. You can start deploying your projects on this robust and versatile stack. Be sure to follow

  • hosting guide, Linux VPS, LAMP stack, MySQL, PHP, Apache, web server setup
  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Getting Started with Your Linux VPS

  Introduction Welcome to your new Linux VPS! This tutorial will guide you through the...

Connecting to Your Linux VPS via SSH

Connecting to Your Linux VPS via SSH body {...

Basic Linux Commands for New Users

Basic Linux Commands for New Users body {...

Securing Your Linux VPS

    Introduction Securing your Linux VPS is crucial for protecting sensitive data and...

Creating and Managing Users in Linux

    Introduction Managing user accounts on your Linux VPS is vital for maintaining...