The Shiny Ubuntu 16.04 LTS + MySQL 5.7 and PHP 7 Upgrade Mess
Hi :)
Ubuntu 16.04 LTS Xenial Xerus was released some days ago, April 21, 2016. I replaced my laptop hard disk drive with a Solid State Drive (SSD), and installed Ubuntu 16.04 LTS on it. Hmm, well, I'll tell you more about the SSD later in another post, after I get more experiences in using my upgraded machine :)
For now, I'll just make some notes on the software-side, especially on the web development stuffs.

Ubuntu 16.04 LTS, Looks Really Nice With Arc Theme :)

Of course, I needed to resetup my local server that I use to develop my websites before uploading them to the webhost.
Ubuntu 16.04 LTS comes with MySQL 5.7 and PHP 7. They bring many changes, and some of them are.. well, honestly, troublesome.

MySQL Saga

MySQL 5.7 changed the security model, not allowing the root user to login without sudo, despite the password can still be blank. To keep things simple, I was used to login as root user without password in my local server's PHPMyAdmin (of course, it is different case with the online server that I use). So, then, I was forced to login with another user, and that's what I did, but the problem didn't end there.
This new user doesn't have the privilege to create a database!
Following the steps on Ask Ubuntu, I granted the necessary privileges to the user and is finally able to import my MySQL databases. However, if you think the problem ended there, you're wrong.

PHP Saga


What's that? A blank page.
Er, well, what's with that blank page? That's the problem, dude! My sites, that work normally on the server, resulted in a blank page when acceased via localhost!

It turned out that there are so many changes coming with this PHP version compared to the one I installed in Ubuntu 14.04 LTS and before. There are so many deprecated functions that I used for my website, mostly regarding connection with mySQL database, including:
  • ereg_replace
  • mysql_connect
  • mysql_query
  • mysql_real_escape string
and so on.

I have to replace ereg_replace with preg_replace, and those mysql_* functions with their mysqli_* counterparts, which are, honestly, adding more complexity to the codes.

I briefly considered to downgrade to PHP5 so that I don't have to go through all that trouble. I mean, hey, what's with the update that breaks so many things like this? Is it even sane? :/
And the webhost that I use gives choices on what version of PHP that I want to use for my site, so that'll work.

However, I declined that option. Sooner or later, the world will move on, and so do I. Better to use the new one earlier than having to be forced to change later by the service provider we use. So, I took that opportunity.

I updated the way my PHP files connect and interact with mySQL database with mysqli_* functions. I also changed the ereg_replace that I used to format some texts to preg_replace. And, well, then my localhost site is running nicely again :)

Checking where the problem is

Deprecating so many things that already worked fine is.. honestly, troublesome. It breaks so many things running on older versions of PHP.
But, well, at least I managed to update my codes quicker than I anticipated. The other good thing is that I learned to use php <filename>.php command from the Terminal to check where my PHP file got a problem. I think that's worth the trouble, since now my site is ready for the new PHP 7 :)
Oh, wait, as of the time this entry is posted, this version of upforward that's running on the online host is still using the old code, though :p
Comments (2)
07 May 2016, 14:02
Thanks! clarifying as I also fearlessly upgraded to 16.04 only find out these problems later.
15 May 2016, 23:38
@michael harings: Glad it helped! ^_^
Write a comment »

 < leave as it is

Notify me via e-mail for new comment