AWS LAMP
In order to install all the features of an efficient web server, there are four main elements that are essential to build a website server:
- Here Linux represents the operating system, and it manages the available resources
- The Apache web server handles user requests
- MySQL acts as a database server to manage the various data
- PHP here is the programming language used to create dynamic web pages. Indeed, it is needed to have a binary that can execute PHP code, much like Python or Java.
1. MySQL database (Amazon RDS)
Amazon RDS standing for Relational Database Service is an AWS service allowing to create an environment to execute an instance of a relational database. It is also possible to use EC2 and install a server like MySQL but RDS makes life easier using a preconfigured ready-to-use server.
In the following, I report how to run a RDS server in the AWS cloud.
I have chosen the RDS service present in the Database group and, to launch an instance, I clicked on Create database, then I choosed MySQL as a database management system because it is free. While creating the instance, I have customized the server: several settings like instance name (corresponding to the database server that may contain several databases), master username and password, to indicate in which VPC the server is located, to choose or not the (public) accessibility to the server, to choose the database name… Creating and launching a new instance may take several minutes. When the server has started, Available is indicated as status. As shown in the following figure, more details of the instance are indicated, and in particular the endpoint which is the DNS address of the server.
Special emphasis should be given to the security group that should allow access and connection to the database server. In what I did, I opened all ports and gave access to any IP address, this is not great in terms of security but it allows me to test what I want without being blocked.
2. A virtual machine to install Linux (Amazon EC2), Apache and phpMyAdmin
After instancing a virtual machine using Linux as operating system (as shown in a previous section), to install a web site server, there are several steps :
- Update software packages
sudo apt update
sudo apt upgrade
- Install Apache web server
sudo apt install apache2 apache2-utils
apache2-utils installs some useful utilities
- Install MySQL
sudo apt install mysql-server mysql-client
mysql-client package allows you to connect to a MySQL server. It will give you the “mysql” command-line program.
mysql-server package allows to run a MySQL server which can host multiple databases and process queries on those databases.
- Install PHP
sudo apt install php7.4 libapache2-mod-php7.4 php7.4-mysql php-common php7.4-cli
libapache2-mod-php is a PHP library enabling Apache web server to interpret and handle PHP code so that Apache can sent rendered web pages to the clients rather than PHP code.
php-mysql package provides MySQL modules for PHP, to enable association and communication between PHP and MySQL database server.
php-common package contains common utilities shared among all packaged PHP versions.
php-cli package enables to execute PHP files using command line interface
In the following figure, is represented the default page of Apache 2 when the public DNS address of the server is entered in the browser.
- Install phpMyAdmin
phpMyAdmin is a tool that allows us to access and manage our database very easily, because the operations are done in graphical mode rather than with the mysql console.
I describe how to install and use phpMyAdmin from the Linux server.
sudo apt update
sudo apt install phpmyadmin
By typing the previous commands on the terminal of the Linux server, you install and configure phpMyAdmin, there are several steps of validation. When it is installed, you have to set up the configuration file in order to have access to the remote database.
In the file /etc/phpmyadmin/config.inc.php, I added the DNS address of the remote database, as indicated in the following figure.
When done, I launched phpMyAdmin using the DNS address of the Linux server, and as shown in the following figure, I fill in the user and the access password.
As shown in the following figure, it is now possible to remotely manage the AWS database server using phpMyAdmin.
Hence, we have a Linux server hosted in the AWS cloud and integrating PHP, a database server managed via phpMyAdmin through a web interface accessible from the first server: this is a web development environment enabling the creation of dynamic web pages.
Leave a comment