dqpu4988 2015-11-17 14:44
浏览 39

在子目录中使用laravel,无root访问权限

A year ago, I decided to go with codeigniter instead of laravel, because codeigniter prooved to be easier to setup. I am now preparing for my next project and it seems as if codeigniter is now obsolete (at least most of the people seem to recommend laravel over codeigniter).

Now to my problem: I use a virtual ubuntu machine for developing web apps so I have a dev environment similar to the production environment (this helps me to avoid some problems (especially case-sensitivity...;)))

I installed composer and laravel and created a new laravel project named "quickstart" in /var/www/quickstart. I then followed their "getting started guide" (here: Guide). So far everything worked.

But here come the problems: I have two other web applications in /var/www, so when I enter the ip of the machine I see the 3 directories.

Issue 1: Normaly I'd expect that as soon as if I click on the "quickstart"-Directory in my browser, the webapp would get displayed, but I have to click a second time on "public", and then the webapp is displayed.

Issue 2: Of course, the links on the page are wrong too, because they reeer to (for example) "/task", which can't be found on the server.

The problem is that I'm not really experienced with apache configuration. I suspect it has something to do with VirtualHosts, but AFAIK you need to have root access to configure virtual hosts, and I do not have root rights on the dev environment.

Could you point out a way to me how I can make laravel work in a subdirectory in a way that I can just move the files and folders to my hoster as soon as I have finished the project? I'd like to then change only one file, and not all paths and URLs in all files ;)

Regards, Christian

  • 写回答

1条回答 默认 最新

  • dtuqxb3884 2015-11-18 22:20
    关注

    Thanks to Bogdan, I was able to figure it out. My hoster allows symlinks, so I did it like so:

    I put the laravel installation in

    /srv/web/quickstart
    

    (quickstart is the name of the project). I then created the following symlink:

    ln -s /srv/web/quickstart/public /srv/web/www/public
    

    The document root of the apache is configured to

    /srv/web/www/public
    

    After that I just got a blank page. That was because I forgot to set the correct permissions on the storage-folder. So I set the following permissions

    chmod -R 777 /srv/web/quickstart/storage
    

    This is fine for a development environment. For production I'd recommend to only allow the webserver-user to write into that directory.

    And voilà: Everything works!

    Thank you for your help bogdan. Christian

    评论

报告相同问题?

悬赏问题

  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 stm32开发clion时遇到的编译问题