Category Archives: php

Install PHP 7.2 on CentOS, RHEL

 

Repositories configuration:

On Fedora, standards repositories are enough, on Enterprise Linux (RHEL, CentOS) the Extra Packages for Enterprise Linux (EPEL) repository must be configured, and on RHEL the optional channel must be enabled.

Fedora 27

wget http://rpms.remirepo.net/fedora/remi-release-27.rpm
dnf install remi-release-27.rpm

Fedora 26

wget http://rpms.remirepo.net/fedora/remi-release-26.rpm
dnf install remi-release-26.rpm

RHEL version 7.4

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-7-server-optional-rpms

RHEL version 6.9

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm
rhn-channel --add --channel=rhel-$(uname -i)-server-optional-6

CentOS version 7.4

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm

CentOS version 6.9

wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
wget http://rpms.remirepo.net/enterprise/remi-release-6.rpm
rpm -Uvh remi-release-6.rpm epel-release-latest-6.noarch.rpm

 

remi-php72 repository activation

Needed packages are in the remi-safe (enabled by default) and remi-php72 repositories, the latest is not enabled by default (administrator choice according to the desired PHP version).

RHEL or CentOS

yum install yum-utils
yum-config-manager --enable remi-php72

Fedora

dnf install dnf-plugins-core
dnf config-manager --set-enabled remi-php72

 

PHP upgrade

By choice, the packages have the same name than in the distribution, so a simple update is enough:

yum update

That’s all 🙂

$ php -v
PHP 7.2.0 (cli) (built: Nov 28 2017 10:27:47) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.2.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.2.0, Copyright (c) 1999-2017, by Zend Technologies
    with Xdebug v2.6.0alpha1, Copyright (c) 2002-2017, by Derick Rethans

 

How to Add a WordPress Administrator to the Database using SQL Queries

Manually Add a WordPress User with Administrator Role to the MySQL Database using SQL Quries or phpMyAdmin

In a recent WordPress hack attack which we worked on and recovered, the owner’s WordPress administrator account was demoted to a user role, therefore the owner did not have any control over the WordPress installation. To regain back access to WordPress, we manually created a new WordPress user with an Administrator role directly in the database.

In this tutorial we will show you how to manually create a WordPress administrator in the WordPress database by using any  MySQL command line (SQL queries).

Create a WordPress User using SQL Queries

Or as frequently referred to, MySQL Command Line

If you have access to your MySQL database server via command line, you can use the below SQL queries to create a new WordPress administrator in the database.

1 INSERT INTO `wordpressdatabase`.`wp_users` (`ID`, `user_login`, `user_pass`, `user_nicename`, `user_email`, `user_status`, `display_name`) VALUES ('1000', 'tempuser', MD5('Str0ngPa55!'), 'tempuser', 'support@yoursite.com', '0', 'Temp User');

 

1 INSERT INTO ` wordpressdatabase`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '1000', 'wp_capabilities', 'a:1:{s:13:"administrator";s:1:"1";}');

 

1 INSERT INTO ` wordpressdatabase`.`wp_usermeta` (`umeta_id`, `user_id`, `meta_key`, `meta_value`) VALUES (NULL, '1000', 'wp_user_level', '10');

The above SQL SQL queries will create a new WordPress administrators with the following details:

Before using the above MySQL queries do not forget to:

  • change the wordpressdatabase to the WordPress database you are working with
  • change the default table prefix (wp_) if the WordPress database you are working with have non default prefixes
  • change the user Id to a bigger number if you have created more than 1000 WordPress users (If you do not specify a user ID it will be automatically generated. Then retrieve the record using an SELECT SQL statement).

Once the above SQL queries are executed, you can login to your WordPress blog or website with the newly created WordPress administrator account.

Create TCPDF PHP Fonts

TCPDF supports TrueTypeUnicode (UTF-8 Unicode), OpenTypeUnicode, TrueType, OpenType, Type1, CID-0 and Core (standard) fonts.

You will find font creation utility at fonts/utils of TCPDF… copy desired font to fonts/utils/svnlabs.ttf

* For TrueTypeUnicode

# cd /var/www/html/tcpdf/fonts/utils

# ttf2ufm -a -F svnlabs.ttf

# php -q makefont.php svnlabs.ttf svnlabs.ufm

* For embedded fonts to tcpdf PDF file.. copy the resulting svnlabs.php, svnlabs.z and svnlabs.ctg.z to fonts folder

Uses:

<?php

……..

$pdf->SetFont(‘svnlabs’,’I’,8);

……….

?>