Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vagrant on Windows w/ Precise64 runs php very slowly

So I am have vagrant set up with virtual hosts on my development machine but when I try a very simple echo of 'hello world' it hangs for like 10 seconds before processing the file. HTML files render very quickly. Where do I even start to troubleshoot this?

After doing some research, others have complained of slow performance with php and virtualbox/vagrant. Many have claimed that the use of the shared folder between host/guest is the cause of this.

  • I have tried changing the shared folder location so that it is not pointed at /var/www/
  • I have also tried removing the shared folder configuration completely by removing the 'config.vm.synced_folder' statement

In each case I have re-provisioned the box but still get the same performance issues, at least a 10 second hang when hitting a simple php script in the web browser.

Other things I have tried:

  • running the same php script from the command line. This works just fine. Immediate response.
  • Hitting an html page from the web browser. Also I get a quick response.

This leads me to believe that the problem is somehow with the apache+php part of the stack.

Not sure what else to do.

like image 988
phirschybar Avatar asked May 23 '13 22:05

phirschybar


3 Answers

I've just come across this issue too.

Following on from ivanicus, it's related to the xdebug configuration. It appears that the request is hanging while xdebug is trying to connect to a remote debugging client. I have been able to resolve the issue by setting...

xdebug.remote_connect_back=0
xdebug.remote_autostart=0

I have then set the xdebug.remote_host value to the IP of the host machine, you need to make sure your guest machine can connect to the host on the IP you set. This allows me to debug within PhpStorm still.

It doesnt look like you can currently set the xdebug.remote_connect_back option within the ini settings on https://www.puphpet.com/ so I had to manually alter it within the php.ini

like image 178
mike.darke Avatar answered Nov 05 '22 16:11

mike.darke


After struggling with this same situation, removing the XDebug usage was the only "solution" I could find.

Taking into account a basic default Vagrant configuration from https://puphpet.com/ as the original poster:

  • Removed xdebug lines from "manifests/default.pp"
  • Removed folder "modules/xdebug/"
  • vagrant destroy
  • vagrant up

Notes:

  • I guess not including "xdebug" on the mentioned site would be the best solution, but I already had modifications on my vagrant configuration.
  • While not the "ideal" solution this one solves the mentioned slowness and would transform this issue on "how to enable and run properly xdebug on windows hosts"

Hope this helps!

like image 43
ivanicus Avatar answered Nov 05 '22 15:11

ivanicus


Many have claimed that the use of the shared folder between host/guest is the cause of this

I found this was definitely the issue in my case.

https://docs.vagrantup.com/v2/synced-folders/nfs.html

As I'm using windows, I wasn't able to use the NFS option either.

To test that this was the case, I moved all the SQLite files I was accessing onto the box using SFTP and the performance went back to the levels I was expecting.

like image 28
danski Avatar answered Nov 05 '22 17:11

danski