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.

 

 

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.

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..

Tech-News

Create Permanent Static Route with Two Lan Card

I want to create routing for my two Lan Card. First Lan Card (eth0) for Internet access, and second Lan Card (eth1) for my Intranet. So when i access internet, it will route to my eth0 by default. otherwise, with eth1 for intranet access.

Public (eth0):
IP: 201.102.21.201
Netmask: 255.255.255.241
Gateway: 201.102.21.1

Intranet (eth1):
IP: 10.1.10.24
Netmask: 255.255.255.0
Gateway: 10.1.10.1

Basic command for adding route on Linux:

route add [-net|-host] <IP/Net> netmask <Mask> gw <Gateway IP> dev <Int>X

And this is what we do:

route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.1.10.1 dev eth1
route add -net default netmask 0.0.0.0 gw 201.102.21.1 dev eth0

To check the route, simply type “route” with no arguments

route

The output will seen like this:

Kernel IP routing table
Destination¬ ¬ ¬ ¬ Gateway¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ Genmask¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ Flags¬ Metric Ref¬ ¬ ¬ Use Iface
201.102.21.201¬ *¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 255.255.255.241¬ ¬ ¬ ¬ U¬ ¬ ¬ ¬ 1¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ 0 eth0
10.1.10.24¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ *¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 255.255.255.0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ U¬ ¬ ¬ ¬ ¬ 1¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ 0 eth1
link-local¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ *¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 255.255.0.0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ U¬ ¬ ¬ 1000¬ ¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ 0 eth0
10.0.0.0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 10.1.10.1¬ ¬ ¬ ¬ ¬ ¬ 255.0.0.0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ UG¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ 0 eth1
default¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 201.102.21.1¬ ¬ ¬ 0.0.0.0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ UG¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ ¬ 0¬ ¬ ¬ ¬ ¬ ¬ ¬ 0 eth0

Now, to keep this route persistent, add this lines to file /etc/networking/interfaces

up route add -net 10.0.0.0 netmask 255.0.0.0 gw 10.1.10.1 dev eth1
up route add -net default netmask 0.0.0.0 gw 201.102.21.1 dev eth0

Restart networking to confirm the changes

sudo /etc/init.d/networking restart

Other method, Create a file called defaultroute in /etc/init.d and make it executable (chmod +x /etc/init.d/defaultroute).
Add the route commands there and do this:

update-rc.d defaultroute defaults 99

.

Programming

Restore Ubuntu Boot Loader

To repair your Ubuntu GRUB, you need Ubuntu LiveCD, boot from this CD, and open a terminal. Be a root, by typing “sudo su” and enter your password.

Find the partition which your Ubuntu system is installed.

# fdisk -l

On my machine, my Ubuntu partition is on /dev/sda3, so i’ll use this for example.

Create a mountpoint for this:

# mkdir /media/rootgrub
# mount /dev/sda3 /media/rootgrub

Check if your partition is the correct partition

# ls /media/rootgrub

if the output is not like this, then you have the wrong partition

bin dev home lib mnt root srv usr boot etc initrd lib64 opt sbin sys
var cdrom initrd.img media proc selinux tmp vmlinuz

unmount the partition if have the wrong one, then mount the others. To make sure you have the correct partition, run ls /media/root/boot, which should output something like this :

config-2.6.18-3-686 ¬ ¬ initrd.img-2.6.18-3-686.bak ¬ ¬ System.map-2.6.18-3-686
grub lost+found ¬ ¬ ¬ ¬ ¬ vmlinuz-2.6.18-3-686 ¬ ¬ ¬ ¬ ¬ ¬ initrd.img-2.6.18-3-686
memtest86+.bin

Now when everything is ok, install the Grub:

# sudo grub-install –root-directory=/media/rootgrub¬ /dev/sda

If you have some warning, try this:

# sudo grub-install –root-directory=/media/rootgrub¬ /dev/sda –recheck

Change /dev/sda to other partition you want to install Grub on. If all goes fine, you will see the output like this:

Installation finished. No error reported. This is the contents of the device map /boot/grub/device.map. Check if this is correct or not. If any of the lines is incorrect, fix it and re-run the script `grub-install’.

(hd0) /dev/sda

Restart to your harddrive (not to LiveCD) and see, your GRUB should be AUTOMAGICALLY appear!

Programming

Reset Mysql Root Password

Terrible, just setup a new server, then i forgot root password for mysql database. So i need to reset the root password.

This is the way i do:
1. Login to our server machine as root (system administrator). Yes! we must have root access to our machine.

2. Shutdown mysql server (if already running). Make sure no other mysql daemon running.

$ /etc/init.d/mysql stop

3. Create a text file and place the following statements in it. Replace the password with the password that you want to use.

UPDATE mysql.user SET Password=PASSWORD(‘YourNewPasswordHere’) WHERE User=’root’;
FLUSH PRIVILEGES;

The UPDATE and FLUSH statements each must be written on a single line. And make sure we have statement “where user=’root’“, to make sure, only our root password is updated.

4. Save the text file into our home directory, or somewhere else. Example, i saved this as: “/home/vandai/mysql-reset

5. Start the MySQL server with the special –init-file option:

mysqld_safe –init-file=/home/vandai/mysql-reset &

This will execute the contents of the file named by the –init-file option at startup, changing each root account password.

6. Don’t forget to delete mysql-reset file immediately!!

Now we will be able to login to MySql database as root with our new password.

Never forget the password again!!

Tech-News

Google has change the Google Search Favicon

Baru sadar, waktu lagi nyari sesuatu di Google, ada yang beda pada tampilan halaman Google.
Favicon Google berubah. favicon itu yang ada disebelah alamat URL pada address bar, dan juga biasanya ada di tab browser.

Biasanya selama ini favicon Google adalah huruf G dengan uppercase.
Sekarang jadi huruf g dengan lowercase.

Google Favicon

Tapi ternyata tidak semua mirror Google yang berubah. Pada beberapa negara masih menggunakan favicon yang biasa. Setidaknya pada mirror Google di Indonesia, Prancis, Italy, Belanda, Rumania, dan Malaysia faviconnya berubah.
Bahkan di server utama nya http://www.google.com/ masih menggunakan favicon yang standar kebesaran Google.

Yah, biar tidak bosan kali…