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;
}

}
“`

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.

Rethinking the justCheckers Website

After listening to my backlog of FLOSS Weekly shows, I’ve been thinking about my involvement with my own project.  Naturally I want it to succeed.  But I also want to use it as a portfolio of my work.  On one hand, I’d like to hack everything together by myself.  On the other hand, I simply don’t have the time or inclination to do everything.  Especially if I think about it… my skills in PHP might not be as interesting as showcasing my work in developing justCheckers and working as a team lead.  So I’m think about setting up Drupal, and maybe do some additional integration work…  I’m just not that sure that anyone really cares about my XHTML/PHP/web development prowess, especially with some many powerful tools that are around.

I’ll probably do that… set up Drupal, integrate a justCheckers look and feel into it (showcasing my web designer side), import all the data, setup a team again and move the damn project forward.

New Site for justCheckers

I’m setting up a new site for the justCheckers project.  The only real good reason for my working at all on this project, is simply to build a portfolio.  As a software developer, I want to show to others that I can code.  And that my code is clean, elegant and professional.  I also want to show that I can write my own web applications.  So I am writing the justCheckers website as a PHP, MySQL DB enabled application.  All using proper XHTML, CSS and a touch of AJAX.  The site is a work in progress.  I’m not planning to build an entire flexible CMS, rather I plan on building a custom site.

Crazy Busy

I’m going to have to keep these next upcoming posts short.  I am a bit overwhelmed at the moment, with the sheer amount of things going on at the same time.  I still want to try to keep going forward on the projects already in progress.  But I will not add anything new to my plate for the next few weeks.  I’m seriously planning a trip to Europe this year.  Planning this trip will take quite some effort.  Still a short update is in order.

I got meet up my university friend Rob yesterday.  Have not talked to him in ages.  I did spend a long time with him.  But it was great to talk to him again, and I needed someone in a similar position to my own to bounce ideas off of.

I started to compile some notes for my novel.  I wrote down most of the background of the novel.  Now I plan on completing my notes and sketching out the plot.  Then the serious work writing can begin.  As for programming, I’m working on a PHP powered website for justCheckers.  Also I am slowly reading through a book on coding C++ and Qt, along with a silly application I plan on writing to learn the Qt framework.

Kicking Tires

This week, I’ve started working on my delayed projects again.  I feel exhausted from the week.  But I also can not wait to play around with my projects.

Learning Qt

I’ve always admired the KDE and Qt developers.  They make some of the most innovative and interesting technology in the consumer-desktop-mobile land.  I’ve decided to pick up learning Qt and C++.  So far I’ve read the beginning of C++ GUI Programming with Qt 4 (1st ed).  I need to play around with C++, which I plan on doing it while using Qt Creator.  One of my first major Qt experiments might be getting the TEA text editor working on my Nokia 5800 XpressMusic.  I know that Nokia just released the tech preview  of Qt 4 for S60 devices.  But I’ll give it a shot.  Hopefully the GUI will port over nicely.

Completing justCheckers

Yes, the project that I left for dead still lives.  I want to work on it, as portfolio material.  I first plan on building a website in PHP (or maybe JSP?) that renders beautiful CSS and XHTML.  And then I need to give the project much love.  But I owe it to myself to finish this application.  I won’t build any crazy game servers.  But I want to make something totally configurable and fun.  And in the process I want to create something that proves that I am a strong Java developer.

Writing A Collection of Shards

I am going back to writing.  Unfortunately I need to start almost from scratch, since many of my written sections simply will not work.  The ideas are there.  I just need to get them down on paper.

Driving License

This one is the ultimate in the tire kicking sense.  I plan on getting my driver’s license really soon.  Aside from parking, I feel comfortable driving.  Once I figure out all this parking stuff, then I’ll be ready.  I’m exciting since this will give me a lot more mobility and flexiblity.  I’ll be able to solve a lot of problems and have even more time to do things in the day.  And I’ll be able to sleep and live in normal time periods.

The Open Source Gamer Looking for Work

I am currently looking for work, so if anyone is interested in a software developer or software engineer position please let me know. I have experience from university (finished my B.Sc. in Computer Science at the University of Toronto) and from my open source projects in:

  • Java development.
  • PHP and JSP scripting.
  • Database (MySQL and SQL Server) programming.
  • Technical, computer manual writing.
  • Graphics: mostly Java AWT and SDL.
  • Website development (XHTML, CSS and Javascript).

I am looking something that I can either do at home or commute to in Brampton, Mississauga or Toronto. So if anyone is interested please send me an email at:

dorian dot pula at gmail dot com.

Thanks in advance for all offers.

Lurking in the Shadows…

Well its a new year, but I have been lurking mostly in the shadows. Nothing much happening, other than the start of classes. Life is the same as always. Chaotic. And my house is divided up into territories (rooms) held various factions (members). 😉 So far, I think the year is alright. Too early to tell naturally. But I hope that this year will be the year I really break out into the open.

Having said that, I started working intensely on a the new news and gallery pages for my two projects, justCheckers and Insomia. Seeing that I could join my work together in a simple cohesive whole, and the potential that it might be useful for more people than just me; I started a new project. This project, Simple Site, plans to create a simple, bare bones content management engine that will allow for developers to add news, and image gallery functionality into their sites. This engine will be so simple, that it will easily be modded into any custom website that uses PHP and MySQL. Now all I need to see if SourceForge will accept my proposal.

Well I am off, to play a short round of VegaStrike and work on Datasphere work.