duankuan5319 2017-08-08 17:42
浏览 128
已采纳

我可以在服务器的子目录中安装Laravel项目吗?

I have a website that was built with just good vanilla PHP, no frameworks, etc. I am now needed to add a blog to this website and I am wanting to use Laravel / Statamtic to do so. My question is this:

Can I install a Laravel project in a subdirectory of my server? For example, www.mywebsite.com/blog/. Ideally, everything in the blog directory would operate with my Laravel code. Everything outside of the blog directory would just continue to work as is. Is this possible?

And if it is possible, is there something special I need to do in my Ngnix config file?

  • 写回答

1条回答 默认 最新

  • doujie1908 2017-08-16 12:11
    关注

    All you would have to do is take the contents in the /public folder and put it in the desired subdirectory, so "yourwebsite/blog". Then move the contents from the root laravel folder to outside the root folder on the server, so basically everything that is left in the project after you remove public would then go into say "/var/www/" if your root folder is "/var/www/html". After that simply update the path to the autoloader and app.php in the index.php file, which was previously in your public folder but is now in your sub directory. Keep in mind if you do this all routes in the laravel app will have to have the subdirectory as part of any relative url, probably simple to solve this with a group.

    If you are simply looking to do a blog and already know PHP why not pick up wordpress and do a basic template for yourself? It's simple to pick up, a weekend maybe. If you consider it check out VCCW as a development environment.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示
  • ¥15 arduino 步进电机
  • ¥20 程序进入HardFault_Handler
  • ¥15 关于#python#的问题:自动化测试