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.

One comment

Leave a Reply

Your email address will not be published.

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