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.

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

Mirror mobile device screen to your computer

I needed to perform a demo of a tool where I would utilize my mobile device (phone) to perform an action, and it caused a reaction on my laptop.  However, part of the “WOW” factor is to mirror my mobile device screen onto my laptop so the viewer can see both the mobile device and the web browser.

Thanks to Apple’s AirPlay this is relatively easy for the iPhone with the purchase of 3rd part software like Air Squirrels Reflector, but I don’t have an iPhone. (I can never figure out how to switch between apps, or how to go back if the app developer didn’t include a back button in the app.  But I digress.)  Instead I have an Android device, which has a much larger user base, and I really didn’t want to switch.  Unfortunately nobody has created a 3rd party application that utilizes the Cast Screen functionality of Android in the same manner as the AirPlay.

In searching I found many solutions that required the user to “root” their mobile device.  This really wasn’t an option for me.  I have a Google Nexus device, so I’m not really held back by mobile vendor limitations, lock downs, or pre-installed software.  No need to “root” my device.  I’ve rooted/unlocked other mobile devices in the past, and since I’m not a mobile developer, I feel no need to tinker with what works for me.

I did manage to find a couple other solutions (one with the help of my co-workers) that did work without altering my device software, or installing applications on my laptop.  Well, that is not entirely true.  Both of the solutions I’m about to share did require the Java runtime environment to be installed, but I consider that a mute point since most computers these days already have it installed for one reason or another. (Most developer IDE’s already require it, so I already had it.)

Step 1 – Ensure you have JRE

As I said, for this to work you will need to have the Java Runtime Environment of some sort installed on your system.  If you don’t already have the JRE installed you can do it at http://java.com.

Step 2 – Connect with USB

You must connect your Android device to your PC via USB connection for this to work.  As of this writing I have not found a way to make this wireless.

Step 3 – Enable Developer Mode

By default Android devices do not come with Developer Mode enabled.  This mode is needed so we can take advantage of debugging via USB tether.

On Android devices prior to 4.2 you could set USB Debugging from the settings…easy-peasy.

To enable this on Android 4.2+ go into Settings->AboutPhone and tap the Build Number 7 times.  The device will inform you that Developer Mode is now enabled.  Click back to hit the previous screen and you will now see Developer Options available.  Check the box for USB Debugging and you’re done.

Step 4 – Download the Android developer tools

For simplicity sake I only downloaded the standalone Android SDK Tools Only. (I had no use for the Studio.) I did this at the URL http://developer.android.com/sdk/index.html#Other, then unzipped the file to a place of my liking.

After making the file ‘/tools/android’ executable I ran it on the system.  This opens the Android SDK Manager window.  The purpose for this is to download and install the needed packages to allow us to “develop” Android apps.  I didn’t change a thing and simply clicked the button that said “Install n packages”. (Note: n will be some sort of number.)

It took awhile for the manager to do the update/download, but after it was completed I simply closed it.  This would have downloaded a bunch of things, but the most important for us is ‘/platform-tools/adb’ which is required to mirror our device screen to the PC. (Make sure this file is executable as well.)

Step 5 – Add locations to the PATH

For this screen sharing to work you will need to add two folders of the Android SDK to your PATH: ‘/platform-tools’ and ‘/tools’.  I did this by editing my .bashrc file as follows:

export PATH=$PATH:/home/aculp/android-sdk-linux/platform-tools:/home/aculp/android-sdk-linux/tools

Step 6 – Download Apps

There are two possible apps to use to do this:

Both carry the same sorts of functionality, however Droid @ Screen is a bit more mature and makes additional options a little easier.  One thing I didn’t like was the need to have an extra window open for the settings.  Due to my being a fan of simplicity I have been using Android-Screen-Monitor.

Both apps are a simple matter of executing the jar file using java and they just work.

Step 7 – Launch it!

Now it is simply a matter of launching either the Android-Screen-Monitor or [email protected] application. I did this via CLI like so:

$ java -jar asm.jar

NOTE: This command assumes we changed directory to where we downloaded the Android-Screen-Monitor jar file.

Conclusion

If you have questions or comments please post them.  I will return to this post and tweak it a bit more to become really easy to use, but for now this is mostly what I did.

Clone Hard Drive to External USB Drive via CLI

Thumb and USB drives

No matter what OS you’re cloning, using “dd” via command line will still work.  I personally tested while cloning a 1TB Ubuntu hard drive to a fancy new 1TB SSD.

Backstory: I purchased a new Dell 7737 laptop with a 1TB hybrid drive, which turned out to be slower than watching paint dry compared to the old SSD I’d been using for a few years.  Otherwise it is a kickass laptop.  So I purchased a 1TB SSD after finding they are roughly 50 cents per GB these days…very affordable.

First I put the new SSD into USB caddy I had laying around for backup purposes.

Next I created a bootable USB stick with an Ubuntu ISO image following the instructions at:

Windows = http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-windows
Ubuntu = http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-ubuntu
MAC = http://www.ubuntu.com/download/desktop/create-a-usb-stick-on-mac-osx

With the USB stick created I booted the system to Ubuntu using the USB LiveCD disk image.  It may require a BIOS change to enable the PC/Laptop to boot from USB device.  Doing this will not make any changes to your current hard drive as long as “Install Ubuntu” is not chosen.

Once booted up I was able to use Gparted, which is a standard app on the LiveCD, to create a new partition table on the new drive in the external USB caddy.

I then used fdisk via command line to find all disks and gain their identifiers needed.

fdisk -l

With the new partition and the identifier of the USB drive I was now ready to initiate the copy.  I used the following command to do that:

dd if=/dev/sdc of=/dev/sdb mb=8M && sync

NOTE: ‘if’ = read from and ‘of’ = write to.

It takes a very long time for this to finish up, especially with larger drives, but the end result was a working drive with my data on it.

After completion I simply switched out the SSD from the caddy with the internal HD in the laptop and all worked well.

Good luck!