PHPMyAdmin blank whitescreen (414 Request-URI Too Long)

Ran across an interesting issue where PhpMyAdmin on a newly installed CentOS server was not rendering in a browser. Or more accurately, it was rendering but the CSS kicked in and caused the browser to display a blank page rather than the desired login screen. (Doing a View Source on the page showed that the login form was in fact there, but hidden by CSS.)

After checking the obvious things: PHP running (with error reporting on), file permissions, Apache working, VirtualHost definition correct, I was stuck. There were no indications of a problem, and PHP reported nothing. (Because, as we will see, there were no errors to be displayed…or was there?)

Finally, I turned on Firebug and refreshed the page. Voilà! There were actually two issues, but they were hidden within additional calls in the backend:

Screenshot from 2016-05-05 17-29-03

Wow, those two long URL strings! One URL was:

https://{domain-withheld}/phpmyadmin/js/get_scripts.js.php?scripts%5B%5D=jquery/jquery-2.1.4.min.js&scripts%5B%5D=sprintf.js&scripts%5B%5D=ajax.js&scripts%5B%5D=keyhandler.js&scripts%5B%5D=jquery/jquery-ui-1.11.4.min.js&scripts%5B%5D=jquery/jquery.cookie.js&scripts%5B%5D=jquery/jquery.mousewheel.js&scripts%5B%5D=jquery/jquery.event.drag-2.2.js&scripts%5B%5D=jquery/jquery-ui-timepicker-addon.js&scripts%5B%5D=jquery/jquery.ba-hashchange-1.3.js&scripts%5B%5D=jquery/jquery.debounce-1.0.5.js&scripts%5B%5D=menu-resizer.js&scripts%5B%5D=cross_framing_protection.js&scripts%5B%5D=rte.js&scripts%5B%5D=tracekit/tracekit.js&scripts%5B%5D=error_report.js&scripts%5B%5D=config.js&scripts%5B%5D=doclinks.js&scripts%5B%5D=functions.js&scripts%5B%5D=navigation.js&v=4.6.1

A quick search uncovered a possible fix. The default Apache limit of the request line needed to be made longer to accomodate PhpMyAdmin. Doing this was simple. I added the directive to ‘/etc/httpd/conf/httpd.conf’ like so:

LimitRequestLine 800

I tried a few different lengths and found that 700 was too short, but 800 worked fine. Also, though I simply added this to the conf file, according to the docs you can add this within the VirtualHost rather than making it blanket covering the entire server.

Hope this helps others.

Ubuntu 16.04 and PHP 7 not rendering

After reloading my work laptop with Ubuntu 16.04 LTS (I prefer to do a reload versus an upgrade, for each LTS version) I was very excited to install PHP 7, and installed using the standard Ubuntu repositories using typical commands:

$ sudo apt-get install apache2
$ sudo apt-get install php7.0

However, after doing the installs I discovered PHP scripts would not render in a browser. After a small amount of digging I realized that doing the base installs did not include one important piece. The package ‘libapache2-mod-php7.0’ was not automatically installed as expected, as it did in the past. (I don’t remember needing to install it separately in the past.) Hopefully the package maintainers fix this at some point. Your mileage may vary.

$ sudo apt-get install libapache2-mod-php7.0

So one quick install like shown previous and all is working fine.

Happy PHP’ing.

Using an SSH tunnel to step debug through a firewall

In a previous post I covered how to set up step debugging in Zend Studio. But if that doesn’t work there may be a firewall in between the server and the debugging client, or IDE, preventing the connection. Here is a possible way to get around that.

Note: Of course there is no way to avoid the firewall, but this post assumes a connection to the server using SSH is possible. What we’ll do is allow communications from the server to the client using the Zend Studio default debugging port (10137) forwarded through an SSH tunnel which uses port 22 by default. For this to work an SSH connection must be possible from the client to the server.

While it is possible to do this using command line from Linux or Mac, or using PuTTY on Windows, this example will use the built-in SSH capabilities of Zend Studio 13. For older versions of Zend Studio I recommend using command line or PuTTY linked above.

Assuming step debugging in Zend Studio was already set up as outlined in my previous post we will continue using that setup, but enhance it with an SSH tunnel.

In Zend Studio open the preferences. (Windows|Preferences) With the preferences open, expand the PHP node to get to Servers. Highlight the server configuration to work with, and click Edit.

Screenshot from 2016-04-18 15:07:40

When the Edit Server dialog opens select the SSH Tunneling tab. Check the box to Enable SSH Tunneling, and populate the desired Username and Password. If your server requires the use of an SSH Private Key in order to login, please supply that.

Screenshot from 2016-04-18 14:41:34

Now that the SSH connection is set up we need to add the Port Forwarding for the debugging port. Do this by clicking the Add button in the Port Forwarding section.

Screenshot from 2016-04-18 14:43:45

Select ‘remote’ to specify which side of the tunnel will be sending communication on the forwarded port, enter the local address the remote side (server) will use and port number to send to. Then enter the port number on the receiving end (the client). Now click Finish to apply the setup, and click finish to exit the preferences.

In the PHP Servers view (Windows|Show View|PHP Servers) right-click the server we just added SSH Tunneling support to and select Open SSH Tunnel. You should then see a brief dialog letting you know the connection was made.

Screenshot from 2016-04-18 14:52:41

We are ready to debug!

Since I was using Zend Server in this example I have Z-Ray available, and while on a page I wished to debug I could simply click on the debug icon and select any of the debugging options.

Screenshot from 2016-04-03 15:24:13

This will cause Zend Debugger to contact Zend Studio for debugging, which in turn will ask the user if they wish to open the debugging perspective.

IMPORTANT NOTE: Debugging over an SSH tunnel is not fast. Therefore you may notice a lag between initiating the debug session and your IDE reacting. After that things speed up, but the initial connection is slow on many networks.

Screenshot from 2016-04-03 15:24:44

If Yes is selected the IDE is now ready to perform any debugging the user desires.

Screenshot from 2016-04-03 15:27:24

Happy debugging!!!

This post is one in a series on debugging. For others click below:

PHPStorm and debugging issue
Setting up step debugging in Zend Studio

Setting up step debugging in Zend Studio

Recently I was helping someone set up step debugging in Zend Studio, and had some difficulties. Therefore I decided to create a blog post to remind me later, and perhaps help others get it set up.

I was doing this on an Ubuntu laptop, so while menus may vary slightly the process should be very similar. Also, I did this using a local virtual machine in VirtualBox, but using Bridged networking mode to simulate a remote server. In Zend Studio I had a project created with the Zend Framework Skeleton Application, and created a virtualhost in the virtual environment that mirrored that.

NOTE: If the desire is to use a local server the setup is similar.

Server setup

While this post doesn’t cover how to install Zend Debugger or Xdebug, ensure these are set up correctly. Also, ensure the debugger of choice “knows” where to find the IDE to be debugging from. Zend Debugger can try to do this automatically, or an IP can be manually specified with Xdebug. Also, if using Zend Debugger ensure the IP of the client is added to the whitelist. More on how to verify this IP from the client later.

Aiming at the server

The first step is to add a server to a Zend Studio project configuration. Do this in the preferences. (Windows|Preferences)  With the preferences open, expand the PHP node to get to Servers.

Screenshot from 2016-04-03 15:17:07

From there click “New”, and follow the wizard for setup. The first step is to specify the type of server. In my case I was using an install of Zend Debugger that comes with Zend Server, so selected Remote Zend Server. Alternatively I could have easily selected Generic PHP Server and arrived to the same endpoint later.

Screenshot from 2016-04-03 15:17:47

Next, after giving this server a name and URL (ensure the URL actually hits the server), I am prompted for the Zend Server login credentials to gain access to the Zend Server Web API.

Screenshot from 2016-04-03 15:19:09

Entering the user and password authorizes Zend Studio to pull down an API key for interacting directly with Zend Server if I desired to later. (This creates a new API Key on the server specifically for this client.) Alternatively it is possible to click Cancel and enter the credentials manually.

Again, this is not really required for simply debugging, but I’m including it for completeness sake.

Screenshot from 2016-04-08 09:25:43

At this point a test can be ran to ensure we are hitting the server as expected by clicking the Test button.

NOTE: If this doesn’t end in a success you may have some network issues to overcome. See my post on using an SSH Tunnel if you need to.

Screenshot from 2016-04-03 15:20:12

After a success click OK and then Finish the wizard. If you had troubles, please see my post for using an SSH tunnel.

Enable debugging for the project

With the server set up it is now possible to set up debugging for the Zend Studio project.

In the Preferences (Windows|Preferences) click on the Debug within the PHP node.

Screenshot from 2016-04-03 15:21:16

Though it is possible to specify the PHP Server globally from the resulting option screen I prefer to set up preferences for each project, since most of them are different in any way. So I click Configure Project Specific Settings… and am prompted to specify which project I desire to configure.

Screenshot from 2016-04-03 15:21:57

After selecting the appropriate project I can then appoint the server I just added above, and then specify the Base Path and ensure the Auto-generated Base URL is correct in the lower section.

Screenshot from 2016-04-03 15:22:26

After approving and closing the Preferences, we are ready to debug!!!

Test: If the following step doesn’t work it may be because the debugger on the server cannot find the IDE. In a browser check what ports the IDE is listening on by entering the following URL to hit Zend Studio’s built in web server.

Screenshot from 2016-04-08 09:48:52

If the debug_host doesn’t show an IP address reachable by the server then it may be necessary to manually specify the IP in Zend Studio by altering the server configuration we created previously.

If the IP address should be reachable by the server the issue may be in the configuration on the servers end, or perhaps a firewall or load balancer in between is limiting. Please see my post on how to get around this with an SSH tunnel.

Since I was using Zend Server in this example I have Z-Ray available, and while on a page I wished to debug I could simply click on the debug icon and select any of the debugging options.

Screenshot from 2016-04-03 15:24:13

This will cause Zend Debugger to contact Zend Studio for debugging, which in turn will ask the user if they wish to open the debugging perspective.

Screenshot from 2016-04-03 15:24:44

If Yes is selected the IDE is now ready to perform any debugging the user desires.

Screenshot from 2016-04-03 15:27:24

I hope this helps others. Happy debugging!!!

This post is one in a series on debugging. For others click below:

PHPStorm and debugging issue
Using an SSH tunnel to step debug through a firewall

PHPStorm and debugging IP issue

Recently I was helping someone troubleshoot an issue using PHPStorm and Zend Debugger. In this case Zend Studio was able to debug an application using Zend Debugger while PHPStorm was failing unless an SSH tunnel was used. The error received was:

Host ‘127.0.1.1’ is not allowed to open debug sessions – please configure zend_debugger.allow_hosts in the ini file.Failed to connect to host ‘127.0.0.1’, reason: ‘Connection refused’.

The person experiencing this issue was attempting to debug a site in a VirtualBox virtual machine from the host machine. Both the host machine and the virtual machine were running Ubuntu 14.04. At first glance I thought adding 127.0.1.1 to the allowed hosts would do it. But turns out it was more than that.

In this case we knew there was not a firewall blocking access, so it had to be networking.

To start things off I wanted to take a look at what PHPStorm was listening to, so I used the broadcast port 20080 to see this in a browser:

Screenshot from 2016-04-04 16:13:09

So it appears PHPStorm was attempting to use the IP addresses linked to the host systems ‘localhost’ and ‘hostname’, but not an IP address accessible via the network. This meant the server would never be able to send information back to the IDE without the use of an SSH tunnel, because it could not reach 127.0.1.1 or 127.0.0.1 of the host.

Unfortunately PHPStorm doesn’t provide a way to alter the listening IP addresses in the preferences, so we were left with either using an SSH tunnel to allow port forwarding of the listening port (10137) back to the host, or manually informing Zend Debugger where the IDE would be located.

Zend Debugger Tweak

By default Zend Debugger will automatically attempt to detect the IDE settings, as shown below:

Screenshot from 2016-04-04 16:23:04

However, this wasn’t working because PHPStorm was not reporting a usable IP address, so we needed to update the settings manually:

Screenshot from 2016-04-04 16:22:37

NOTE: Checking the box “Use browser’s IP Address” did not fix the issue. The IP address needed to be entered.

With this done, the server now knew where to reach the IDE for debugging sessions. One downside to this is if the host machines IP address changes, this setting will need to be updated.

This post is one in a series on debugging. For others click below:

Setting up step debugging in Zend Studio
Using an SSH tunnel to step debug through a firewall

Edit: Please head out to the PHPStorm ticket system and +1 this fix to make this a thing of the past. https://youtrack.jetbrains.com/issue/WI-7465