There are times when everything goes smoothly in the app you just developed on your local machine. But the moment you upload it online, boom! PHP errors you didn’t encounter offline.
Now in most cases of mine it was simply a matter of upgrading the php version of the server. Now I’m someone who frequently reinstalls OS on my desktop , so installing a web server like XAMPP is something I do regularly and I always use a version with the latest updates, which includes php version.
If you have cPanel there is an option where you choose the php version. And sometimes it doesn’t go well. Choosing the latest version sometimes “breaks” your website , and by this I mean your whole website gets an error 500.
Don’t panic! You can get it working again by using the old .htaccess version. By upgrading via cPanel , the server should make a backup of your previous .htaccess file. Just go in the root, and you’ll see one with the latest date change. Just rename that to .htaccess (rename the current one to something else) and voila ! It should work ! Well I hope it does for you, because it worked for me.
Now back to upgrading the php version of your server. As you’ve guessed by now, the problem lies in the .htaccess file. Now googling around I just added one particular line and it I got the recent version to work .
AddHandler application/x-httpd-php71 .php .php5
That’s it, nothing else. I ran a phpinfo() just to see if it worked and I got php version 7.1 .
Unfortunately setting up the server time didn’t work for me in the same file, so I created a main php file which I included a everywhere and inserted the following function
date_default_timezone_set('America/Paramaribo');
Now these don’t seem like much, but after writing thousand lines of code, it’s these little things that can keep you busy and lose a bunch of time , time you could’ve use programming or something else productive.
That’s my web programming tech tip for today.