Vagrant + Apache + PHP running extremely slowly on Windows - php

I have a Vagrant VM running Apache and PHP. All requests are routed initially by mod_rewrite.
When a request comes in with anything other than .php, Apache just serves that file directly. This works almost instantaneously both from inside and outside the vagrant VM.
When a request comes in with .php, a couple rewrite conditions are checked and ultimately Apache sends the request to PHP, which loads our Symfony kernel environment and whatnot. I've tried adding exit('test'); to the very first line of that kernel bootstrapping file, so response should be as fast as possible. Literally all that's happening is Apache is sending the request to PHP which is exiting immediately. From inside the VM, this executes almost instantaneously. From the host machine this results in 10+ minute load times.
Also, everything works perfectly on OS X, and the exact same setup works fine on a different Windows machine. I've tried reinstalling/rebuilding pretty much every part of the technology that's driving this to no avail.
So what the heck? There's something different between requesting PHP vs. non-PHP content from the VM, but that difference only exists when the request comes from outside the VM.. and only on a specific Windows machine.
I'm absolutely stumped. Any ideas?

I've had a very slow site in vagrant become perfectly usable by switching from the virtualbox provider to the vmware one.
This is a somewhat expensive solution though, as you should definitely NOT install the trial version of vmware because it doesn't play nicely with the vagrant vmware plugin (follow the official instructions to uninstall vmware then reinstall the full version after purchasing).
Also the vagrant vmware plugin is a separate purchase from hashicorp. In my experience they're definitely worth it though. Would you pay a total of 100 bucks or so for an easy life?
Alternative things to try before splashing out.
Explicitly specify the resources for the vm in your Vagrantfile and use private_network instead of port forwarding. Allow 1/4 of your system ram for the virtual machine. Don't use an ip address that's already being used on your system. It should work fine as shown below.
Vagrant.configure(2) do |config|
config.vm.box = "lattice/ubuntu-trusty-64"
config.vm.network "private_network", ip:"192.168.50.4"
config.vm.provider "virtualbox" do |v|
v.memory = 2048
v.cpus = 2
end
end

Related

Network Issues with LEMP set up through WSL using PHP, Composer, NPM

Hope everyone is well
I have set up a LEMP environment on Ubuntu 18.04 WSL. I am using PHP7.1-FPM, Composer and NPM for an application running from a webserver.
I have set up the virtual host file and can browse to the webpage and open the application and connect to the database over localhost:80. But my issue is, it feels like there is almost a timeout on the LEMP setup. On the application, there is a 60-second timer where it automatically refreshes and pulls updated information from the MySQL database. If I press the inbuilt button to refresh it, that seems to work fine, but the minute it tries to do an automatic refresh, it throws up an error saying:
net::ERR_INCOMPLETE_CHUNKED_ENCODING
Uncaught (in promise ) Error: Network Error
at e.explorts
at XMLHttpRequest.f.onerror
I did try adding proxy buffers:
proxy_buffers 8 1024k;
proxy_buffer_size 1024k;
I feel as though Windows 10 is playing a part. from my knowlege, port 80 is in use on windows 10 from PID4 HTTP service which is used by the print spooler but when i set it to a different port, It does not even connect (1111).
I am just starting out really with this. I have (basic compared to most of you guys) knowledge in troubleshooting but WSL and LEMP is a new frontier to me so any help woul be much appreciated.
Many thanks in advance.
I think I know what the issue is, we use allow override in our vhost but this is not available on Nginx. It would mean me having to convert our vhosts file.
If anyone can assist with this, I would be most great full. In the mean time, I went with apache2 in wsl.

xampp apache server up and running, yet bad request

I got some trouble with my xampp on Win 10, as so many have had before me...
It's the same old port problem with skype and IIS.
I used to quit skype and stop the world wide web publishing service, but am sick of having to go through the whole ordial every time I start xampp.
so yesterday I changed the ports for my apache server and ecerything worked fine.
started up today and boom...localhost couldn't find my pages.
So I checked for port problems in xampp...there were none! apache was up and running(as were mysql server and filezilla). no error messages, nothing.
I resetted the ports to 80 and 443. killed of skype and the iis and everything worked fine again. Now whenever I change the ports, it will not run.
I did everything according to here:
How to change XAMPP apache server port?
(I changed the ports in httpd.conf, httpd-ssl.conf and in service and port settings )
I just don't get it. why it won't run with changed ports(and yes I checked the ports for being empty).
atm I have changed the port 80 -> 8024
and port 443 -> 1337 (no matter what I change this port to it always throws bad request)
8024 works fine. I can get to the dashboard via localhost:8024
but localhost:1337 gives me a bad request.
any suggestions, or similar encounters?
For now will have to continue using standart ports and kill of the 2 processes, but I really wanna skip that in the future.
I used port 80->8024
and port 443->448 yesterday and it worked fine...really weird...
Ok so that means your system has Microsoft IIS installed or one of the other bits of MS technology that reports that signature, they are doing that on later versions of Windows for some reason.
If you are not intending to use it you can uninstall it, it is not an integral part of windows so its being uninstalled wont effect normal operations of windows, and if you need to install it again later, it comes as part of the standard OS so you wont need to do anything perticularly clever.
So go to Start -> Control Panel -> Programs and Features
Click the 'Turn windows features on and off' link in the left hand menu.
Wait for the list to load and then find 'Internet Information Services'
Un check the check boxes for the following items ( you may not see all of them ), and there may be others I done know about. You may have all of these or just some of these.
IIS
Web Deploy 2.0 (Web Deployment Agent Service)
MS Sql Server Reporting service.
BranchCache ( Windows 8.1 )
SQL Server VSS Writer
List of possible service names not sure how up to date this is.
Tutorial on how to find what ports are in use on your system and what app is using them
Windows will then have a think for a while and then remove those applications, you will probably be asked to reboot to complete the uninstalls.
Reboot anyway when the uninstalls are complete.
Then try XAMPP again

Trick checkdnsrr in the dev environment

We use Vagrant to spin-up dev environemnt VMs. Within our VM infrastructure we have /etc/hosts setup to emulate our production urls. For example, if an app lives in production at https://foo.bar.com, then in our VM environment it is https://test-foo.bar.com. This has been working well but I recently hit a hiccup.
We use Symfony2, and have a field with a Url constrant and checkDNS set to true. That fires of a validator that runs the following.
if (!checkdnsrr($host, 'ANY')) {
Since this is actually reaching out to the DNS server for answers, and it of course knows nothing of my /etc/hosts file, and https://test-foo.bar doesn't really exist, this fails.
Is there an easy way to configure the VM so that this works, short of setting up a DNS server and pointing all the VMs to use it?
The VMs are running Ubuntu GNU/Linux.

Wamp server is not working although it is showing green icon

I have been developing a php project and the wamp server was seems
working fine but suddenly it stops working and i don't know what to do
because when i check its status it says server online and green icon is also
showing but it just does not work whenever i run .php files, Mr. browser
just write it down as i did in notepad++ but before some days it was working
fine, please help me I'm kinda stuck?
I also want to mention that in the mean while I installed tomcat server for some other work is it anything to do with fault because i'm pretty sure both operating on differnet port numbers
use <?php instead of <?or left click wamp > php > settings > short_open_tags
and make sure you are running your scripts through localhost and not just opening the php file in the browser
Read More about wamp problem
If you're definitely viewing the script through your MAMP setup (if your URL bar starts with http:// instead of file://) and it is showing the contents of the PHP file instead of executing the script, it sounds like Apache is running fine, but PHP-FPM is the issue or a misconfiguration between the two. Apache should detect it is a PHP script and ship it to the PHP-FPM process, accept a response then ship it to your browser.
I would recommend checking PHP-FPM logs first. All logs are in MAMP/logs - scroll to the bottom of each one for latest entries. Ensure the service is running as expected and logging hits when Apache serves a .php file. PHP-FPM may be using a socket file (which can hit permission problems) or on a network port (which can be in use/require admin privileges/etc). Otherwise check your config files, or re-install MAMP for fresh config files.
If Apache cannot start, common reasons are;
The port is in use by another application
The port is a low number and you do not have administrator privileges to use that port
Switching from wired to wireless / switching network adapters / changing hostname, etc
Apache is already running, or Apache thinks it is
You must sign out from Skype it'll occupied the port of Apache or you should turn down the server and then restart you pc and turn it on. It will work fine.

setting up remotely accessible wamp server along with iis

I am new to Windows IIS and I need to run a php/mysql application on it. For local php development on windows, I have found WAMP to be the easiest.
But can WAMP be used in this case instead of installing php and mysql separately ?
This needs to be done on an ec2 Windows 2003 instance. So far, I have already tried installing WAMP and setting up apache to listen on port 8080 instead of 80. From inside the remote desktop, both IIS and WAMP work properly in parallel on their respective ports.
However, when I try to connect from another computer using the ip address http://184.**.***.***, IIS works fine serving the default web page but cannot connect to apache on http://184.**.***.***:8080.
Is it possible to use WAMP at all for this purpose and if yes, would there be any disadvantages in using it instead of installing php/mysql seperately ?
Edit :
I dont know if this is a problem of blocked 8080 port. To verify this I stopped IIS and configured apache to listen to 80. Even then http://184.**.***.*** doent show the WAMP homepage. IS anything needed to be configured in IIS ?
RESOLVED :
Added the port 80 in Windows Firewall Exceptions and it started working.
Also, its necessary to select "Put Online" in the WAMP tray otherwise it gives a forbidden response as suggested by some answers.
Thanks
I haven't used EC2 in this way before, but broadly speaking, I'd encourage you to use the same server for development and production environments if at all possible - the installation effort can be a bit of a pain, but it's nothing compared to developing an app locally and then finding an IIS configuration issue causes it to break on production.
This approach also lets you keep your PHP configurations in source code control - php.ini and any modules you're using - and automatically deploy them alongside your application; again, forgetting to deploy the correct PHP.ini usually makes your application do crazy things...
So, your choices appear to be:
- switch off IIS and have WAMP listen to port 80. Not sure WAMP is designed for production level traffic, but in the past, I've run low-traffic public websites in this way.
- work out why port 8080 is blocked, and if it can be unblocked. This would still require you to run your website on an unusual port, which makes for ugly and hard-to-communicate URLs.
- install PHP on your IIS instance. One benefit of having installed WAMP is that MySQL should already be up and running, and the basic PHP installation should also be there; getting PHP to run on IIS is no longer a dark art ([http://php.iis.net][1])
For my money, I'd go for the latter option...IIS is a production quality server, and it's clearly what Amazon want you to use in this instance.
Of course, running IIS on your development environment may be a problem.
Have you put the server online? Think it is offline by default, meaning it's only accessible from your local machine. It's an option in the systray menu to put it online.
If I remember well, there is an option "go public" (or "put online") on the system traya icon of wamp.
This option modifies the httpd.conf to authorize public access.
You should give a try.
On a side note, you can make php work with IIS. This is another option to help you manage your server. (Mysql and Php have to be installed separatly but, this is very easy to do as far as I remember :) )

Categories