How To Host Laravel 5 Web App To Azure Along With Its Database?

- 1 answer

I've tried to host the Laravel 5 web app by following this tutorial, .

It successes and I can access my web apps URL, but I cannot access some elements of my web apps because some of them need database.

Before hosting it, I've test the web apps using xampp, localhost & mySQL, and it works perfectly by using the ability from Laravel5 to migrate the database to mySQL(xampp)

My question is, how to configure the database in azure so it will work with our web apps? I've heard that some people telling about the .env file, but I don't know what to do with it to make the database works. Thanks.



ClearDB provides MySQL database Services in Azure, you can leverage it to create and host your MySQL database, then set the MySQL connection info in your laravel application configuration files.

You can follow the steps below to create a MySQL database on Azure:

  1. Login Azure Manage portal, click NEW button, write "Mysql" in search bar, select the "MySQL Database" service and click "create".enter image description here
  2. Fill the basic information of your MySQL database:

    enter image description here

  3. In the manage page of your MySQL server, you can find all connection info in Properties section: enter image description here
  4. Then you can set the connection info in your laravel app, at config/database.php: 'mysql' => array( 'driver' => 'mysql', 'host' => '', 'database' => '<your_database_name>', 'username' => '<your_user_name>', 'password' => '<your_password>', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ), And the database setting should be modified in .env file as well.

Additionally, you can leverage your MySQL workbench to connect to MySQL database on Azure to manage your data.