24 C
Dubai
Thursday, March 28, 2024

Migrate PHP and MySQL Site to Azure App Service


Let’s migrate a Phpmysql site from Godaddy to Azure App Service and Mysql

Go to Marketplace; let’s create a resource group

Web App + Database

Lets use PHP run time stack

It auto-creates MySQL with the wizard with proper private DNS zone

Generated resources after creation

App service is online now

Created Windows 10 VM and Installed SQL Workbench in the same vNet to connect to MySQL and App service FTP easily

You can download SSL and connection information from here.

Connect using MySQL Workbench

Enter the obtained password

Import your old database using .SQL export and import

Choose Target schema

Now DB is imported.

Now you can see Tables have been created.

You can see appropriate tables populated

Let’s load a test PHP file to test DB connectivity , You can see the FTP Credentials

Connect to App Service using FTP

if you are using WinSCP

Placed this file to test mySQL connectivity.

<?php
$servername = "azure365pro-com-server.mysql.database.azure.com";
$username = "izmayfiuav";
$password = "8EHW56653KRSH5MZ$";
$database_name =  "azure365pro-com-database";

// Create connection
$conn = new mysqli($servername, $username, $password, $database_name);

// Check connection
if ($conn->connect_error) {
  die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
?>

Connection failed: Connections using insecure transport are prohibited while –require_secure_transport=ON.

if you turn off secure transport

if you turn off secure transport

or use SSL from the PHP side (Recommended)

&amp;lt;?php
$servername = "azure365pro-com-server.mysql.database.azure.com";
$username = "izmayfiuav";
$password = "8EHW56653KRSH5MZ$";
$database_name =  "azure365pro-com-database";
$options = array(
    PDO::MYSQL_ATTR_SSL_CA =&amp;gt; '/DigiCertGlobalRootCA.crt.pem'
);
// Create connection
$conn = new mysqli($servername, $username, $password, $database_name, $options);

// Check connection
if ($conn-&amp;gt;connect_error) {
  die("Connection failed: " . $conn-&amp;gt;connect_error);
}
echo "Connected successfully";
?&amp;gt;

Satheshwaran Manoharan
Satheshwaran Manoharanhttps://www.azure365pro.com
Award-winning Technology Leader with a wealth of experience running large teams and diversified industry exposure in cloud computing. From shipping lines to rolling stocks.In-depth expertise in driving cloud adoption strategies and modernizing systems to cloud native. Specialized in Microsoft Cloud, DevOps, and Microsoft 365 Stack and conducted numerous successful projects worldwide. Also, Acting as a Technical Advisor for various start-ups.

Related Articles

LEAVE A REPLY

Please enter your comment!
Please enter your name here

× How can I help you?