Category Archives: PHP

This sections will have issues which normally do occur in php on cpanel servers

Ffmpeg on Centos 7 and Centos 6

Login to server via SSH

Below steps are for Centos 7

yum -y install epel-release

rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro

rpm -Uvh  http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release0-5.el7.nux.noarch.rpm

yum -y install ffmpeg ffmpeg-devel

 

Below steps are for Centos 6

yum -y install epel-release

rpm –import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro

wget https://li.nux.ro/download/nux/dextop/el6/x86_64/nux-dextop-release-0-1.el6.nux.noarch.rpm

rpm ivh  nux-dextop-release-0-1.el6.nux.noarch.rpm

yum -y install ffmpeg ffmpeg-devel

 

now we need to install ffmpeg-php to get it working using PHP

yum -y install git
git clone https://github.com/tony2001/ffmpeg-php.git

cd ffmpeg-php
/usr/local/cpanel/3rdparty/php/56/bin/phpize
/opt/cpanel/ea-php56/root/usr/bin/phpize
./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config

If you want to install on PHP 7 use

/opt/cpanel/ea-php7/root/usr/bin/phpize

 

[Usually before easyapache 4 only phpize would work] now as there are multiple version of PHP there is need to  phpize from above path.

The path would changes based on php version

if you are using PHP 7 path will be /opt/cpanel/ea-php70/root/usr/bin/phpize and

/opt/cpanel/ea-php70/root/usr/bin/php-config

You can find path using find command

[root@server ffmpeg-php]# find / -iname phpize
/opt/cpanel/ea-php55/root/usr/bin/phpize

/opt/cpanel/ea-php56/root/usr/bin/phpize

/opt/cpanel/ea-php70/root/usr/bin/phpize

 

Do not use path ./usr/local/cpanel/3rdparty/bin/phpize

 

Before compiling ffmpegphp

need to make sure all need files are in   /usr/include

When you install ffmpeg and ffmpeg-devel files get stored in  /usr/include/ffmpeg however ffmpeg while compiling looks for files in /usr/include/ so need to copy files to /usr/include using below command

scp -r /usr/include/ffmpeg/* /usr/include/

Now you can go ahead and compile

./configure –with-php-config=/opt/cpanel/ea-php56/root/usr/bin/php-config

Note [Path /opt/cpanel/ea-php56/root/usr/bin/php-config will changed on which version you are installing ffmpeg]

[root@server ffmpeg-php]# find / -iname php-config

/opt/cpanel/ea-php55/root/usr/bin/php-config
/opt/cpanel/ea-php56/root/usr/bin/php-config
/opt/cpanel/ea-php70/root/usr/bin/php-config

 

now before making make and make install few things need to be modified.

mv /usr/include/libavutil/time.h /usr/include/libavutil/time.h_

now go ahead with make and make install

now   again need to rename the above file

mv  /usr/include/libavutil/time.h_    /usr/include/libavutil/time.h

 

 

ffmpeg modules will be installed in below path

root@server ffmpeg-php]# ls -al /opt/cpanel/ea-php56/root/usr/lib64/php/modules/
total 2712
drwxr-xr-x 2 root root 4096 Dec 7 07:07 .
drwxr-xr-x 4 root root 4096 Feb 22 2017 ..
-rwxr-xr-x 1 root root 32608 Feb 22 2017 bcmath.so
-rwxr-xr-x 1 root root 33792 Feb 22 2017 calendar.so
-rwxr-xr-x 1 root root 15584 Feb 22 2017 ctype.so
-rwxr-xr-x 1 root root 86928 Feb 22 2017 curl.so
-rwxr-xr-x 1 root root 180728 Feb 22 2017 dom.so
-rwxr-xr-x 1 root root 281640 Dec 7 07:07 ffmpeg.so
-rwxr-xr-x 1 root root 57792 Feb 22 2017 ftp.so

 

Now go ahead and add extension=ffmpeg.so to php.ini for the PHP version you need and restart apache

 

 

Parse html as PHP is easyapache 4

 

Normal rule in .htaccess to parse html files as php on easyapache 3 are not working on easyapache 4

#AddType application/x-httpd-php .php .htm .html

#<FilesMatch “\.(htm|html|php)$”>
#SetHandler application/x-httpd-php56
#</FilesMatch>

 

Below is the code which will need to be added In cpanel, multiphp manager will add the following for force a specific
version of php:

# php — BEGIN cPanel-generated handler, do not edit
# Set the “ea-php54” package as the default “PHP” programming language.

AddType application/x-httpd-ea-php54 .php .php5 .phtml

# php — END cPanel-generated handler, do not edit

Make sure the AddType and the selected php version matches! So there we go, simple when you know how.

 

 

Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again

While working on a server on installing php 5.6 on centos 6 OS

I was getting error “Error: Cannot retrieve metalink for repository: epel. Please verify its path and try again”

After googleing around I found this issue is due to https mentioned in the .repo file in /etc/yum.repos.d

[root@host yum.repos.d]# ls -la
total 28
drwxr-xr-x. 2 root root 4096 Oct 28 05:15 .
drwxr-xr-x. 80 root root 4096 Oct 28 05:16 ..
-rw-r–r–. 1 root root 954 Oct 28 05:15 epel.repo
-rw-r–r–. 1 root root 1056 Nov 4 2012 epel-testing.repo
-rw-r–r–. 1 root root 966 Jul 4 2015 webtatic-archive.repo
-rw-r–r–. 1 root root 862 Oct 28 05:15 webtatic.repo
-rw-r–r–. 1 root root 966 Jul 4 2015 webtatic-testing.repo

I checked in all files with .repo extension and  an replaced all https with http and  all repository started working fine

 

 

 

Fixed: Strict Standards: Non-static method JLoader::import()

Code:
Strict Standards: Non-static method JLoader::import() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/import.php on line 38Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 71

Strict Standards: Non-static method JLoader::import() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/import.php on line 39

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 71

Strict Standards: Non-static method JLoader::load() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 161

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 138

Strict Standards: Non-static method JLoader::import() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 186

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 71

Strict Standards: Non-static method JFactory::getConfig() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/application/application.php on line 726

Strict Standards: Non-static method JFactory::_createConfig() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/factory.php on line 73

Strict Standards: Non-static method JLoader::import() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 186

Strict Standards: Non-static method JLoader::load() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 161

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 138

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/registry/registry.php on line 19

Strict Standards: Non-static method JLoader::load() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 161

Strict Standards: Non-static method JLoader::register() should not be called statically in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/loader.php on line 138

Strict Standards: Non-static method JUtility::getHash() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/application/application.php on line 99

Strict Standards: Non-static method JFactory::getConfig() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/utilities/utility.php on line 111

Strict Standards: Non-static method JFactory::getSession() should not be called statically, assuming $this from incompatible context in /var/www/vhosts/marylynnmurray/yalestationspaandsalon.com/libraries/joomla/application/application.php on line 752

Solution:

 Open your php.ini
Find:

Code:
error_reporting = E_ALL | E_STRICT

and change it to:

Code:
;error_reporting = E_ALL | E_STRICT
Shut error reporting off. It worked for me and allowed my joomla site to show up.
HOORAY!!

HTTPS to HTTP redirect

Redirect your Homepage from HTTPS to HTTP

1
2
3
#Redirect your Homepage from HTTPS to HTTP
RewriteCond %{HTTPS} on
RewriteRule ^$ http://%{HTTP_HOST} [L,R]

libMagickWand.so.2: cannot open shared object file

While working on one cPanel server we could see below error in error_log file for one client

libMagickWand.so.2: cannot open shared object file

The error log were filled by such errors

reinstalling imagemagick  using command  /scripts/installimagemagick  didnt work as error were still persisting .

So renamed the php,ini file

mv /usr/local/lib/php.ini /usr/local/lib/php.ini-old

Now to regenerate the new php.ini file I had to use command

/scripts/phpini

A new PHP.ini was create with default entries like a newly set server.

Modified the PHP.ini to customize it  as needed

Then had to finish it by rebuilding apache and php using easyapache

/scripts/easyapache

Now all sites work fine without any error 🙂

 

 

 

 

Blank PHPmyadmin page in cpanel

While working with one hosting client we came across an issue where PHPmyadmin was blank

On checking logs on /usr/local/cpanel/logs/error_log we could see below error

root@hosonline  [~]# tail -n 10 /usr/local/cpanel/logs/error_log
Cpanel::Server::write_buffer(Cpanel::Server=HASH(0x4abf5d8), “HTTP/1.1 401 Access Denied\x{d}\x{a}Set-Cookie: cprelogin=no; HttpOnl”…) called at /usr/local/cpanel/Cpanel/Server.pm line 1132
Cpanel::Server::write_content_to_socket(Cpanel::Server=HASH(0x4abf5d8), IO::Socket::SSL=GLOB(0x4a9c208), 0, “HTTP/1.1 401 Access Denied\x{d}\x{a}Set-Cookie: cprelogin=no; HttpOnl”…, SCALAR(0x20f8ae8)) called at /usr/local/cpanel/Cpanel/Server.pm line 626
Cpanel::Server::badpass(Cpanel::Server=HASH(0x4abf5d8), __CPANEL_HIDDEN__, 1) called at cpsrvd.pl line 2997
cpanel::cpsrvd::badpass(__CPANEL_HIDDEN__, 1) called at cpsrvd.pl line 5278
cpanel::cpsrvd::handle_auth() called at cpsrvd.pl line 1222
cpanel::cpsrvd::handle_one_connection() called at cpsrvd.pl line 1073
cpanel::cpsrvd::script() called at cpsrvd.pl line 437
PHP Fatal error: Class ‘AuthenticationCpanel’ not found in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/common.inc.php on line 876
PHP Fatal error: Class ‘AuthenticationCpanel’ not found in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/common.inc.php on line 876
PHP Fatal error: Class ‘AuthenticationCpanel’ not found in /usr/local/cpanel/base/3rdparty/phpMyAdmin/libraries/common.inc.php on line 876

The issue was diagnosed to missing libraries

We resolved the issue using below command by upgrading PHPmyadmin

/usr/local/cpanel/bin/updatephpmyadmin –force

Now PHPmyadmin works like Charm 🙂

 

Install ZendGuard on cPanel server

To install ZendGuard on cpanel server follow below steps

SSH to server as root user and run below script

root@online  [~]# /scripts/installzendopt

Updating digest list Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz.yaml (connected:0)…….(request attempt 1/12)…Using dns cache file /root/.HttpRequest/httpupdate.cpanel.net……searching for mirrors (mirror search attempt 1/3)……loaded mirror speeds from cache……mirror search success……connecting to 67.222.0.10…@67.222.0.10……connected……receiving…100%……request success……Done Downloading tarball for Zendopt Fetching http://httpupdate.cpanel.net/cpanelsync/easy/targz/Cpanel/Easy/Zendopt.pm.tar.gz.linux-generic-64 (connected:0)…….(request attempt 1/12)……connecting to 67.222.0.10…@67.222.0.10……connected……receiving…2%…5%…8%…10%…13%…16%…18%…21%…24%…26%…29%…32%…34%…37%…40%…42%…45%…48%…50%…53%…56%…58%…61%…64%…66%…69%…72%…74%…77%…80%…82%…85%…88%…90%…93%…96%…98%…100%……request success……Done Installing Zendopt Skipping install to /usr/local/php4, missing php.ini Determining PHP version Installing Zend Guard/Optimizer 6.0 for PHP 5.4 Activated Zend Guard/Optimizer

 

Now restart apache using below command to complete the process

root@hostonline [~]# service httpd restart

An unexpected error occurred. Something may be wrong with WordPress.org

Are you getting error below error in wordpress while installing plugin ?

“An unexpected error occurred. Something may be wrong with WordPress.org”  The solution for this issue is to check file wp-config.php

While troubleshooting issue I see the error was in wp-config.php

I commented out below settings to fix this issue

/** EXAMPLE – proxy settings */
#define(‘WP_PROXY_HOST’, ‘proxy.url.com’);
#define(‘WP_PROXY_PORT’, ‘1234’);
#define(‘WP_PROXY_USERNAME’, ”);
#define(‘WP_PROXY_PASSWORD’, ”);
#define(‘WP_PROXY_BYPASS_HOSTS’, ‘localhost’);

This issue got fixed once I commented the above settings.

 

Adding a custom php.ini cPanel account

To make your account in cpanel  server have custom php.ini for all subfolder                       You need to use below code steps

1)   Login to server via SSH

2) scp /usr/local/lib/php.ini  /home/cpanelusername/public_html/

3)   vi /home/cpanelusername/public_html/.htaccess

Add below code

suPHP_ConfigPath /home/pankaj12/public_html
<Files php.ini>
order allow,deny
deny from all
</Files>

Once done custom php.ini should be available for all accounts