Programming

How to Install PHP 7 on CentOS 6

Previously i posted about upgrading PHP 5.3 to PHP 5.6 on CentOS 6.
If you want to install / upgrade it to PHP 7, here’s how:

1. Make sure to remove older version of PHP
yum remove php-common

2. Add EPEL and Remi repository
yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm

3. Install yum-utils
yum install yum-utils

4. Enable Remi repository
yum-config-manager --enable remi-php72

5. Now install PHP 7
yum install php php-xml php-mcrypt php-cli php-gd php-curl php-mysql php-ldap php-zip php-fileinfo

6. When it’s done, restart your web server (apache or nginx)

7. Check your PHP version
php -v

Hope it helps.

 

 

Programming

How to reset MySQL 5.7 root password on Linux

I was having problem with MySQL root password after a fresh installation on CentOS 6. I cannot login to mysql as i didn’t know what was the default password for root. The installation didn’t prompt me to enter the password for root user.

So if you have a problem like me, or you have forgotten your root password, here’s how to reset it.

1. Shutdown the MySQL
service mysqld stop

2. Start mysql in safe mode
mysqld_safe --skip-grant-tables

Keep this process running, and don’t close this terminal

3. Open new terminal

4. Login to MySQL as root, and without password
mysql -u root

5. Change to database mysql
use mysql;

6. Now update the password for root user
update user set authentication_string=PASSWORD('YOUR-NEW-PASSWORD-HERE'), password_expired = 'N' where user='root';

notes: In MySQL 5.7, the `password` field was removed, now the field name is `authentication_string`.

7. Don’t forget to flush it
FLUSH PRIVILEGES;

8. Exit
exit;

9. Back to terminal 1, and stop the process (or close it). Then start the MySQL
service mysqld start

10. Now you can login to MySQL with your new password
mysql -u root -pYOUR-NEW-PASSWORD-HERE

Hope it helps.

 

 

Programming

How to Upgrade PHP 5.3 to PHP 5.6 on CentOS 6

Follow this post to install PHP 7 to your CentOS 6

Nowadays, to keep up up-to-date with the latest PHP technology, you need at least PHP version 5.6 installed on your server.
But for CentOS 6 users, PHP 5.3.3 is the latest version of PHP available through the official CentOS package repository.

To update your PHP version to version 5.6, follow these steps:

  1. Install repository
    rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm
  2. Remove older PHP version
    yum remove php-common
  3. Install PHP 5.6
    yum install php56w php56w-mysql php56w-common php56w-pdo php56w-opcache
  4. Restart Apache
    service httpd restart
  5. Check PHP version
    php --version
    You will get something like:

    PHP 5.6.32 (cli) (built: Oct 29 2017 19:00:01)
    Copyright (c) 1997-2016 The PHP Group
    Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies

Congratulation, your PHP is now upgraded to version 5.6!

 

 

Programming

Convert PHP object to an array recursively

In PHP, you can easily convert an object to an array by typecasting it.

$array = (array) $object;

But if you have multi-dimensional / nested objects, this will only converts the top level of the object. So instead of looping through the object and typecasting it, just use this single line code:

$array = json_decode(json_encode($object), true);

And to convert an array to an object recursively:

$object = json_decode(json_encode($array, JSON_FORCE_OBJECT), false);

note: This only works if the properties of the object you are trying to convert are declared as public

anything

Offline Mode on Spotify Linux

Unlike other desktop version, Spotify Linux version doesn’t have Menu to toggle to offline mode (at least until this post written).

But if you use 1.0.47 or later, you should be able to toggle offline mode by pressing CTRL+SHIFT+O.
Make sure you already download all of the songs on your playlist.

anything

Deleting Some Posts

A few days ago Google sent me email, notifying me that they have disabled my Google Adsense ad serving on this website. They said my website is not currently in compliance with their AdSense program policies, which is Hacking / Cracking content.

I can’t understand, i have NO hacking / cracking content on this site. I only posted something related to Linux or Programming, and sometimes any jokes or simple articles, but NOT hacking or cracking.
I already run this website since 2006. Have no posting since 2010, and my last post is last month about Olympic 2012 Youtube channel.
Then suddenly on August 15th, Google sent me email that i have hacking / cracking content, When my unpaid earnings reached $93.58!

How’s that possible?
If i have a hacking content, why they email me now? why not alert me on 2010 after my last post? or months before when i posted many articles. Or maybe posting their own Youtube channel is prohibited?? and they called it a hacking??

I already sent an appeal request regarding this issue, and asked them to tell me which of my post contain any hacking / cracking content. But they replied that my site is still in violation, without describing any further detail which one!

So, to resolve this i deleted many of my posts which has the lowest page view, and leave the highest rated posts.

If Google still think that i still have a violation content, well.. i don’t have any clue, maybe i’ll delete my Adsense account, and never use it again!

Tech-News

Age of Empire II color issue on Windows 7

There’s a color issue with Age of Empires 2 on Windows 7. You will get a corrupted color in game. Its not a driver issue or some directx compatibility. I think its just because of the Aero theme’s poor handling of colors.

So how to fix it? simply..

  1. Change to Windows Classic Theme
  2. Open the resolution changer window (Right click on your desktop, and select “Change Resolution”)
  3. Run Age of Empire game.

Now the color problem has gone.

Sounds silly?? nope.. IT WORKS!
Believe me, it really works..