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!