简体   繁体   English

如何将laravel 5 web app与其数据库一起托管?

[英]how to host laravel 5 web app to azure along with its database?

I've tried to host the Laravel 5 web app by following this tutorial, 我已经尝试按照本教程主持Laravel 5 Web应用程序,

http://blog.bobbyallen.me/2015/06/26/configuring-and-hosting-laravel-5-x-applications-on-windows-azure/ . http://blog.bobbyallen.me/2015/06/26/configuring-and-hosting-laravel-5-x-applications-on-windows-azure/

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. 它取得了成功,我可以访问我的网络应用程序URL,但我无法访问我的网络应用程序的某些元素,因为其中一些需要数据库。

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) 在托管它之前,我使用xampplocalhostmySQL测试Web应用程序,并且通过使用Laravel5将数据库迁移到mySQL(xampp)的功能,它可以完美地运行

My question is, how to configure the database in azure so it will work with our web apps? 我的问题是,如何在azure中配置数据库,以便它可以与我们的网络应用程序一起使用? 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. 我听说有些人讲述.env文件,但我不知道如何处理它以使数据库正常工作。 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. ClearDB在Azure中提供MySQL数据库服务,您可以利用它来创建和托管您的MySQL数据库,然后在您的laravel应用程序配置文件中设置MySQL连接信息。

You can follow the steps below to create a MySQL database on Azure: 您可以按照以下步骤在Azure上创建MySQL数据库:

  1. Login Azure Manage portal , click NEW button, write "Mysql" in search bar, select the "MySQL Database" service and click "create". 登录Azure管理门户 ,单击“ 新建”按钮,在搜索栏中输入“Mysql”,选择“MySQL数据库”服务,然后单击“创建”。 在此输入图像描述
  2. Fill the basic information of your MySQL database: 填写MySQL数据库的基本信息:

    在此输入图像描述

  3. In the manage page of your MySQL server, you can find all connection info in Properties section: 在MySQL服务器的管理页面中,您可以在“ 属性”部分中找到所有连接信息: 在此输入图像描述
  4. Then you can set the connection info in your laravel app, at config/database.php : 'mysql' => array( 'driver' => 'mysql', 'host' => 'xx-xxxx-azure-xxxx-c.cloudapp.net', '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. 然后你可以在你的laravel app中设置连接信息,在config/database.php'mysql' => array( 'driver' => 'mysql', 'host' => 'xx-xxxx-azure-xxxx-c.cloudapp.net', 'database' => '<your_database_name>', 'username' => '<your_user_name>', 'password' => '<your_password>', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ),并且数据库设置也应该在.env文件中修改。

Additionally, you can leverage your MySQL workbench to connect to MySQL database on Azure to manage your data. 此外,您可以利用MySQL工作台连接到Azure上的MySQL数据库来管理数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM