×
Community Blog Setting Alibaba Cloud ECS Instance With NGINX Supporting PHP and MySQL

Setting Alibaba Cloud ECS Instance With NGINX Supporting PHP and MySQL

Now there are some concerns among the developer community on how to enable an ECS to support server side execution of PHP scripts and support querying...

We all know how to create a 3 tier architecture based web application using Alibaba Cloud products from our previous blog. Now there are some concerns among the developer community on how to enable an ECS to support server side execution of PHP scripts and support querying MySQL queries to database engines in other products like Apsara RDS and PolarDB. This blog will be a tutorial on how to install a web server that supports PHP scripts and external MySQL sources.

Firstly create a basic ECS instance with internal and public IP addresses configured. Public IP address can be swapped with Elastic IP as well based on convenience and the project requirements. Internal IP address is used to whitelist the ECS from the RDS instances and public IP or Elastic IP is used to access the web server from a thin client.

Login to the command prompt of workbench.
1

Successful login shows as below.
2

Update the ubuntu operating system using the command as shown.
3

Upgrade the components of the operating system.
4

Install the nginx server.
5

Activate and check the status of nginx server.
6

Enter the public IP address of the ECS in a browser to check the functionality of the nginx server. In case public IP is not opted, Elastic IP can be mounted and used to check.
7

This page uses the folder /var/www/html/ in the ECS instance. This is currently supporting static page of html format only. At this point, if you add php files, it will be downloaded than to execute the scripts. So we install php and the current version is 8.1. This value should be changed when a new version is released.
8

Check the status of php installed.
9

Get into the configuration of the web server.
10

Edit the server function as follows:
11

Check the correctness of the php related configuration as below.
12

Restart the nginx now.
13

Provide read access to the root folder of your web application.
14

Create a php file to display information about php installed.
15

When the file is accessed through the browser, the following output is obtained.
16

This confirms the validity of php with nginx server.

0 1 0
Share on

ferdinjoe

19 posts | 20 followers

You may also like

Comments