Tutorial

How To Use the LAMP 1-Click Install on DigitalOcean

How To Use the LAMP 1-Click Install on DigitalOcean

Introduction

LAMP stack is a solution stack that employs a specific group of software to host web applications on a server. This term is an acronym which represents the Linux operating system with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP.

This tutorial will guide you through spinning up a DigitalOcean Droplet with LAMP stack pre-installed, using the DigitalOcean LAMP 1-Click App. It also includes useful tools such as Fail2ban for mitigating server attacks, Postfix for sending email, and Certbot for managing TLS/SSL certificates for secure HTTPS connections. After creating your Droplet, you will be guided through other use cases for LAMP stack. Because this 1-Click Droplet is based on a standard Ubuntu 20.04 Droplet, you can follow any of our LAMP tutorials on your Droplet after you finish this guide.

1-Click Deployment

By the end of this tutorial, you will have a Ubuntu 20.04 Droplet with the following additions:

  • Apache (version 2.4.41) is a popular open-source web server. It provides many powerful features including dynamically loadable modules, robust media support, and extensive integration with other popular software.
  • MySQL (version 8.0.30) is a popular open-source database management system. It implements the relational model and uses Structured Query Language (better known as SQL) to manage its data.
  • PHP (version 8.1.8) is a scripting language used in web development for creating dynamic and interactive web pages.
  • Fail2ban (version 0.11.1) is a tool used to prevent brute force DDOS attacks through the creation of rules that ban specific IP addresses according to certain behaviors.
  • Postfix (version 3.4.10) is a mail transfer agent that can be used to route and deliver email on a Linux system.
  • Certbot (version 0.39.0) is a tool for automating the creation of certificates for TLS/SSL encryption for HTTPS traffic. Additionally, it can handle the automatic configuration of web server settings to use HTTPS using these new certificates.

In addition to the package installation, this 1-Click also includes:

  • An enabled firewall using UFW, allowing port 80 for HTTP traffic, port 443 for HTTPS traffic, and port 22 for SSH traffic.
  • A root password already set for MySQL by running mysql_secure_installation. This information can be found at /root/.digitalocean_password.

Step 1 — Creating a LAMP Droplet

Start by creating a LAMP 1-Click Droplet that is available on our Marketplace, and that will take you to the DigitalOcean control panel. To create a LAMP Droplet from the LAMP 1-Click App, press the Create LAMP Droplet button:

LAMP 1-Click Create LAMP Droplet
Create LAMP Droplet

If you are not logged into your DigitalOcean account, you need to login.If you don’t have an account, you can sign up for one.

Next you’ll be taken to the Create Droplets page. Here you can customize your server settings before creating your LAMP Droplet. Read the guide on How to Create your First Droplet for a description of all the choices you need to make in detail. The following sections are a few key settings to consider.

Choosing an Image

Your image will already be set to the Marketplace tab with LAMP Latest on Ubuntu 20.04:

Marketplace LAMP Image
Create a Droplet with the Marketplace LAMP Image

If this is not selected use the search box to search for LAMP.

You can accept the defaults or adjust settings according to your use case. We typically recommend the following changes:

Choosing a Datacenter Region

To avoid potential latency, it is recommended that you select a datacenter region closest to your user base. In some regions we have more than one datacenter. There is no difference between these same region datacenters (e.g., SFO3 and SFO2).

Choosing a Plan

To run a Droplet with LAMP it is recommended to have at least 1GB of RAM.

Choosing an Authentication Method

The SSH Key option is recommended, rather than a Password for your Droplet. Authentication using SSH Keys is typically more secure.

Selecting Additional Options

Adding improved metrics monitoring and alerting to your Droplet helps you follow your Droplet resource usage over time. You may also want to consider enabling automated backups. You can come back later to enable backup functionality on Droplets you’ve already created.

Choosing a Hostname

Give your Droplet an identifying name that you will remember, such as “LAMP Droplet 1” or naming it after the application you will be using it for.

After you’ve made all your choices, press Create Droplet in the bottom bar of the control panel screen. Once the Droplet is created, its IP address will be displayed:

Copying a new Droplet's IP Address
Copying a new Droplet’s IP Address

You can connect to and configure your Droplet by accessing this IP address. Hover over the IP address and press Copy to copy it to your clipboard.

Droplets created through the 1-Click Marketplace comes with additional resources that you can access by pressing Get started:

1-Click Droplet's Get started
1-Click Droplet’s Get started

This toggles a new panel, where you can gain additional information specific to your 1-Click application. This includes an overview, further steps to get started using your Droplet, and links to relevant tutorials from our Community site. Furthermore, you’ll have access to support and other resources for LAMP:

Get started with additional information and resources
Get started with additional information and resources

Once you’re finished getting your Droplet setup in the control panel, you can proceed to accessing it on your terminal.

Step 2 — Accessing the Droplet via SSH to Enable Configuration

Once you’ve spun up your LAMP Droplet, you need to connect to your Droplet via SSH. That means you’ll connect to the server from the command line. If you haven’t used a terminal program like SSH or PuTTY before, check out How To Connect To Your Droplet with SSH. When you’re ready, open a terminal on your computer and log into your Droplet as root via SSH with this command, substituting the IP address with your Droplet’s IP address:

  1. ssh root@your_server_ip

Once you’re finished getting your Droplet setup in the control panel, you can proceed to accessing it on your terminal.

Step 3 — Working with LAMP

Now that your LAMP Droplet is up and running, you can start working with LAMP. To verify that LAMP is set up and check its overall status, use the php command:

  1. php -i
Output
phpinfo() PHP Version => 8.1.13 System => Linux lamponubuntu2004-s-1vcpu-2gb-sfo3-01 5.4.0-135-generic #152-Ubuntu SMP Wed Nov 23 20:19:22 UTC 2022 x86_64 Build Date => Nov 26 2022 14:07:36 Build System => Linux Server API => Command Line Interface Virtual Directory Support => disabled Configuration File (php.ini) Path => /etc/php/8.1/cli Loaded Configuration File => /etc/php/8.1/cli/php.ini . . .

To access your automatically created root password for MySQL, you can open the following file with nano or your preferred text editor:

  1. nano /root/.digitalocean_password
/root/.digitalocean_password
root_mysql_pass="your_mysql_password"

Once you have your password noted, close nano by pressing CTRL + X.

Your 1-Click droplet is automatically configured to serve websites from a root directory of /var/www/html. Within this directory there is an example file that is being served named index.html. To inspect its contents, open the file with your preferred text editor:

  1. nano /var/www/html/index.html
/var/www/html/index.html
<html>
  <head>
	<style>
  	body {
    	font-family: ProximaNova;
    	font-size: 15px;
    	font-style: normal;
    	font-stretch: normal;
. . .

Once you are finished reviewing, close the file. You can view this file on your browser by navigating to http://your_server_ip:

Your server accessed in your browser
Your server accessed in your browser

Next, there are a few things you can do to further customize your LAMP setup and secure your web server’s traffic. One way you can customize your LAMP setup is by creating a virtual host in Apache.

Apache server configuration does not take place in a single monolithic file, but instead happens through a modular design where new files can be added and modified as needed. Within this modular design, you can create an individual site or domain called a virtual host. Using virtual hosts, one Apache instance can serve multiple websites. For more information, follow our How To Set Up Apache Virtual Hosts on Ubuntu 20.04 tutorial.

While Certbot comes installed with your 1-Click Droplet, you must run it to obtain your certificate through Let’s Encrypt. Let’s Encrypt is a Certificate Authority (CA) that facilitates obtaining and installing free TLS/SSL certificates, thereby enabling encrypted HTTPS on web servers. It provides a software client, Certbot, that automates the entire process of obtaining and installing a certificate for Apache. For more information, follow our How To Secure Apache with Let’s Encrypt on Ubuntu 20.04 tutorial.

Step 4 — Creating a New User and Adjusting Permissions and Firewalls (Optional)

Your new Droplet comes with only one user, which is the default root user. While LAMP can work as the root user, you also have the option to set up a new user and grant it administrative privileges through sudo. This, along with other security recommendations, can be found in our Initial Server Setup with Ubuntu 20.04 tutorial.

Additionally, you can choose to only allow traffic through HTTPS if you have properly set up your certificates using Certbot. Use ufw delete to remove the rule that came with your 1-Click Droplet:

  1. ufw delete allow 80/tcp

Your server is now only accessible through HTTPS.

Conclusion

Your LAMP 1-Click Droplet is now up and running. Keep in mind that while LAMP is treated as a singular entity in this tutorial, each of its separate components has its own suite of features and functionality. To learn more about each component, consider the following tutorials:

If you’re interested in a traditional installation of LAMP, you can check out our How To Install Linux, Apache, MySQL, PHP (LAMP) stack on Ubuntu 20.04 tutorial. To learn about other software that uses LAMP stack as a foundation, you can explore Wordpress for building websites following our How To Install WordPress on Ubuntu 20.04 with a LAMP Stack tutorial.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about our products

About the authors
Default avatar
Tony Tran

author

Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
 
1 Comments


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Start by creating a LAMP 1-Click Droplet from the DigitalOcean Marketplace, which will take you to the DigitalOcean control panel. This is an optional step, but it’s recommended for security purposes to create a new user and adjust the necessary permissions and firewalls. It will guide you through the process, including additional tools such as Fail2ban, Postfix, and Certbot, which are included in the 1-Click Install. Remember, this 1-Click Droplet is based on a standard Ubuntu 20.04 Droplet, so you can follow any related LAMP tutorials on your Droplet after you finish the initial setup.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Join the Tech Talk
Success! Thank you! Please check your email for further details.

Please complete your information!

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.