---
title: Quickstart LAMP Setup Guide - Digital Ocean
date: 2014-04-30T10:58:00-05:00
author: Dario Zadro
canonical_url: "https://zadroweb.com/blog/quickstart-server-lamp-setup-digital-ocean/"
section: Articles
---
It's no secret that most shared hosting platforms are just terrible. This includes HostGator, BlueHost, and any other you can think of. The only true way to have a solid web host is to build it yourself. It's not too complicated either, and I like two cloud hosting companies, [Linode](https://zadroweb.com/go/linode "Linode") and [Digital Ocean](https://zadroweb.com/go/digital-ocean "Digital Ocean").

Our company used Linode (running a LEMP setup) for all our client sites in the early days, and we couldn't be happier about how it helped Zadro Web grow. I also created a complete [LEMP WordPress setup tutorial](https://zadroweb.com/blog/debian-lemp-nginx-wordpress-digital-ocean/) if that's your preferred configuration. Today, we use a combination of on-premises and cloud architecture.

So, why have a quick start tutorial for Digital Ocean and LAMP if we use LEMP?

If you're unfamiliar with LEMP, it uses Nginx (pronounced Engine-x) instead of Apache for the webserver. You will (typically) have fewer setup issues running WordPress or other CMS platforms on Apache.

Also, with Linode, you can bind many IPs to a single installation. In contrast, with Digital Ocean, you're assigned a single IP per *droplet* -- a droplet is their naming convention for a single VPS (virtual private server).

If you need the flexibility to host multiple IPs, go with [Linode](https://zadroweb.com/go/linode "Linode") and take the time to learn Nginx.

Digital Ocean is the clear choice for a single VPS installation, and that's the reason for this LAMP tutorial.

![Digital Ocean -- Create Droplet](https://static.zadroweb.com/site/_large/digital-ocean-create-droplet.png)Ok, here we go...

1. Head over to [Digital Ocean](https://zadroweb.com/go/digital-ocean "Digital Ocean") and sign up (yes, that's a referral link). Create a new $5/month "droplet" and choose Debian 12 - you will be emailed the "root" password and IP of your new server (droplet). Why Debian? Because it's clean and simple. If you need Cpanel, then this guide is not for you. We're creating a server requiring command line administration from a terminal window moving forward. Plus, you can take a snapshot of your server and make as many "clone" droplets as you like later, 1 for each site.
2. After you receive your root password and IP, open up a terminal window, type `ssh root@123.123.123.123`, and replace it with your provided IP address. Next, let's start by getting some basic security for your new server.
3. Change the root password right away by typing `passwd` once logged in. Choose your favorite password creation tool and make sure it's highly secure with upper, lower, punctuation, and 16 characters should be good.
4. Next, we will add a new user that you will use to access your server over SSH for all future sessions - we will be disabling SSH access for root in a bit. Type `adduser zeus` to create a new user with the username *zeus*. Choose whatever username you want; it should be hard to associate with your website. Choose a secure password.
5. Now, create a new group that will be used for SSH by typing `groupadd sshusers` so that you can add any additional usernames directly to this group for SSH access down the road. The group name "sshusers" can be whatever you want, just like the username, but update #6 and #7 below also.
6. Let's add *zeus* to this new group by typing `gpasswd -a zeus sshusers`
7. We're going to edit the sshd\_config file that is used to access the server over SSH by typing `nano /etc/ssh/sshd_config`
    - Look for `PermitRootLogin yes` and change to `PermitRootLogin no` - this will disable root login from using SSH.
    - Look for `PasswordAuthentication no` and change to `PasswordAuthentication yes` -- if you're comfortable setting up SSH keys, you can come back and change this back to "no" later once you have your keys set up properly.
    - At the end of the file, add `AllowGroups sshusers` -- this is the group you created above.
    - Type `service ssh restart` so that all our new settings for SSH take effect. To access your server in the future, you must type `ssh zeus@123.123.123.123` (replacing the IP with the one Digital Ocean provides or your hostname and replacing *zeus* with your chosen username). Then, you can type `su` at the command prompt to become root to make server modifications.
8. You'll get a lot of script kiddies knocking on your SSH door, so I like to update the following files so that I don't worry about these attacks. This step assumes you have a static IP at your office or home location. *If you have a standard home internet provider, move to step #9*. You can also read about SSH throttling to minimize attacks even further. Let's edit some files... 
    - `nano /etc/hosts.deny` and add `sshd: ALL` to the end of the file - this file is read first and prevents all SSH access.
    - `nano /etc/hosts.allow` and add `sshd: 100.100.100.100` to the end, where you will be replacing this IP with your static office IP to allow access. Again, only do this if you have a static IP from your ISP.
9. Let's get a simple firewall installed. Type `apt-get install ufw` to install Uncomplicated Firewall - great resource [here](https://www.digitalocean.com/community/articles/how-to-setup-a-firewall-with-ufw-on-an-ubuntu-and-debian-cloud-server "UFW") for more details. Now, some basic rules: 
    - Type `ufw allow ssh` to access the server.
    - Type `ufw allow www` for web traffic.
    - Type `ufw allow https` if you plan on installing SSL on your site later.
    - Finally, type `ufw enable` to turn the firewall on.
10. To install Apache, type `apt-get install apache2` at the command prompt.
11. For MySql, type `apt-get install mysql-server` and it will then give you the option to choose a "root" password for your database server. Again, keep this password secure, and make it different than your server's root password.
12. Finally, to install PHP type `apt-get install libapache2-mod-php8.3 php8.3-mysql php8.3-dev php8.3-curl php8.3-gd php8.3-imagick php8.3-mcrypt php8.3-memcache php8.3-common php8.3-pspell php8.3-snmp php8.3-sqlite php8.3-xmlrpc php8.3-xsl` to setup PHP with the most common extensions. I think that's everything required for most CMS platforms.
13. You will probably want `mod_rewrite` on your LAMP server, so type `a2enmod rewrite` at the command prompt.
14. If you plan on using SSL, you can type `a2enmod ssl` then `a2ensite default-ssl` at the command prompt. You will need to modify /etc/apache2/sites-available/default-ssl with the proper paths to your private and certificate key files. This step is not necessary if you do not plan on using SSL.
15. Let's type `cd /home/zeus` and then `mkdir www` to create a working directory for your new site. Let's type `chown zeus:zeus /home/zeus/www` for good measure.
16. Now, type `nano /etc/apache2/sites-available/default` and change /var/www to /home/zeus/www in those couple of spots. Do the same for `nano /etc/apache2/sites-available/default-ssl` if you configured step #14.
17. We need to add www-data to our user so our web server runs properly using `gpasswd -a www-data zeus`
18. And last, you want to restart apache by typing `service apache2 restart` at the command prompt. You can add `ServerName yourdomain.com` to /etc/apache2/apache2.conf to stop the warning message on restart, replacing yourdomain.com with the domain you used to setup the server prior to step #1.

There you have it, 18 quick steps to get a very basic production-ready LAMP server. To upload your site, you can use any FTP client and choose SFTP as the connection method, then enter the username and password you created in step #4 above.

You will probably want to fine-tune the *OPcache* settings in your php.ini file and server further, but this guide will get you started.

As bonus steps, run `apt-get install postfix` after you log in to your terminal and `ufw enable smtp` -- both of these commands will get your outbound SMTP to work properly for any contact forms on your site. You can later fine-tune your Postfix mail server, but the first step will do almost all you need.

If you don't have a static IP at your home or business, you will want to use Shorewall combined with Fail2Ban for your firewall configuration (outside the scope of this article). To access your MySql databases, get in the habit of using [MySql Workbench](http://www.mysql.com/products/workbench/ "MySql Workbench") over an SSH connection.

Feel free to ask any questions or provide feedback by reaching out using the contact form.

 *Share* [  ](https://www.facebook.com/sharer.php?u=https://zadroweb.com/blog/quickstart-server-lamp-setup-digital-ocean/ "Share Article: Quickstart LAMP Setup Guide - Digital Ocean") [  ](https://www.linkedin.com/sharing/share-offsite/?url=https://zadroweb.com/blog/quickstart-server-lamp-setup-digital-ocean/ "Post Article: Quickstart LAMP Setup Guide - Digital Ocean") [  ](https://twitter.com/intent/tweet?url=https://zadroweb.com/blog/quickstart-server-lamp-setup-digital-ocean/&text=Quickstart%20LAMP%20Setup%20Guide%20-%20Digital%20Ocean "Tweet Article: Quickstart LAMP Setup Guide - Digital Ocean") [  ](mailto:%20?subject=Check%20Out%20This%20Article&body=%0D%0AQuickstart%20LAMP%20Setup%20Guide%20-%20Digital%20Ocean%0D%0Ahttps://zadroweb.com/blog/quickstart-server-lamp-setup-digital-ocean/ "Email Article: Quickstart LAMP Setup Guide - Digital Ocean") 

 

 ![Dario Zadro, Author at Zadro Web](https://www.gravatar.com/avatar/7fd3c6f03536f4ad85610768a8da304d?s=130&d=mm) 

### Dario Zadro

20+ years experience as a full-stack web developer. Owner of Zadro Web, where we provide web services such as web design, custom web development, SEO/UX, and fully-managed web hosting and cloud solutions.

 [  ](https://zadroweb.com "Vist My Website") [  ](https://twitter.com/dariozadro "Follow Me On Twitter") 

 

 

 

 

   ## Browse More in Cloud Computing

Explore insights about cloud computing with our informative articles. From infrastructure to information technology, security, migrations, and server builds, we cover trending topics on the many benefits of the cloud. Stay ahead of the curve in this continually evolving technology landscape.

 

 

 ![Http3 introduction](https://static.zadroweb.com/site/_card/http3-introduction.png) 

 [Cloud Computing](https://zadroweb.com/blog/cloud-computing/ "Cloud Computing") 

##  [HTTP/3: An Introduction to the Next Generation Web Protocol](https://zadroweb.com/blog/http3-introduction-web-protocols/ "HTTP/3: An Introduction to the Next Generation Web Protocol") 

Move over HTTP/2; there's a new kid on the block.HTTP/3 is finally here, and everybody's talking about it. Well, it's actually…

 

 

 ![Lemp tutorial digital ocean](https://static.zadroweb.com/site/_card/lemp-tutorial-digital-ocean.png) 

 [Cloud Computing](https://zadroweb.com/blog/cloud-computing/ "Cloud Computing") 

##  [Debian Install with Nginx and WordPress on Digital Ocean](https://zadroweb.com/blog/debian-lemp-nginx-wordpress-digital-ocean/ "Debian Install with Nginx and WordPress on Digital Ocean") 

I love VPS servers. Configuring them and customizing cloud solutions brings me joy.For the last seven years or so, we have…

 

 

 ![Php upgrade](https://static.zadroweb.com/site/_card/php-upgrade.jpg) 

 [Cloud Computing](https://zadroweb.com/blog/cloud-computing/ "Cloud Computing") 

##  [Upgrade PHP on a VPS: Debian &amp; Ubuntu Guide](https://zadroweb.com/blog/upgrade-php-vps/ "Upgrade PHP on a VPS: Debian & Ubuntu Guide") 

I've been managing VPS environments for over 15 years. And the one thing that never changes is how many production servers I…
