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

How a Professional Website Can Double Your Business Leads in 90 Days

Why a Professional Website Matters A business website isn’t just...

How to Move Your School Online with Tremhost’s Education Plans

Learn how Zimbabwean schools can transition online with Tremhost’s...

How School Websites Help Increase Enrollments in Zimbabwe

Learn how having a professional school website in Zimbabwe...

Why Your Business Needs a Website in 2025 – Especially in Zimbabwe

Discover why Zimbabwean businesses need a professional website in...

How to Choose the Right Web Design Company in Zimbabwe

Why Choosing the Right Web Design Company Matters Your website...

Topics

How a Professional Website Can Double Your Business Leads in 90 Days

Why a Professional Website Matters A business website isn’t just...

How to Move Your School Online with Tremhost’s Education Plans

Learn how Zimbabwean schools can transition online with Tremhost’s...

How School Websites Help Increase Enrollments in Zimbabwe

Learn how having a professional school website in Zimbabwe...

Why Your Business Needs a Website in 2025 – Especially in Zimbabwe

Discover why Zimbabwean businesses need a professional website in...

How to Choose the Right Web Design Company in Zimbabwe

Why Choosing the Right Web Design Company Matters Your website...

Websites Built to Grow Your Business in Zimbabwe

Discover how Tremhost builds custom websites that grow businesses...

How to Make Your School Visible on Google in Zimbabwe

Learn how Zimbabwean schools can rank higher on Google...

Why Professional School Emails Build Parent Trust

Discover how professional school email addresses boost parent trust...
spot_img

Related Articles

Popular Categories

spot_imgspot_img