Avoiding Blank PHP Responses after upgrading to Ubuntu 16.04, and php7.0-fpm

Earlier this week I finally made the plunge to upgrade my VPS to Ubuntu 16.04. With a minor hiccup surrounding supervisord (which I probably can avoid if I go the systemd route) not being enabled at boot, the upgrade was simple for both my WSGI and Node webapps.

I can not say the same thing about my WordPress/PHP installations. (Installations that I hope to transition off to Rookeries once that software becomes more stable.) It took me a few hours to track down and resolve the problems. Hence I am posting this article, to hopefully save someone else’s time when they do the same upgrade.

Upgrading to PHP 7.0

Ubuntu 16.04 makes the switch away from PHP 5 to PHP 7. So I had to switch to php7.0, php7.0-fpm, and php7.0-mysql from their PHP 5 equivalents. The location of the running UNIX socket has changed from /var/run/php5-fpm.sock to /var/run/php/php7.0-fpm.sock, as did the PID files.

Updating the PHP-FPM configuration

Running WordPress using FPM (Fast Process Manager) and NGINX, requires turning off the path translation in php.ini file. This can be done by uncommenting the line cgi.fix_pathinfo=0 found in the configuration file /etc/php/7.0/fpm/php.ini. Again these files have moved from the old location. After you’ve done this remember to restart the FPM service using the new systemd utilities: sudo systemctl restart php7.0-fpm.

Updating the NGINX configuration and Solving the Blank Response

This is the tricky part. After updating my NGINX configurations to the new UNIX socket path, and restarting NGINX, I found that I got blank PHP responses. Everything else worked, expect that any PHP page would not render. And not render by not rendering any content in the body of the responses. That led me down a few rabbit holes, and researching how to re-architecture my setup using Docker. Eventually I stumbled across a blog entry with the solution to the blank PHP response issue.

In a nutshell, with the NGINX upgrade one of the parameters needed for FastCGI went missing namely the fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; bit. Oddly this parameter appears in /etc/nginx/fastcgi.conf and not the /etc/nginx/fastcgi_params file that I normally include in my NGINX configs. Anyways after adding this line and restarting NGINX using sudo systemctl restart nginx everything worked correctly. Below I’ve included a sample NGINX configuration that should work.

Sample NGINX Configuration /etc/nginx/site-enabled/example-site.conf

“`
server {
server_name .example-site.com;
index index.php;
root /srv/www/location_of_wordpress_install;
listen 80;

access_log      /var/logs/nginx/site-access.log;
error_log       /var/logs/nginx/site-error.log info;

location / {
    try_files       $uri $uri/ /index.php$args;
}

location ~ \.php$ {                        
    fastcgi_split_path_info     ^(.+\.php)(/.+)$;
    fastcgi_pass    unix:/var/run/php/php7.0-fpm.sock;
    fastcgi_index   index.php;
    fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
    include         fastcgi_params;
}

location ~* \.(js|css|png|jpg|jpeg|gof|ico)$ {
    expires         max;
    log_not_found   off;
}

}
“`

A Clean Future

The future is white?

Bob, the future has been white since the 60’s.

Autotainment, Big Ideas

The future has been white for a long time, thanks to the likes of Stanley Kubrick and the folks at Apple.  Thats why the theme I’m crafting for this website, is called “Clean Future”.  I took the “Open Sourcerer” theme by Alan Lord, and modifying it until it suits my tastes.  I’m still debating whether it will look like a glass UI or hand-drawn doodles.  Maybe I’ll go all out and create a full AJAX powered UI.  We’ll see.  I’m sure it will remain white and light grey.  And I’ll take it as far as I feel it makes sense to do so.  So if anyone has any suggestions feel free to leave them in the comments below.  I’ll make the modified theme available once I finish working on it.

The Joys of Seamless Upgrades

Upgrades often is a naughty word in programming and system administration.  When a system admin or programmer starts an upgrade, often it is with clenched teeth and an expectation something will break, explode or spontaneously combust.  So congrats to the WordPress guys for releasing another seamless, non-breaking, and easy to do upgrade.  And yes this blog now runs on the latest greatest WordPress 2.8.6.

Now if only upgrading my Drupal sites could be as simple and trivial.

Drupal Dreams

I love my WordPress powered blog.  For a blogging site, WordPress is the way to go.  However there are site that require me to step beyond the paradigms of a blog.

Back in the day, I used to hardcode all my sites using XHTML & PHP.  I’d make them elegant, minimalistic and W3C compliant.  I also wasted a good deal of time doing so.  So now…  when I need to set up a site, I reach for Drupal.  Now thats a fun application to work with.  By no means is Drupal “simple”.  It is a freaking CMS for crying out loud.  Simple and CMS don’t go together.  And it does have its weaknesses.  Getting an image gallery set up in Drupal 6 is non-trivial.  But once you know where things are and how the components work, then you are all set.

Upgraded to WordPress 2.8

I am continually amazed by the ease of working with WordPress.  Not only do the themes and plugins just work, so does everything else.  I upgraded my WordPress install to the latest and greatest 2.8 .  Simple, clean and issue-less upgrade.  This is how technology should work.  Get out of the way and perform the tasks the user needs to do.  And perform the tasks quickly, efficiently and perfectly everytime all the time.

In addition to that, I can proudly say that less than 20% of the older blog entries remain “Uncategorized”.  I plan on tagging, categorizing and editing the remaining entries.  With any luck, I have this blog configured perfectly before my upcoming birthday.  Hurrah!

Looking Forward, Looking Back

I’ve blogging for a while now.  This particular site and setup doesn’t suggest that I’ve been blogging since 2005.  Of course nowadays, I blog more often than I did then.  But the fact remains.  I noticed this because when I imported my old Blogger blog to WordPress, I did a messy job of importing my posts.  Most of the tags and categories were messed up.  So every so often I go into my mass of uncategorized posts, tagging, spellchecking and updating as I go along.

Looking back, I blogged about my life in the context of a university student.  My struggles and triumphs as I dealt with university, computing, stress, writing, love and growing up.  Some things changed since those times, some remained the same.  I still enjoy blogging for all the same reasons as before.  Back then I would post when inspired.  Today I have to inspire and compell myself to keep posting daily entries, that are interesting, compelling, clear and worth reading.  Still it has been a worthwhile journey, one that I plan to continue well into the foreseeable future.

Looking forward, I am trying to bring my blogging into the next level.  Aestetically, I have set up the theme for the site in a manner that I like.  To top of the site, I created and added a favicon yesterday.  Also I continue with my re-organization of old posts.  I have some 110 post to clean up.  So about 65% of the posts are done.  Just a few more to go.

A Quest for Easy Multiblog Setup

One of the downside of sporting the ‘Y’ chromosone, is the tendency to setup new kit without reading instructions.  In my case a similar thing happened with my sites.  I bought a domain and hosting.  Then I installed Drupal hearing all the wonderful things I heard about Drupal. What I didn’t do was research to find out installing Drupal on GoDaddy could be problematic.  And that Drupal is complicated to setup exactly how you want to.  Also it turns out that Drupal is a pain to maintain.  At least  for me it seems that way.

Maybe the problem is because I am writer.  As a writer I tend to view in the lens of literature.  World history becomes a story, the Internet looks awfully like a multimedia capable library and all my websites morph into glorified blogs.  I just can’t wrap my head around on WHY I actually need a CMS.  I fought around with Drupal to get to look not half arsed.  And then I installed WordPress for my blog and everything… just… worked!   Out of the box.  No questions asked.  No fiddling around with .htaccess files.  No monkeying around for modules just to do something useful.

Now I plan on transitioning my stealth project sites to WordPress.  However I don’t want to handle multiple installations.  A separate installation for my own personal blog is fine.  But not for a separate installation for each project.  Especially since all of my self-hosted projects will actually stem from one central project/system.  I looked at WordPress MU but it looks too complicated to setup and maintain.  I’m trying to avoid hacks if possible.  But the WP Hive module/plugin looks promising.  I’ll keep you updated on how things progress.

Notes: Excuse if some of my thoughts seem cryptic.  Those in the know will understand why I can’t speak plainly about my upcoming projects.  Those who don’t know will find out later, once I’m ready to announce my ideas to the rest of the world.  And dear GoDaddy admins, fear not.  I am not going to start a massive blog network on this hosted space.  I just need a single tidy installation to run a few very related websites with different domains.  So please don’t swing Thor’s ban hammer at my account. 🙂

Blogging Update

As you may have noticed, I am back to blogging on a regular schedule.  In fact this past week, I got a full five workdays all covered.  And was no easy task.  Now I’ll be the first to admit that not all of my blogs are actually written on a daily basis.  Rather I am liking WordPress’ option of scheduling blogs.  So now I get to make a buffer of the blogs I’d to publish, and I can keep up with regular blogging even if I am not.  That said, if some interesting timely news breaks, I try to make sure I get it out right away.

Still even with the options of scheduling blogs, the amount of writing takes its toll.  Currently I am on hiatus from my novel.  But that is simply because my life is always busy in general.  I hope to keep this regularity up.  And I plan also on more regular updates to my writing and my other projects.

Also I’ve played around with the theme and static content of this blog.  I think I like the current setup and I’ll keep it around for a while.

Moving In…

I migrated my blog to its new home here a few days ago.  Already I feel a lot more comfortable than I ever did in Blogger.  It feels like a moved from an apartment to a single family detached house.  And yes I am liking it.

Like an new house owner, I am now in the getting settled in and “painting” mode.  I’m experimenting with different professionally made themes.  I’ll probably end up making my own sometime in the future.  I cleaned out the glob of categories created, when I imported my data.  So now I have a bunch of posts that I need to retag and re-categorize.  I’ll work on that part slowly.  I plan on putting up some my articles and setting up a gallery sometime in the future too.  This is quite cool, and I am glad that all I needed to do is buying hosting in GoDaddy, set up a few options, install WordPress as a Hosted App and import my Blogger content.  So painless and honestly a lot more fun then I thought it would be.  Now if I can figure out this Drupal thing, my hosted web life would be total awesomeness.