This website uses cookies

Our website, platform and/or any sub domains use cookies to understand how you use our services, and to improve both your experience and our marketing relevance.

✨ Vultr and Linode are back on Cloudways! VIEW PLANS→

How to Host PHP on DigitalOcean (Step-by-Step Guide)

Updated on October 11, 2023

14 Min Read
php digitalocean

Are you looking to host a PHP application on a reliable cloud hosting provider?

As one of the most popular web development languages, PHP is used by 77.6% of all websites. However, finding the right hosting provider to host your PHP apps can be challenging.

Keeping that in mind, DigitalOcean (DO) is a popular choice among the top PHP developers worldwide. It is known for its reliability, consistency, and convenient data center locations.

In this blog post, I’ll show you how to host a PHP app using DigitalOcean as a cloud infrastructure on the Cloudways platform in minutes. Also, I will cover the easy steps to installing PHP directly on the DigitalOcean platform.

Let’s get started.

Ready to Take Your PHP Website to the Next Level?

Discover how Cloudways can simplify your DigitalOcean hosting experience and take your website to new heights.

Why Choose DigitalOcean to Host PHP

DigitalOcean is one of the five cloud providers supported by Cloudways, along with AWS, Google Cloud, Linode, and Vultr.

Here are some reasons you should host your PHP apps on DigitalOcean using Cloudways over other managed hosting providers:

Ease of use: Cloudways is a user-friendly platform that simplifies your PHP apps’ server & application management. It lets you launch a DigitalOcean droplet, install your preferred PHP stack, and deploy your application with just a few clicks.

Affordability: Cloudways offers a cost-effective solution for hosting your PHP apps with DigitalOcean. Starting from $11/month, you get features like management, backups, and enterprise-grade security on all its plans, making it a smart and budget-friendly solution.

Performance: DigitalOcean’s droplets are known for their speed and reliability. When combined with Cloudways, you get various tools to help you fully optimize your application’s performance, including a built-in caching system and content delivery network (CDN).

Support: Hosting your PHP apps on DigitalOcean with Cloudways provides 24/7 support to help you with any issues you might encounter, including server setup assistance, maintenance, and troubleshooting. Cloudways’ prompt support is particularly useful if you’re new to managing a server.

Security: With Cloudways’ enterprise-grade features like Cloudflare, SSH access, two-factor authentication, IP whitelisting, and more, you get an additional security layer on your DigitalOcean server, boosting network security and data encryption.

Overall, if you’re looking for an affordable, user-friendly, and reliable hosting solution for your PHP app, opting for DigitalOcean on the Cloudways platform is highly recommended.

However, if you have specific requirements better met by other cloud providers supported by Cloudways, such as AWS or Google Cloud, you may also want to consider those options. Feel free to check out the comparison of DigitalOcean with other cloud hosting providers to know more about its advantages.

An Overview of PHP Usage and its Popularity

PHP is a popular and widely-used programming language that offers developers a variety of features and benefits. With millions of websites currently using PHP, it’s clear that this language is well-suited for a range of advanced development projects.

PHP is the backbone of numerous globally recognized websites, with industry giants like Facebook, Wikipedia, and WordPress relying on its robustness and security. This widespread adoption showcases PHP’s exceptional scalability and underscores its importance to developers and end-users alike. When it comes to hosting MediaWiki, PHP’s reliability further solidifies its position as a go-to choice for web development.

With over 33 million live PHP websites (source: builtwith), including 1.8 million in the US alone, it’s clear that PHP is a highly popular and widely used language in web development.

Its popularity and widespread usage suggest it will likely remain a top choice for future web development projects.


Source: W3Techs

How to Install PHP on DigitalOcean (Easy Steps)

You can simplify your PHP apps hosted on DigitalOcean using the Cloudways platform. This managed web hosting platform offers server hosting on leading cloud infrastructure providers, including DigitalOcean.

With Cloudways, you can launch your server in just a few clicks and focus on development while they manage your server-related worries.

DigitalOcean is a reliable, cost-effective cloud hosting infrastructure that works well with PHP. It offers affordable bandwidth solutions and a reliable framework.

Learn how to launch a DigitalOcean server on Cloudways by following the easy steps below:

Step 1: Sign Up on Cloudways

  • Head over to the Cloudways platform signup page, fill in the form with your details, and click on the “START FREE” button to begin your 3-day free trial (no credit card required).

fill in the form

  • Verify your account by clicking on the “Activate My Account” button.

cloudways account activation page

  • Now you’ll need to verify your phone number. You’ll get a text message on your number with the code.

Phone verification cloudways

Step 2: Select Your Application

  • Once you’re logged in, you will be redirected to the server creation page.
  • Select your application from the drop-down menu. For this article, I have selected PHP (Custom App) as my application.
  • Name your managed app and server.

Name your managed app and server.

Step 3: Choose DigitalOcean as Your Cloud Infrastructure

  • Choose a cloud infrastructure provider from the list of market-leading providers. I have chosen DigitalOcean here.

Choose a cloud infrastructure provider
Step 4: Scale Your Server’s Size

  • Select your server’s parameters at this point as per your needs. You can pick any size in the beginning and later scale it as your resources increase.

Scale Your Server's Size
Step 5: Select Your Server’s Location

  • Choose the server’s location wisely for optimal performance. Proximity to the target audience is crucial for both server and application performance.

Select Your Server's Location

Step 6: Launch Your PHP Application on DigitalOcean

  • After verifying what you’ll be paying to host your PHP application on Cloudways, click on the “LAUNCH NOW” button.

Launch now

  • Now, wait a few minutes while Cloudways prepares and launches your server.

How to Manage PHP Application & Server on Cloudways

Once you have launched a DigitalOcean server on Cloudways, the next step is efficient management. One of the most notable benefits of Cloudways is its intuitive dashboard, which streamlines the management of your server and application settings.

The platform offers a range of user-friendly tools and features to help you easily manage your server, including automated backups, server monitoring, and application scaling. With Cloudways, you can optimize your server settings and track metrics to ensure optimal performance.

The user-friendly dashboard and efficient management tools provided by Cloudways enable you to streamline your server management tasks, making it an ideal choice for developers of all skill levels.

PHP Server Management on Cloudways

Cloudways’ server management tab offers a comprehensive array of management options on a single page, allowing for streamlined server settings management via efficient 1-click solutions. It offers you options, including:

  • Master Credentials – Access master credentials for SFTP and SSH access to your server.
  • Monitoring – View performance graphs on various server aspects.
  • Manage Services – Control your server’s core services.
  • Settings & Packages – Manage various server-level settings and packages.
  • Security – Manage your application and server security.
  • Vertical Scaling – Effortlessly increase the size of your server.
  • Backups – Manage your backup preferences.
  • SMTP – Enable or disable server-level add-ons.

PHP Application Management on Cloudways

The application management tab on Cloudways provides a suite of management options on a singular page, thus enabling the effortless administration of application settings through highly efficient 1-click solutions.

Below are some of the options you’d find on the Cloudways Application Management page:

  • Access Details – View and manage ways to interact with your application.
  • Staging Management –Test new code, plugins, and themes in an isolated environment without breaking your live site.
  • Monitoring – Easily monitor website resources like traffic, MySQL version, PHP version, disk usage, logs, and more.
  • Domain Management – Conveniently manage your application’s domain.
  • Cron Job Management – Manage your application’s cron jobs.
  • SSL Certificate – Create a free or deploy a paid SSL certificate for your applications.
  • Backup and Restore – Schedule or perform on-demand server-level backup that backs up all the applications deployed on the server.
  • Deployment Via Git – Manage deployment of your Application code using Git.
  • Application Settings – Configure several application-specific settings.
  • Cloudflare – Set up Cloudflare for your application.

How to Create and Launch a DigitalOcean Droplet

Heads Up!

Creating and launching a DigitalOcean droplet is a lengthy process. If you’re not tech savvy, this process might be more complicated than launching a PHP app on DigitalOcean with Cloudways that we shared with you earlier.

Now that we’ve gotten the disclaimer out of the way, just follow the steps below with screenshots to create and launch your first DigitalOcean droplet.

  • Step 1: Sign up or log in to the DigitalOcean platform.
  • Step 2: Create a new droplet by clicking Create > Droplets.

Create a Droplet on Digitalocean

  • Step 3: On the Create Droplets section, navigate to the setup screen. You have to configure the server specifications and other settings at this stage.
  • Step 4: Remove the Add block storage segment and select a data center region for your DO droplet, as shown in the image below. It is recommended to choose the closest location to your target audience.

Add block storage segment and select a data center region on cloudways platform

  • Step 5: Next, select an image. For this tutorial, I will go with Debian 10, which is the Linux OS flavor you will install on your server.

select an image on DO platform

  • Step 6: Choose the Droplet Type. For this tutorial, I will choose the Basic option.

Choose the Droplet Type

  • Step 7: Choose the server specification you need for your DO droplet. For this example, I’m going to select the most affordable plan.

Choose server specification for DO droplet

  • Step 8: After the previous step, leave the VPC Network and select the extra alternatives section.
  • Step 9: Navigate to the SSH keys section within the Authentication tab. If you have an existing SSH key, select it. If not, create a new one using the PuTTY generator. Please ensure that you have already installed PuTTY.
  • Step 10: Open PuTTYgen and click Generate an SSH key, as shown in the image below:

Generate an SSH key

  • Step 11: Copy the public key content and save the SSH key by clicking “Save private key.”

putty configuration

  • Step 12: Return to your DO server setup screen and click “New SSH Key.”
  • Step 13: Paste the text to the SSH key content segment, provide a title (e.g., Cloudways), and click “Add SSH Key.”

add SSH Key to DO platform

  • Step 14: Choose a hostname for your droplet. I’m naming it Shahzeb-PHP.

Choose a hostname for your droplet

  • Step 15: Now, leave all the sections because the server setup is complete, and all you need to do is Create a Droplet.

Create a Droplet

  • Step 16: Wait patiently, as setting up your droplet will take a while. If you see the below screen, it means your Droplet was successfully created.

DO Droplet successfully created

Deploy the LEMP STACK

Once you have set up your server, you have to deploy the LEMP stack, and here’s how you can do it:

  • Step 1: In order to deploy the LEMP stack, first, you need to open PuTTY and paste your server’s IP.

deploy the LEMP stack

  • Step 2: Navigate to Connection > SSH > Auth. Click on the browser and select the PPK file you downloaded from PuTTYgen.

configuring putty

  • Step 3: Click “Open” to access your DO server droplet and type root.

putty root access

  • Step 4: Change the directory and access the root file by typing the following command.
cd ..

Change directory

  • Step 5: Update the package lists by typing the following command.
apt update

Update the package lists

  • Step 6: Next, you need to install the NGINX web server. To do this, run the following command.
apt install nginx

install the NGINX web server

  • Step 7: Enter “Y” to continue.
  • Step 8: To install the MariaDB database, type the following command.
apt install mariadb-server

install MariaDB

  • Step 9: Enter “Y” again to continue.
  • Step 10: Type the following command to secure your MariaDB installation:

Note: At first, it will ask for the root password, and you just have to press “Enter” (By default, there’s no root password).

  • Step 11: If you want to set the root password for your database, press “Y” and update it.

set the root password for your database

  • Step 12: Type the following command to install PHP FPM and MySQL:
apt install php-fpm php-mysql

install PHP FPM and MySQL

  • Step 13: Edit the default file by typing the command below:
nano /etc/nginx/sites-available/default
  • Step 14: Then add index.php to that line as we are using PHP.

add index . php

  • Step 15: Next, uncomment the four lines by removing “#” as shown in the following image, and save the file by pressing “ctrl + x”.

uncomment four lines in the index.php file

  • Step 16: Now edit the php.ini file by typing the following command:
nano /etc/php/7.0/fpm/php.ini
  • Step 17: Type the command below:

fpm php

  • Step 18: Press “ctrl+w” and paste “cgi.fix_pathinfo=” with right-click.

provide path info

  • Step 19: Uncomment the line (by removing “;”) and set the value “0” like this: cgi.fix_pathinfo= 0;

cgi.fix _ pathinfo

  • Step 20: Exit by pressing “ctrl+x” and save the changes you’ve made.
  • Step 21: Check the configurations to confirm if it’s running or not. To do that, I will create a PHP file named shahzeb.php.
nano /var/www/html/shahzeb.php

Check the configurations to confirm if it's running or not

  • Step 22: Paste the following code into the PHP file and save the changes.

$name="Shahzeb Ahmed";

for ($i=1; $i<=9; $i++)


echo "My Name is: ".$name."<br/>";



php code

  • Step 23: Before running the newly created PHP file in the browser, restart NGINX by using the following commands:
systemctl restart nginx

restart NGINX

  • Step 24: After running the above script, check the PHP file in the browser.
  • If the newly created PHP file starts executing, then it will show “shahzeb” multiple times, which means you’ve successfully installed the LEMP stack.

successfully installed the LEMP stack

  • You can see in the above screenshot that your PHP code successfully runs, meaning PHP has successfully been installed on your DO Droplet.

Why Should You Host Your PHP App on DigitalOcean Using Cloudways

If you’re looking to host your PHP app on a reliable and scalable platform, DigitalOcean is worth considering. And if you want to make managing your DigitalOcean server easier and more efficient, Cloudways is the perfect tool.

Below are some of the reasons why you should host your PHP apps on DigitalOcean via Cloudways.

Latest PHP Version

Cloudways supports the latest PHP versions, including PHP 7.4, 8.0, 8.1, and 8.2, and provides dedicated servers for complete freedom. And the best part is you can upgrade or revert to an older version with just a click. Check out PHP 8.2’s new features, deprecations, and more in our detailed blog.

PHP Versions Supported Applications
7.4 ✓ WordPress 4.3.x and higher
✓ Magento 2.4.0 ~ 2.4.3
✓ Laravel 6.x and higher
8.0 ✓ WordPress 5.6.x and higher
✓ Magento 2.4.4 and higher
✓ Laravel 6.20.x and higher
8.1 ✓ WordPress 5.6.x and higher
✓ Magento 2.4.4 and higher
✓ Laravel 6.20.x and higher
8.2 ✓ WordPress 5.6.x and higher
✓ Laravel 6.20.x and higher

Unlimited PHP Workers

Cloudways optimizes your PHP app’s performance by dynamically adding PHP workers based on your server limits and custom PHP settings that you can adjust to enhance performance further.

Once you get a baseline of how many PHP workers and PHP memory limit you may be using and your traffic volumes, you can easily plan for future increases.

Unlock the Full Potential of Your PHP App With Cloudways’ Managed Hosting on Digitalocean!

Leave server management to us and focus on optimizing your app’s performance and enhancing user experience.

PHP Memory Limit

You can easily adjust your PHP app’s key settings without editing complicated configuration files such as the PHP.ini or wp-config. Cloudways provides an intuitive user interface that lets users modify settings directly from within the application settings, providing a seamless and hassle-free experience.

1-Click Backup & Restore

With Cloudways, you can access an advanced console that lets you manage your CNAME/Alias, set backup frequency, and perform manual backups or restores.

Additionally, Cloudways ensures your backups’ safety by storing them off-site, providing an extra layer of security and reliability. You can learn more about how to back up an entire WordPress website in our detailed guide.

Server & Application Cloning

Website and server cloning is as simple as 1-2-3 with Cloudways. Cloudways allows you to clone websites and servers for a quick database and application version compatibility test.

Also, it lets you clone servers to verify server resource requirements for your applications. Whether you need website cloning on the same server or launch a new server with pre–cloned apps, the choice is yours!


Cloudways has relentlessly prioritized quality, performance, and security on its platform. And its integration with Cloudflare lets you access strong performance capabilities to deliver a better user experience and optimized speed.

Its enterprise add-on maximizes CDN output to provide higher performance and availability for web hosting. The best part is Cloudflare Enterprise Add-on costs only $4.99/mon and goes as low as $1.99/mon.

PHP on DigitalOcean (Cloudways) – Pricing & Plans

Hosting your PHP app on DigitalOcean using the Cloudways platform is affordable, thanks to a range of pricing plans that cater to different needs and budgets. With plans starting at just $11/mo, even small and growing PHP applications can find a suitable hosting solution.

The image below shows the DigitalOcean plans on the Cloudways platform at a glance:


If you’re looking for a reliable and affordable way to host your PHP app, you should try DigitalOcean with Cloudways. Cloudways is a managed cloud hosting platform that offers a free 3-day trial, so you can test the platform and its features before committing.

By deploying your PHP app to DigitalOcean through Cloudways, you can experience the best of both worlds: the affordability and flexibility of DigitalOcean and the powerful features and support of Cloudways. So launch your PHP app on DigitalOcean with Cloudways today and experience an unmatched hosting experience.

Q1. How do I migrate an existing PHP website to DigitalOcean via Cloudways?

You can easily migrate an existing PHP website to DigitalOcean via Cloudways by following the steps below:

  • Create a new server on Cloudways with DigitalOcean as the provider.
  • Once the server is created, go to the “Applications” tab.
  • Click on “Add Application” and select “PHP Application.”
  • Fill in the application name and select the PHP version and server.
  • Go to your existing PHP website’s control panel or file manager and create a backup of all files.
  • Upload the backup files to your new Cloudways server.
  • Once the files are uploaded, go to the “Application Management” tab and set up the application’s database credentials and environment variables.
  • Finally, update your domain’s DNS settings to point to the IP address of your new DigitalOcean server.

Q2.Does DigitalOcean support PHP?

Yes, DigitalOcean supports PHP. You can install PHP on DigitalOcean droplets and use it to run your web applications.

Q3.Is DigitalOcean good for hosting PHP?

Yes, DigitalOcean is a good option for hosting PHP. DigitalOcean provides scalable and reliable cloud infrastructure and lets you choose from various droplet sizes and configurations to suit your needs. You can also use its pre-configured application images or install your own PHP stack.

Q4.How do I upgrade my PHP version on Cloudways?

To upgrade your PHP version on Cloudways, follow these steps:

  • Log in to your Cloudways account.
  • Select your application.
  • Click the “Server Management” tab and select the “Settings & Packages” option.
  • Scroll down to the “PHP” section and select the desired PHP version.
  • Click on the “Save Changes” button.
  • Cloudways will automatically update your PHP version and restart your web server.
Share your opinion in the comment section. COMMENT NOW

Share This Article

Abdul Rehman

Abdul is a tech-savvy, coffee-fueled, and creatively driven marketer who loves keeping up with the latest software updates and tech gadgets. He's also a skilled technical writer who can explain complex concepts simply for a broad audience. Abdul enjoys sharing his knowledge of the Cloud industry through user manuals, documentation, and blog posts.


Get Our Newsletter
Be the first to get the latest updates and tutorials.

Thankyou for Subscribing Us!


Webinar: How to Get 100% Scores on Core Web Vitals

Join Joe Williams & Aleksandar Savkovic on 29th of March, 2021.

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Do you like what you read?

Get the Latest Updates

Share Your Feedback

Please insert Content

Thank you for your feedback!

Want to Experience the Cloudways Platform in Its Full Glory?

Take a FREE guided tour of Cloudways and see for yourself how easily you can manage your server & apps on the leading cloud-hosting platform.

Start my tour


  • 0


  • 0


  • 0


  • 0



For 4 Months &
40 Free Migrations

For 4 Months &
40 Free Migrations

Upgrade Now