Deploy your own PHP application on OCI and MDS

Recently, I wrote several articles about how to deploy popular Open Source applications on Oracle Cloud Infrastructure and MySQL Database Service.

Today we will see how you can deploy your own LAMP stack application using the same technique where L will stand for a compute instance (and why not the Ampere always free trier?), A stays Apache and will run in that compute instance. M stands for MySQL Database Service and P for PHP.

As usual we start by deploying a Stack by just clicking on the deploy button from GitHub:

The we are directly redirected to OCI’s dashboard and we need to accept the Terms of Use:

As soon as we accept the Terms of Use, we see the information being updated, we can directly click on Next:

On the next screen, we can set all the variables. Some are mandatory and the others are already pre-filled:

This is also on that form that you have the possibility to choose the PHP version you wanna use:

You validate everything and you can Create the stack and deploy the architecture on OCI:

As you can see, we have all the generated ans required information in the Outputs section.

We can already use the public IP in a browser and we should see the following page:

Now the Web server is ready to get our code. From the stack’s outputs, we already know the ip, the username and password to use to connect to MySQL Database Service.

We also need the ssh key that we can copy locally to ssh to the Web Server to deploy our code, or we can use the Cloud Shell from OCI’s dashboard. Let’s use it:

We create a file for the ssh key (php.key) and we paste its content in it:

We change the permission of the key’s file and we use it to connect to our web server using it’s public IP:

As application, we will use this gist file which is a PHP script that connects to MDS and we will place it in /var/www/html:

We edit it and there are 3 variables to modify using the values from the Stack’s outputs:

When done, we can refresh the page on the browser and we will see our code being processed:

The Web server box already contains git and certbot.

Now you are able to deploy your own LAMP stack easily to OCI, enjoy !

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.


  1. Hi,
    An error occurs even though the Application instance is E3.Flex and OCI support (raised a limit increase ticket) claim that there are no limits if using E3.Flex. Is it possible that the default for MySQL (VM.Standard.E2.1.) should be changed? I have tried to type in ..E3.Flex but it still ends up with an error..

    Error: 400-LimitExceeded, You have reached your MySQL service limit of 0 in this Availability Domain for VM.Standard.E2.1.

    PS: I have tried different Terraform (0.13 and 1.0) and PHP 7.4 and 8 but is seems to be a shape error

    • Hi Lars,

      This doesn’t seems to be a Terraform issue but more a service limit on your tenancy.

      Are you allowed/able to start a MySQL DB (MySQL Database Service) manually on OCI web console ?

      • Hi, thank you for the fast response. I was able to create a MySQL.VM.Standard.E4.1.8GB.Standalone in my own compartment.

        When looking at MySQL limits in my compartment: MySQL Manual Backup Count mysql-manual-backup-count 1,200 (but the same is the case for Root .. I am admin – Amsterdam dc)

        • Fixed the problem: The optional MySQL shape has to be a specific MySQL shape and not a general compute shape

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

As MySQL Community Manager, I am an employee of Oracle and the views expressed on this blog are my own and do not necessarily reflect the views of Oracle.

You can find articles I wrote on Oracle’s blog.