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

我可以在服务器的子目录中安装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?

我的网站是用很好的香草PHP,没有框架等构建的。我现在需要添加 这个网站的博客,我想使用Laravel / Statamtic这样做。 我的问题是: p>

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

如果有可能,我的Ngnix配置文件中是否需要做一些特别的事情? p> div>

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.