简体   繁体   English

有关如何在一个项目中设置多个laravel 5.1应用程序的教程

[英]Tutorial on how to setup multiple laravel 5.1 apps in one project

I am currently working on a Laravel 5.1 project which involves a public section and a admin section. 我目前正在开发一个涉及公共部分和管理部分的Laravel 5.1项目。 When googling around the issue I was having, I came across this stack post managing user role log in . 在谷歌搜索我遇到的问题时,我遇到了管理用户角色登录的这个堆栈帖子。 Where the first post recommends. 第一篇帖子推荐的地方。

Admin and Users in the same laravel app is a bad idea simply because the app will share the same session and storage information. 同一个laravel应用程序中的管理员和用户只是一个坏主意,因为该应用程序将共享相同的会话和存储信息。 There will be a myriad of egde cases that will cause information to bleed through any logic "walls" you set up and you'll end up spending way too much time patching those bleeds. 将会有无数的egde案例会导致信息在你设置的任何逻辑“墙壁”中流血,你最终会花太多时间修补那些流血。 What you really want to do is set up separate laravel applications for each: admin.project.com & project.com. 您真正想要做的是为每个应用程序设置单独的laravel应用程序:admin.project.com&project.com。 That way you get two separate sessions and storage. 这样你就可以得到两个独立的会话和存储。 All you need to do is ensure that the databases you need are setup in both database.php config files. 您需要做的就是确保在database.php配置文件中设置所需的数据库。 You can even host BOTH projects on the same server with separate deployments, listening to different ports. 您甚至可以在具有单独部署的同一服务器上托管BOTH项目,并侦听不同的端口。 TRUST ME this is the best way to go. 相信我,这是最好的方式。

Could someone explain in detail how it could be done? 有人可以详细解释如何做到这一点吗? I mean how should I set up my project. 我的意思是我应该如何设置我的项目。 I know It is easy for them to share the same DB and setting up that would easy. 我知道他们很容易共享相同的数据库并设置起来很容易。 First question, how can I have URLs admin.mysite.com as my admin section and www.mysite.com as my public section for my 2 apps Also how to set it up in Azure as a web app? 第一个问题,我如何将URL admin.mysite.com作为我的管理部分和www.mysite.com作为我的2个应用程序的公共部分还有如何在Azure中将其设置为Web应用程序? I got my one app I currently have working on Azure ( no 5.1 guides on the internet, got it deploying somehow). 我得到了我目前在Azure上工作的一个应用程序(在互联网上没有5.1指南,让它以某种方式部署)。

So could someone explain in detail how the project setup should like and how it should be done? 那么有人可以详细解释项目设置应该如何以及应该如何完成? Could not find guides for Laravel 5.1 and since 5.1 setup is different from 5 and 4.* I'm not sure how to continue. 无法找到Laravel 5.1的指南,因为5.1设置与5和4不同。*我不知道如何继续。

Per your description, it seems you need to deploy 2 apps with custom domains. 根据您的描述,您似乎需要使用自定义域部署2个应用。 If so, I think to deploy your admin and user apps separately on 2 Azure Web Apps services. 如果是这样,我想在2个Azure Web Apps服务上单独部署您的管理员和用户应用程序。 Which is benefit for management, deployment and scaling for each side of your applications. 这对您的应用程序的每一方的管理,部署和扩展都有好处。 To configure subdomains to your site, you can refer to Azure Websites and wildcard domains and Mapping a custom subdomain to an Azure Web App (Website) . 要为您的站点配置子域,您可以参考Azure网站和通配符域以及将自定义子 映射到Azure Web App(网站)

If you insist on deploy 2 apps on a single Azure Web Apps Service, you can try it with URL rewriting in IIS Web.config, Eg 如果您坚持在单个Azure Web Apps服务上部署2个应用程序,则可以在IIS Web.config中使用URL重写进行尝试,例如:

      <rule name="RewriteRequestsAdmin" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
              <add input="{HTTP_HOST}" pattern="^admin\.XXXX\.com$"/>
          </conditions>
          <action type="Rewrite" url="AdminApp/public/index.php/{R:0}" />
        </rule>
        <rule name="RewriteRequestsUser" stopProcessing="true">
          <match url="^(.*)$" />
          <conditions>
          </conditions>
          <action type="Rewrite" url="UserApp/public/index.php/{R:0}" />
        </rule>
      </rules>

To deploy your local laravel project to Azure Web Apps, you can use Git or FTP tools, please refer to Create a PHP-MySQL web app in Azure App Service and deploy using Git . 要将本地laravel项目部署到Azure Web Apps,您可以使用Git或FTP工具,请参阅在Azure App Service中创建PHP-MySQL Web应用程序并使用Gi​​t进行部署 But by default, the dependence folder vendor and composer files will not be deployed on Azure with project, so we have to login KUDU console site of your Azure Web Apps to install the dependences. 但默认情况下,依赖文件夹vendor和作曲家文件不会在Azure上部署项目,因此我们必须登录Azure Web Apps的KUDU控制台站点来安装依赖项。 You can install composer in site extensions tab of your KUDU console site which the URL should be https://<your_site_name>.scm.azurewebsites.net/SiteExtensions/#gallery then run command composer install in your app root directory. 您可以在KUDU控制台站点的站点扩展选项卡中安装composer,其URL应为https://<your_site_name>.scm.azurewebsites.net/SiteExtensions/#gallery然后在您的应用程序根目录中运行命令composer install

Additionally, you can simply leverage cmdlet on your KUDU console site, which URL should be https://<your-website-name>.scm.azurewebsites.net/DebugConsole , run the following commands: 此外,您只需在KUDU控制台站点上使用cmdlet,该URL应为https://<your-website-name>.scm.azurewebsites.net/DebugConsole ,运行以下命令:

cd site\wwwroot 
curl -sS https://getcomposer.org/installer | php 
php composer.phar install

For deployment laravel on Azure, you can refer to the answer of laravel 5.1 on windows azure web application for more information. 对于Azure上的部署laravel,您可以参考windows azure Web应用程序中laravel 5.1的答案以获取更多信息。

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

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