Lance Cleveland

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

Lessons From My First RV Trip

I just spent a week doing my annual father/son summer getaway.   Our crazy but fun RV trip is over. Back to reality; back to work. Before I forget, I want to share some things I learned along the way:

RV sales and rental companies should be required to follow concussion protocols similar to the NFL. Nicolas & I each hit our heads at least as many times as a typical linebacker during a full season. I’m still not sure what year it is or how many fingers you’re holding up.

Prius drivers are slow. I’m pretty sure they don’t even realize they are in a car. My guess is they meant to get on their bicycle and got in the Prius by accident. I’ve driven most of the East Coast TWICE in the past 5 weeks. I have lots of empirical data to back this up.

Google Maps Navigation does NOT base the estimated travel time on the posted speed limit and traffic conditions. As far as I can tell it is the average speed of traffic times your gross vehicle weight divided by 3,501.7. Since nobody drives the speed limit these days and EVERYBODY drives faster than the speed limit (besides Prius owners) you will be much later than Google says unless you are doing 90 in a 70. Also a loaded RV is slightly more than 3,501.7 pounds so there’s that. Case in point, doing 72 in a 65 – Google kept adding 1 minute to our arrival time every 7.25 minutes of driving time. Do the math.

Chevy cruise control blows. Set cruise control for 70. Start up a hill, speed drops to 62. Amnesia Cruise Control mode wakes up and RV downshifts to overdrive and speeds up to 78 using 37 gallons of gas in the process. Almost rear-end a semi , turn off cruise control and re-engage at 70.

You can jump a Prius in an RV. Remember that precision cruise control system? It is particularly good at getting and RV up to Evil Knievel Jump-The-Gorge speeds any time you approach an overpass hill. Just as you get partway up the overpass it will downshift to overdrive and floor it. It peaks at something close to 98 MPH, I can’t say for certain as that is the point I close my eyes. This sends the RV airborne at the crest of the hill. During one of the numerous daredevil stunts on the 8.5 , I mean 10.75, hour drive home I opened my eyes and the light blue all-electric Prius we were about to take out was somehow behind us. I’m pretty sure we jumped it. Either that or we just ran it over and the RV spat it out the backside like a used burrito.

There are many more things I learned from being an “RVer” this past week; DC public transportation is unreliable, RV Park WiFi is connected to dial-up modems, don’t drink the water, do see the Smithsonian museums, DC people are nicer than they look, and your congressmen and senators really ARE as lazy as you think.

In short, if you’ve never done the RV experience I highly recommend it. It may not be the most enjoyable or relaxing trip you take but it will certainly be memorable; other than those things you forget from short-term amnesia caused by your 12th concussion of the week.

Is ASCAP Lacking Web Technology Expertise?

Music streaming and licensing.  In case you’ve missed it , licensing music is a HUGE deal these days.  It is a billion-dollar industry and is growing every day.   It will be one of the largest entertainment industry segments in the next few years outside of video games and movies.    Yet the top organization that are responsible for tracking streaming media plays and compensating artists are woefully behind the times when it comes to technology.     They invest heavily in marketing and recruiting members but neglect what should be a core competency of their business in today’s high-tech world.

Just how bad are these companies at technology?   The hints are everywhere.    Licensing agreements refer to archaic terminology that references an age when computers were only found in college basements.   Corporate websites don’t work and are poorly maintained.   Nearly everywhere you look you can see the hints of outdated corporations that changed just enough to give the appearance they are keeping up with the times but behind-the-scenes are likely listening to 8-track tapes or possibly wax cylinders while the rest of the world streams digital media to their iPhone.
Read More

Now You Know Everything About Music Publishing… – Digital Music News

An article that does a great job explaining the intricacies of music licensing, copyright, royalties, and publishing. It is a complex system with a lot of moving parts. IMO this complexity makes it difficult for artists to control their own product. In turn this has created and industry where the source of the product , the artists, are easily taken advantage of. Everyone done the distribution chain has their hand out, leaving nothing for the artists.

http://www.digitalmusicnews.com/2014/02/28/understandpublishing/

Unpaid Music Artists – Maybe It’s Time To Blame The Streaming Companies

Songwriters, publishers, performers, and a myriad of others that create the music that defines moments in our lives, serves as the background for dinner dates, house parties, and corporate conventions are earning less money than ever before.   While there are many factors to consider one of the most notable issues is the lack of compensation from streaming services.   Sure, radio has been notorious for their lobbying group that has kept them exempt from paying their fair share of royalties to recording artists, but streaming media has taken it to a whole new level.
Read More

%d bloggers like this: