How to Install a LAMP Stack on Your VPS (2025 Guide)

How to Install a LAMP Stack on Your VPS (2025 Guide)

A LAMP stack is a group of open-source software typically used to get web servers up and running. The acronym stands for Linux, Apache, MySQL, and PHP. Here is a step-by-step guide to installing a LAMP stack on your Virtual Private Server (VPS) as of 2025:

Step 1: Access Your VPS

  • SSH into Your VPS: Use an SSH client to connect to your VPS. You will need your server’s IP address, SSH port, and root credentials.
    ssh root@your_server_ip
    

Step 2: Update Your System

  • Update Package Lists: Before installing any software, it’s a good practice to update your package lists.
    sudo apt update
    
  • Upgrade Packages: Optionally, you can upgrade all your system software to the latest versions.
    sudo apt upgrade
    

Step 3: Install Apache

  • Install Apache2: Apache is the most widely used web server software.
    sudo apt install apache2
    
  • Adjust Firewall: Ensure that your firewall allows HTTP and HTTPS traffic.
    sudo ufw allow in "Apache Full"
    

Step 4: Install MySQL (MariaDB)

  • Install MySQL: As of 2025, MariaDB is often preferred over MySQL due to its open-source nature, but both function similarly.
    sudo apt install mariadb-server
    
  • Secure MySQL: Run the mysql_secure_installation script to secure your database server.
    sudo mysql_secure_installation
    

    Follow the prompts to set a root password, remove anonymous users, restrict root user access to the local machine, and remove the test database.

Step 5: Install PHP

  • Install PHP: PHP is a server-side scripting language designed for web development.
    sudo apt install php libapache2-mod-php php-mysql
    
  • PHP Modules: Install additional PHP modules based on your needs.
    sudo apt install php-cli php-fpm php-json php-common php-mysql php-zip php-gd php-mbstring php-curl php-xml php-pear php-bcmath
    

Step 6: Test Apache

  • Check Apache: Ensure Apache is running.
    sudo systemctl status apache2
    
  • Access Default Page: Open your web browser and navigate to http://your_server_ip/. You should see the default Apache2 Ubuntu Default Page.

Step 7: Test PHP

  • Create PHP File: Create a simple PHP file to test PHP processing on your Apache server.
    echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php
    
  • Access PHP Page: In your web browser, go to http://your_server_ip/info.php. You should see a page displaying information about your PHP configuration.

Step 8: Configure MySQL (MariaDB)

  • Login to MySQL: Log into the MySQL shell.
    sudo mysql
    
  • Create Database and User: Optionally, you can create a database and a user for your applications.
    CREATE DATABASE exampledb;
    CREATE USER 'exampleuser'@'localhost' IDENTIFIED BY 'password';
    GRANT ALL PRIVILEGES ON exampledb.* TO 'exampleuser'@'localhost';
    FLUSH PRIVILEGES;
    EXIT;
    

Step 9: Secure Your System

  • Regular Updates: Keep your system secure by regularly updating all software.
  • Backup Configurations: Regularly back up your configurations and databases.

Step 10: Additional Configurations

  • Tune Apache and PHP: Adjust configurations in Apache and PHP to optimize performance and security based on your specific needs.

Installing a LAMP stack on your VPS equips you with the essential software needed to host dynamic websites and web applications. This setup forms the backbone for many popular CMSes like WordPress, Drupal, and Joomla, and is known for its robustness, flexibility, and customization capabilities.

Hot this week

Top 5 Beaded Jewelry Trends in Africa (2025)

Beaded jewelry continues to thrive in Africa, blending traditional...

Crocheting for Beginners: Step-by-Step African Patterns

Crocheting is a rewarding craft that allows you to...

DIY African Black Soap: Homemade Recipes & Benefits

African black soap is renowned for its natural ingredients...

Where to Buy Candle-Making Supplies in Nigeria

If you're interested in starting candle-making in Nigeria, here...

How to Make Tie-Dye at Home (African Fabric Edition)

Creating tie-dye patterns on African fabrics is a fun...

Topics

Top 5 Beaded Jewelry Trends in Africa (2025)

Beaded jewelry continues to thrive in Africa, blending traditional...

Crocheting for Beginners: Step-by-Step African Patterns

Crocheting is a rewarding craft that allows you to...

DIY African Black Soap: Homemade Recipes & Benefits

African black soap is renowned for its natural ingredients...

Where to Buy Candle-Making Supplies in Nigeria

If you're interested in starting candle-making in Nigeria, here...

How to Make Tie-Dye at Home (African Fabric Edition)

Creating tie-dye patterns on African fabrics is a fun...

5 Best Sewing Machines for Beginners in Africa

Starting your sewing journey can be exciting, and choosing...

DIY Wall Décor Ideas Using African Prints

Transform your space with vibrant African prints! Here are...

How to Start a Bead-Making Business in Africa: Profitable Skills

Starting a bead-making business can be a rewarding venture...
spot_img

Related Articles

Popular Categories

spot_imgspot_img