Changing PHP Version On Vagrant


After nearly 24 hours of working on this issue I finally figure out how to change the running version of PHP from the WEB SERVER under VVV for my WordPress development environment.  I recall, at a WordPress conference last year, someone touting how easy it was to change PHP versions to test plugin and theme development on various deployment stacks.    Sure, if you happen to want to pull a whole new box image with just the right version of PHP along with all your other tools in place.

For me, I wanted to keep my vanilla Vagrant box with a single mapped directory intact.   I wanted the SSL certificates I created to remain as well, which was another day-long project.   The only thing I wanted to do was replace the default PHP 5.5 release with PHP 5.4.43 to match that of a client.  I’d also like to test with PHP 5.2 someday as that is the minimum supported version for WordPress.

It turns out that changing the PHP version at the command line is easy.   Making it take affect in nginx, the default web server for VVV, is a whole other story.  I found lots of resources on doing this “simple trick” but very few were current and almost ALL were missing information or provide cryptic installs such as “on Apache” (not the VVV default web server) or “on Debian” (no the VVV default distro).

The Summary

Install and use phpbrew to build the PHP flavor you are looking for.

Find your particular flavor of PHP under the vagrant user directory and get the path to the socket listener.

Modify the nginx configuration file to use the socket for your flavor of PHP.

Restart nginx.

Installing phpbrew

Install phpbrew either by going to the phpbrew site and following their instructions OR go to the Vagrant site , install Vagrant, and then clone the repo to a local directory.    After cloning the repo checkout the feature/phpbrew branch.   phpbrew will be installed and ready-to-run.

I chose the “install manually” option as I wanted to keep my Customfile and some tweaks to my config files that I already had in place on my current “non-repo based” Vagrant box.

Make sure you run the phpbrew init command, preferably as the default vagrant login NOT as root.  This will create a hidden .phpbrew directory under your user’s (vagrant) home directory (/home/vagrant).

Install Your PHP “Flavor”

Decide what version of PHP you want to run and install it with phpbrew.  This may take a little time.   When it is done  you should have some new directories under your /home/vagrant/.phpbrew/php folder for the version you installed.

You will want some default options as well.   Here is my command for PHP 5.4.43 with the default configuration, FPM support, MySQL support, and CLI support.

Find The Socket Listener

Under the ~/.phpbrew/php//etc directory you will find the configuration files for that version of PHP.    Search the files for the line that loads the socket listener.  The socket listener ends with .sock and is usually in a /run/ directory.     I use grep to search:

The part after the listen = that is returned is the patch to the PHP 5.4.43 socket listener for FPM.

Modify The nginx Config

I edited this directly on my guest box by logging in with vagrant ssh and restarted nginx.  The default config file is at /etc/nginx/nginx.conf

Look for the line that loads the current socket listener, usually in the /var/run directory and comment it out.  Put another line in that points to your specific PHP listener.   Here is my snippet pointing to my PHP 5.4.43 version:

The other option to make this more permanent is to edit the vagrant config files.  Got to the directory that contains your Vagrant environment, the place with the Vagrantfile, and go to the ./config/nginx-conf/ subdirectory.   Edit the nginx.conf file.     This is the file that will build the /etc/nginx.conf file whenever you provision your Vagrant box.    If you change this file you will want to run vagrant provision from your host.

Restart nginx

Again, I did this from the command line on my vagrant box after logging in with vagrant ssh.

Check Your Work

Go to to your web browser and check the phpinfo status.

By default this is found at http://vvv.dev on your host.

Click the phpinfo link.

vvv dev dashboard

vvv dev dashboard

Building A Streaming Music Service : Technology Components

Media File

A media file is the digital file format of the recording of a song.  The most common format today is MP3 which comes is various “flavors” that determine the quality of the audio.   MP3 is considered a “lossy” format which means it uses compression algorithms that can trim off pieces of the music data that it thinks the users will not hear.  FLAC is another common format that is considered lossless.  It uses compression algorithms that restore ALL of the original digital data as it was received.

The quality of any media file recording will depend on the original sound recording, the master recording, and how it was turned into a “digital master”.   Many variables impact the quality of the work including the type of equipment used in the studio and the quality of the digital signal processors (analog-to-digital / digital-to-analog converters).

Read More

Bitbucket Permission Denied / Conq

Hopefully this article will save at least one other person an hour of their life trying to figure out why they cannot clone a Bitbucket repository when using SSH.

My projects are broken into several teams, each with their own developer and administrator users.  Each team has a number of repositories that are being managed.  There is one common denominator; I have admin access to all repositories.   That means my Bitbucket user should have full read/write/admin privileges on all repos.    Yet no matter how many different keys I added to my Bitbucket user account it would not allow me to clone several repositories.

Read More

iPhone Versus Android : Christmas 2015 Update

I just replaced my Samsung Galaxy S5 with a new iPhone 6S Plus.    This was not an easy transition.   I started out in the smart phone world literally on day 1.    We had a contract to write an app for the very first iPhone and we stood in line to purchase a pair of them on the first day they were available.    Within 18 months Android was out and after fighting with that gen 1 iPhone more than I liked it was time to check out the competition.   I never looked back even when iPhones improved faster than Androids.    Even when Androids didn’t work with ANYTHING and nearly EVERYTHING, including my toaster oven, “talked to” and iPhone.
 
But things have changed.   My past two go-arounds with the top-of-the-line Android models have been nearly as frustrating as that first iPhone many years ago.  First with an HTC model whose power ports just stopped connecting unless you moved the usb cable “just right”, like playing a new form of Jenga…. ooops moved that a little too far and CRASH down came the entire tower of tech.   Then with the latest Galaxy S5 that would literally just do a factory reset in the middle of streaming a Slacker station on a walk down the beach.     After the 5th factory reset in 12 months with a brand-new phone that tested “nothing wrong” with a perfect battery, I’d had enough.
Not only was my phone forcing me to spend a solid 4 hours re-installing all my apps and security settings, it would take less than a month to run out of memory.  If I was taking hundreds of photos and videos I could understand, but it was always the apps.  Not a lot of apps, but every one was HUGE.  Maybe It was the unprecedented amount of pre-installed apps you cannot install without rooting the phone (and voiding the warranty ) and keystroke log files that they keep to send back to everyone that wants to buy your data.  Privacy be damned.
To finally push me over the edge, yet another update came out for my car that was “only for iPhone”.   Starbucks continues to have iPhone-only free music and apps.    My stereo has advanced features only for iPhone.   My TV is “best with Apple TV compatible devices”.   My thermostat.  My security system.  Everything has MORE features and the most recent tech ONLY if you are on iPhone.   Even the smart door locks I looked at are NEVER available on Android first and even if they support Android it is always a half-assed version of the “real product” built for iPhone.
One last factory reset and a looming 4 hours of loss productivity pushed me over the edge.
In just 24 hours, here are my first impressions of the iPhone experience on the latest 6S Plus versus the year-old Android Samsung Galaxy S5.

iPhone killing it over Android

Battery life.   Bigger brighter screen with more resolution.   More sensors built in.  A gazillion megapixel camera.  A faster CPU.   And it STILL gets at least 5x the real-world usage time of the Galaxy S5.   After a day of use where I used the phone AT LEAST as much as any day in the past week with the Android and I still have 80% batter life.   My S5 would have been on the charger TWICE since noon.
Screen resolution.  A full 1920×1080 makes a HUGE different in legibility.   Also, Apple has always just had screens that “pop”.  They are easier to read no matter what the resolution is compared to an Android.  Not sure what tech magic this is but it makes a big difference to my eye.
Camera resolution.   I’m not sure the official spec but I now the video shoots true 4k at 30fps and full HD but the still images.  Wow.  This thing blows away the S5.  It has to be at least 3x the resolution if not more.
Ease-of-setup.   They literally activated the sim card and ported the account.  Nearly EVERYTHING was imported properly in terms of contacts, email, etc.    The few apps I had to re-install for security reasons worked perfectly.  EXCEPT a couple of Google-specific apps.  Go figure.    Funny thing is restoring an Android backup to the SAME PHONE after any one of the 5 factory resets was a 4-hour operation.    To go to a whole new phone OS took all of 15 minutes.
Performance.  This phone is WAY faster.   Literally the first words out of the Verizon rep when picking up the S5 was “your phone is so laggy”.  Yup.   Does that within 2 days of being setup.    Even after a factory reset and comparing them side-by-side the iPhone blows away the S5 in terms of app switching, downloads, app installs, and … well… just about everything.  Hell, the S5 takes 4-5 seconds to start up the camera app and snap the photo  (the new faster Google Camera app is so buggy it hangs 80% of the time but in the 20% of the time it works still takes 3 seconds to start).   The iPhone 6S Plus…  it is instantaneous.   The 6S is so fast in bringing up the camera tt is even faster than my actual pocket camera that has to open the lens cover (about 1 second or less). And in case 1/1000th of a second isn’t fast enough this camera uses some vodoo black magic to capture a second or two of photos BEFORE you clicked the take-photo button. What!?!?
Intangible “feel”.   Don’t get me wrong, the Galaxy S5 feels solid.   However the feel of quality when holding the phone is just “better”.  More solid.   It is hard to quantify by the 6S Plus feels like a solid piece of milled aluminum and the S5 feels like a piece of solid milled aluminum with some plastic tacked on that should really be there.   
The Other Stuff.  The “just touch me” fingerprint scanner blows away the S5 “swipe me and I might recognize it but likely won’t” scanner.   There are FAR MORE quality accessories both from Apple and 3rd parties for the iPhones 6S; which is amazing as it has been out for 60 days versus 18 months.   Compatibility with 3rd party devices; again EVERYTHING works with and usually works-better-with the iPhone which is NOT true of the leading Android Galaxy S5.  No extra pre-installed crap like the dozen-plus bloated apps Samsung forces you to have (and can never delete BTW, without voiding the warranty) so that Samsung can lower their price into your hands.
 

Android beats iPhone

The Back Button.   Seriously, why doesn’t Apple steal this idea.   It saves SOOOO much time over having to scroll to the top of an app just to back up.    I didn’t realize it but that is a HUGE time saver.
Integration with Google services.  We all know this is on purpose and it all at the hands of Google.    However getting all of my primary business connectivity via email, hangouts and every-other-app is the ONLY thing that was not a “oh, it just configures itself” on the iPhone.  On android it is kind of a pain especially if you have 2-factor authentication but on iPhone it seems to NEVER work until literally the 4th setup attempt (I swear Google has a counter that has to be reached before it will work).
App-to-app integration.   Some third party apps, like LastPass for example, work far better with other apps on Android.  On Apple they have put everything  under such tight controls that apps from different vendors don’t tend to like to talk to each other.
Speaker Quality.   The external speaker, the one you use to watch videos or to to a “speaker call” is absolutely ridiculous on the iPhone.  And I mean ridiculous in the “what fucktard came up with this” type of ridiculous not in a “that party was RIDICULOUS” as in an epic sort of way.     That iPhone speaker is placed perfectly so that if you don’t contort your hand into some fucked-up “I’m the direct offspring of quasimodo” sort of grip you will effectively mute the sound entirely.    Yeah, I get it, the sound is great if you lie it down on a desk.  But for those of you that actually HOLD your phone… it is completely freakin’ useless.  How did Apple miss this mark so badly?

Which Is Better?

So which do I like better at the moment? Well, not having a ubiquitous back-button is really annoying. It is amazing how many screen presses that saves you. Also the speaker placement on a $900 phone should NOT be in a place that completely MUTES the phone if you don’t hold it just right. Really? Yup, really.
 
That said, the most important things to me are battery life, camera and video quality, not having to delete all my photos just to update an app, and a phone that leverages ALL the features of my tech life (car, home security, home sound systems, and all my gadgets). Despite the ridiculous speaker placement and lack of a back button, the iPhone is already killing it in the 4 primary things I am looking for.
Luckily there are nearly one-bazillion third party accessories out there for the iPhone 6S Plus just 30 days after launch that I can certainly find a stand that lets me watch videos AND hear them at the same time without having to hold the phone.
Now if this thing doesn’t factory reset within the first 60 days I think I’ve found a new favorite tech toy.
%d bloggers like this: