简体   繁体   中英

Can I install a Laravel project in a subdirectory of my server?

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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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