This is the first in a series of blogs that detail how to setup and use a LAMP Stack that makes use of MySQL HeatWave in the Oracle Cloud.
LAMP is an acronym that stands for Linux, Apache, MySQL and PHP. These technologies collectively form a stack to build, deploy and manage web applications. The LAMP stack is perhaps the oldest of all web development frameworks and is still one of the most important with some commentators suggesting that up to 50% of all new web developments either use the LAMP stack or a variant of the LAMP stack.
The stack can be visualized as follows:
The stack begins with a server and some storage. On the server a Linux operating system is installed. The Linux operating systems allows the other stack components to read from and write to the storage as well as make and receive network calls. MySQL is then installed. This is the stack’s database server and will store web application state (e.g. user details, store inventory, etc.). PHP is layered on top. It is responsible for implementing the business logic of our web application. As part of that logic PHP will use the underlying database to store data and later retrieve it when requested. Finally, we have the web server, Apache. This is responsible for receiving http(s) requests (e.g. a request for a web page) and responding to them (e.g. returning the requested web page). When a request is received by Apache it will determine whether the request needs processing by PHP and forward it accordingly. A request to PHP may require the services of the database, in which case it will communicate with the MySQL database. MySQL will return its results to PHP. PHP may further process these results before returning its data (typically in the form of a web page) to Apache. Apache will then package this as an http response and send it to the requestor.
A LAMP stack has a flexible architecture: the database server can be stored on a separate server to the application server (Apache and PHP). Splitting the components in this manner has a number of benefits:
MySQL HeatWave is a fully managed database service that enables customers to run OLTP, OLAP, and Machine Learning workloads directly from their MySQL Database.
Being a service most of the administration tasks are done for you leaving you to concentrate on your database schema. Given the purpose of this series of blogs is to detail how to build a LAMP stack from the ground up only the basic MySQL Database Service will be discussed; OLAP and Machine Learning are beyond its scope.
Currently (July 2022), there are three options:
This series of blogs will follow the first option: build your own. This will give the reader a full insight into how stack should be deployed and works. Further, if the reader follows these blogs they will be fully in charge of their own destiny both in terms of software versioning, security and cost.
The second option is a really good way to deploy a LAMP stack. Its only drawbacks are that it does not currently deploy the latest versions of Apache and PHP, and it is not clear whether its scripts will be maintained going forward. If you are happy with this approach and prefer it to building your own then please see the Community Managers blog.
The third option would seem to be the easiest way of deploying a LAMP stack. However, it has commercial, security and scalability limitations:
The first thing we need to consider is the infrastructure architecture:
Our logical infrastructure architecture design will look like this:
With respect to software the latest stable versions for Apache, PHP and MySQL will be used. MySQL is being implemented as a service, and the service always provides the latest stable version (8.0.29 at the time of writing, July 2022). Apache 2.4 and PHP 8.1 are the latest stable versions and shall be used. The Linux operating system to be used will be Oracle Linux 8. Note: OL8 is compiled from Red Hat 8 source code and effectively is Red Hat without the Red Hat branding. Therefore, the commands and work flows in this series of blogs should be applicable to all other variants of the Red Hat operating systems (i.e. Red Hat, Fedora and Centos). If you use Ubuntu then you should still be able to follow the work flow but there will be some differences when installing and using software, for example: repository access (apt as opposed to dnf/yum with OL8), as well as package and application names (e.g. apache2 as opposed to httpd with OL8).
In order not to over-complicate things, administration will be done from the application server. In the first instance the only additional software to be installed will be MySQL Shell; this will allow the upload of a test schema to the database.
Once the stack is in installed and operational, further software will be installed:
In terms of this blog series Git will be used to access the source code of a simple demonstration web app on GitHub. Certbot will be used to provide a TLS/SSL certificate so that users of the web application can access it securely.
In summary we have learned what the LAMP stack is and we have a clear architectural vision as to what we are going to build. All that remains is to press on with the second part of this series of blogs.
Continue to Part 2. You can also watch the recording below.