duanba5777 2017-04-20 08:52
浏览 544
已采纳

Laravel加载视图需要很长时间

I have a LEMP stack setup using vagrant and virtual box on a windows Machine. php is version 7.0, Nginx is version 1.4.6. I've allocated a RAM of 768mb to the guest machine(Ubuntu 14.04.5 LTS)

On the guest machine, I've installed and configured composer as instructed on the Laravel documentation page. Using the Laravel installer, I installed Laravel in the www directory of my host machine laravel new commerce So the path to my laravel installation looks something like this /vagrant/www/commerce

In my Nginx config file, I configured Nginx to serve files from this location /vagrant/www/commerce/public and to redirect all request to the index page try_files $uri $uri/ /index.php?$query_string;

In the browser(chrome) when I test to see if everything is working fine, it takes about 4-5 seconds for the Laravel landing page to display in the browser. This is the same for safari and firefox. I shut down the guest machine and restarted it several times but the landing page still takes about 4-5 seconds to display.

I stumbled upon a post somewhere online where I was told to install debugbar. I installed debugbar successfully. When I tested in the browser again, It took about 16 seconds for the landing page to display. The strange thing here is that debugbar logged no messages. Frustrating.

Another solution suggested slowlog. So, first, i uninstalled debugbar and in my guest machine, i configured slowlog to track slow requests. I set a timeout of 10s. When i checked the slow.log file in /var/log I got what's in the image below slow.log I can't seem to make any sense out of this. please i need help.

Thanks in advance

  • 写回答

1条回答 默认 最新

  • dongya9904 2017-04-20 09:09
    关注

    I had a similar issue, and enabling NFS for folder sharing fixed it. Add NFS to ~/Homestead/Homestead.yaml

    folders:
    - map: ~/www/commerce
      to: /vagrant/www/commerce
      type: "nfs"
    

    And then provision your server.

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

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?