Trick checkdnsrr in the dev environment - php

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.

Related

Is it possible to get FTP to work in VirtualBox using NAT networking or get php's ftp functions to work

I'm trying to get php's ftp methods to work from within a VM. I can connect using ftp_connect but not actually do anything afterwards.
HOST: Ubuntu 14.10
GUEST: Debian 7
Stack: Vagrant - VirtualBox - Debian - LAMP
I'm using vagrant to run a virtual box VM that runs a lamp stack. In php I'm running some method calls (ftp_pasv, ftp_nlist) that are not working.
I discovered that because of the FTP protocol using random ports for connections, the issue is caused by the use of NAT networking in virtualbox. I have the perfect vagrant-virtualbox setup except for this one issue. Does anyone know of a method to get ftp to work on the guest OS in this scenario. I know I could try using a bridged setup, but that means a bunch more work setting it up and the machine will be available to the public. So I would prefer to try to get it working behind that NAT.
I also have tried to use ftp_pasv to get passive mode turned on, which would fix the issue. But the method returns false when I call it to turn on passive mode.
As far as I know this isn't possible. Maybe if you want to hack some source code and compile custom solutions it will work. But that's harder than just using a different setup. I've resorted to using curl to make the ftp connections. Which works for listing files and downloading them.
Anyone that comes across this question and actually finds a solution please post it here.
The problem is most likely related to the network configuration. The fact that e.g. creating a directory works in contrary to getting the directory listing indicates, that theres an issue with the back channel.
A potential root cause is the configuration of the network router. It seems that some routers handle packages different if they are sent from different mac adresses (host vs guest system).
I had this issue and it turned out that upgrading Virtual Box solved the issue. Possibly some bug in the NAT interface.

Vagrant + Apache + PHP running extremely slowly on Windows

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

How to configure PhpStorm to use xdebug on a Vagrant machine

I am trying to configure xdebug to work in PhpStorm with my Vagrant machine, but I cannot figure out how to properly configure everything.
Here is the Vagrantfile I am using:
https://github.com/fideloper/Vaprobash
This Vagrantfile installs and configures xdebug for my Vagrant machine, but I'm not sure how to hook that up with PhpStorm. Between my xdebug.ini config, my web server config, and the PHP web app debug config, I cannot figure out how to get everything working.
When I click run->debug in PhpStorm, I get the following:
I have tried hacking away at the configuration details but have had 0 luck. Can anyone point out what I'm doing wrong here?
xdebug runs "backwards" to most typical server software one would deal with on Vagrant. IE, for apache you would fire that up on the VM and forward a port from the host to the VM so you could hit the server. Well, xdebug wants to push data from the VM to the host machine. Which means you need to feed xdebug the host's IP address -- which is probably the one the VM configured on the host only network and not your typical IP address -- and also to make sure that xdebug server is running and can accept connections.
Yeah that leaves a bit to be desired . . . .

Running a custom webserver in cloud9 environment and reaching it from the outside world

Is it possible to run serve my web application from another server than the one provided in cloud9?
For example : I would like to run different applications (PHP, Node.js - not sure what's possible yet) with nginx as the backend server (i) and/or a reverse proxy (ii) (to try different scenarios and configuration options).
Is it possible to run nginx and serve content to the outside world in cloud9?
Is it possible to have nginx as a reverse proxy in cloud9?
EDIT:
Here they write:
$PORT is exposed to the outside: When you run an application which listens on the port specified in the environment variable $PORT, you can access this application using the http://projectname.username.c9.io URL scheme. The proxy expects the server on that port to be a HTTP server. Other protocols are not supported.
This leads me to believe that if I would start nginx on port=$PORT it would be accesible via the specified URL sheme - can anyone confirm? Maybe anyone has tried this and can share some time-saving tips. Thanks.
I know this might be a late reply but might be helpful for those who are wondering how to do the same.
Short answer
I've created a repository to hold all the configuration needed on the process. Just run a command and NGINX and PHP-FPM will be serving and accessible from internet.
GitHub repo: https://github.com/GabrielGil/c9-lemp
Explanation
Basically to run NGINX on a c9 environment as you noted, you just have to make it listen on port 8080. YOu can either edit the default site on /etc/nginx/sites-available or create and enable your own (That's what the script above does)
Then, in order to run PHP-FPM script using NGINX, configure some permissions and the socket on the webserver is needed. By default, c9 uses ubuntu:ubuntu and the webserver www-data:www-data.
The script above also does this changes for you.
Hope this help you, or other users on similar situations.
You can run nginx on a normal Cloud9 workspace, as long as it listens to port 8080 (the value of $PORT). The URL scheme to reach your server would be http://projectname-username.c9.io, however. Please refer to the docs.c9.io for more up-to-date help on running applications.
One other thing you can do if you have another server where you would like to host your software, is to create an ssh workspace (https://docs.c9.io/ssh_workspaces.html). That way, you can connect Cloud9 to an external server directly.

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