The LAMP stack is a popular combination of open-source software used for web development. LAMP stands for Linux, Apache, MySQL, and PHP. In this tutorial, we will install and set up the LAMP server stack on Ubuntu 24.04.
Step 1: Create an Instance
- Access the Dashboard: Log in to your Shape.Host account and navigate to your Dashboard.
- Click Create: Click on the “Create” button located in the top-right corner.
- Select Instances: From the dropdown menu, choose “Instances” to begin creating a new cloud server.

- Select Location: Choose a data center location for your instance closest to your target audience for optimal performance.

- Choose a Plan: Scroll through the available pricing plans. Select a plan based on your project requirements, such as Standard, CPU-Optimized, or Memory-Optimized.
- Choose an Image: Select Ubuntu 24.04 as the operating system for your instance.

- Authentication and Finalize: Choose your authentication method, either via SSH keys or password. Once done, click Create Instance to launch your server.

Once the instance is created, go to the Resources section to find the public IP address of your instance. You’ll need this to connect to the instance remotely.

Step 2: Update and Upgrade System Packages
Start by updating the package list and upgrading the existing packages to the latest versions:
apt update && apt upgrade -y

Step 3: Install Apache Web Server
Apache is the web server that serves web pages to users. Install Apache using the following command:
apt-get install apache2 -y

After the installation, start the Apache service and enable it to start automatically on system boot:
systemctl start apache2
systemctl enable apache2

Verify the status of Apache to ensure it’s running:
systemctl status apache2

Check the installed version of Apache:
apache2ctl -version

Step 4: Install MySQL Database Server
Next, install MySQL, which is used to store and manage databases:
apt install mysql-server -y

Secure the MySQL installation by running the following command:
mysql_secure_installation
This command will prompt you to set a root password, remove anonymous users, disallow root login remotely, and remove the test database.


Step 5: Add PHP Repository and Install PHP
To get the latest version of PHP, add the Ondrej PHP repository:
add-apt-repository ppa:ondrej/php

Update the package list again:
apt update
Now install PHP 8.3 along with commonly used extensions:
apt install php8.3 libapache2-mod-php8.3 php8.3-mysql php8.3-gd php8.3-curl php8.3-xml -y

Restart Apache to apply the changes:
systemctl restart apache2
Check the installed version of PHP:
php --version

Step 6: Start and Enable MySQL Service
Make sure the MySQL service is started and enabled to start automatically on boot:
systemctl start mysql
systemctl enable mysql

Step 7: Verify PHP Installation
To verify that PHP is working correctly with Apache, create a test PHP file in the web root directory:
echo "<?php phpinfo(); ?>" > /var/www/html/info.php
Now, open your web browser and navigate to http://your-server-ip/info.php
. You should see the PHP information page, which confirms that PHP is correctly installed and configured.
Note: For security purposes, it’s recommended to remove the info.php
file after verification:
rm /var/www/html/info.php

You have successfully installed the LAMP stack on Ubuntu 24.04. Your server is now ready to host PHP applications, connect to a MySQL database, and serve web pages using Apache.
To host websites and applications efficiently, Shape.Host offers Linux SSD VPS services. Shape.Host’s SSD-powered VPS ensures fast and reliable performance, perfect for hosting LAMP-based applications.