我可以在服务器的子目录中安装Laravel项目吗? [英] Can I install a Laravel project in a subdirectory of my server?

查看:134
本文介绍了我可以在服务器的子目录中安装Laravel项目吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个网站,该网站仅使用良好的原始PHP构建,没有框架等.现在需要向该网站添加一个博客,并且我想使用Laravel/Statamtic来做到这一点.我的问题是这样:

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:

我可以在服务器的子目录中安装Laravel项目吗?例如,www.mywebsite.com/blog/.理想情况下,blog目录中的所有内容都可以使用我的Laravel代码运行. blog目录之外的所有内容将继续按原样继续工作.这可能吗?

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?

如果可能的话,我需要在Ngnix配置文件中做些特别的事情吗?

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

推荐答案

您要做的就是将/public文件夹中的内容放入所需的子目录中,即"yourwebsite/blog".然后将内容从laravel根目录文件夹移到服务器上的根目录之外,因此,如果删除根目录,那么基本上所有项目中剩下的所有内容都会变成"/var/www/",如果您的根目录是"/var/www/html".之后,只需将index.php文件中的autoloader和app.php的路径更新,该文件以前在您的公用文件夹中,但现在在您的子目录中.请记住,如果执行此操作,则laravel应用中的所有路由都必须将子目录作为任何相对URL的一部分,可能很容易通过组来解决.

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.

如果您只是想做一个博客并且已经知道PHP,为什么不选择wordpress为自己做一个基本的模板呢?提货很简单,也许是一个周末.如果您认为它是VCCW的开发环境.

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.

这篇关于我可以在服务器的子目录中安装Laravel项目吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆