cPanel: Delete error_log & *php.error.log files

Ever wanted to easily and quickly dispose of error_log and/or <domain>.php.error.log files on your cPanel server? Fortunately, there’s a way to do just that!

find /home/* -path /home/virtfs -prune -o -type f -name error_log -exec /bin/rm -fv {} \;
find /home/* -path /home/virtfs -prune -o -type f -name *php.error.log -exec /bin/rm -fv {} \;

 

he above commands will search all of the cPanel accounts in your home directories for files named error_log and/or <domain>.php.error.log and remove any that it finds. It will also exclude /home/virtfs/, as files in this directory are read-only. It will create a list of the files that it removed, like so:

root@server [~]# find /home/* -path /home/virtfs -prune -o -type f -name error_log -exec /bin/rm -fv {} \;
removed ‘/home/testuser/public_html/error_log’
root@server [~]#

 

cPanel: cPHulk Service Failure

On a cPanel system with cPHulk, you may run into an error like so:

(XID e22d2d) The “cphulkd” service failed because it cannot find the “/var/run/cphulkd_db.sock” socket.

The subprocess “/usr/local/cpanel/scripts/restartsrv_cphulkd” reported error number 255 when it ended.

The system could not provide log messages for “cphulkd” because it failed to read all of the potential log files with the following errors: Error while attempting to open “/var/log/secure”: “No such file or directory”, Error while attempting to open “/var/log/maillog”: “No such file or directory”, Error while attempting to open “/var/log/messages”: “No such file or directory”

This typically indicates that the rsyslogd service is not installed and/or not running, which is responsible for maintaining files such as /var/log/secure, /var/log/messages, etc.

# /scripts/restartsrv_rsyslogd
(XID bx88f7) The “rsyslog” service is disabled.

To resolve this, simply install the rsyslog RPM:

# yum install rsyslog

You then need to start the service, and configure it to start on boot:

# systemctl start rsyslog
# systemctl enable rsyslog

You’re now all done! The missing log files should now exist, and cPHulk should no longer return an error message about missing files.

cPanel: Find accounts with highest CPU, Memory & MySQL Usage

You may have come across a time where there’s higher-than-usual resource usage, and you’re trying to pinpoint the cause. Sometimes that can be tricky, though, with the below command, you can quickly and easily build up a list of the top 5 users that are consuming your CPU, Memory and MySQL resources. This command does not make any changes to your server. The expected output of the command can also be seen below.

 

OUT=$(/usr/local/cpanel/bin/dcpumonview | grep -v Top | sed -e ‘s#<[^>]*># #g’ | while read i ; do NF=`echo $i | awk {‘print NF’}` ; if [[ “$NF” == “5” ]] ; then USER=`echo $i | awk {‘print $1’}`; OWNER=`grep -e “^OWNER=” /var/cpanel/users/$USER | cut -d= -f2` ; echo “$OWNER $i”; fi ; done) ; (echo “USER CPU” ; echo “$OUT” | sort -nrk4 | awk ‘{printf “%s %s%\n”,$2,$4}’ | head -5) | column -t ;echo;(echo -e “USER MEMORY” ; echo “$OUT” | sort -nrk5 | awk ‘{printf “%s %s%\n”,$2,$5}’ | head -5) | column -t ;echo;(echo -e “USER MYSQL” ; echo “$OUT” | sort -nrk6 | awk ‘{printf “%s %s%\n”,$2,$6}’ | head -5) | column -t ;

 

Output Will be

 

USER       CPU
user1        2.51%
user2        1.48%
user3        1.04%
user4        0.77%
user5        0.61%

USER       MEMORY
user1        5.67%
user2        0.38%
user3        0.38%
user4        0.13%
user5        0.12%

USER       MYSQL
user1        0.3%
user2        0.0%
user3        0.0%
user4        0.0%
user5        0.0%

Root Shells on Linux Servers Using  polkitd Vulnerability

A new vulnerability that affects many Linux systems has been revealed: Pwnkit. This attack uses a vulnerability in polkitd to allow any user to escalate his privileges to root.  There are patches for major Linux systems: see the LowEndTalk thread.

It’s important to note that the vulnerability can only be used by users logged into the system.  You can’t launch this attack on just any Linux box you ping on the network.

Patch your systems ASAP!

Failed to start MariaDB 10.3 database server [SOLVED]

Hello,
Today i will Share a Horror Story about Mariadb(MySQL) ,

We are Checking Our Server Load in that time we face a Huge Load Issue in our Server that was 12 Core CPU so it almost consumes 80% of the CPU we look into deep but in this case, the Server get Restart. When I Back it Online All Of the services are Working good But MYSQL Not Working Most Of the Sites are Facing MYSQL Issue, Database not Establish, I think to look at MYSQL or MariaDB I get

[root@us ~]# systemctl restart mariadb
Job for mariadb.service failed because the control process exited with error code. See “systemctl status mariadb.service” and “journalctl -xe” for details.

This means We have Some issue in MariaDB Service so look into it
No Solution !! No Solution
I think my Database Cruppretted 🙁 & yes I am finding a Solution for it No Solution.
last I figure out it if I make rename to ib_logfile0 & ib_logfile1
what will be ?
I did to Rename

mv /var/lib/mysql/ib_logfile0 /var/lib/mysql/ib_logfile0.bak 

mv /var/lib/mysql/ib_logfile1 /var/lib/mysql/ib_logfile1.bak

systemctl start mysql

WOW 😮 My MariaDB Service Active & Working 🙂

 

Nothing is Impossible If you try  🙂 have a Nice Day

 

cPanel MySQL/MariaBB error: adminbin Cpanel/cpmysql/DBCACHE: exit 11 [SOLVED]

Many cPanel users are experiencing the above error within the cPanel interface recently; The error appears within cPanel, giving the impression that MariaDB/ MySQL is not working. Infect the error is a false positive, MariaDB/MySQL is infect working perfectly fine.

 

 The MySQL server is currently offline.
 adminbin Cpanel/cpmysql/DBCACHE: exit 1

First Check Log in cPanel

/usr/local/cpanel/logs/error_log

You May Get Something Like That

cpanel::cpanel::cptt_exectag("/usr/local/cpanel/base/frontend/paper_lantern/sql/index.html.tt", 1) called at cpanel.pl line 4637
cpanel::cpanel::run_standard_mode() called at cpanel.pl line 929
cpanel::cpanel::script("cpanel::cpanel", "./frontend/paper_lantern/sql/index.html.tt") called at cpanel.pl line 325
[2021-10-26 05:47:41 +0000] info [] The cacheid for the user “thetechp” was reset because it was in the future: Tue Nov 9 08:12:02 2021
[2021-10-26 05:47:41 +0000] info [] The cacheid for the user “thetechp” was reset because it was in the future: Tue Nov 9 08:12:06 2021
[2021-10-26 05:47:41 +0000] info [] The cacheid for the user “agunmyid” was reset because it was in the future: Tue Nov 9 08:06:37 2021

To Fix This Issue

mysqldump MySQL > /root/mysql-backup.sql
Then Go to WHM Click Jetbackup & Restore Old Backup To That User which one is affected   & Get Fix 
/scripts/restartsrv_mysql
Have a Good Day 🙂 

HOW TO INSTALL REDIS AND PHP REDIS ON A CPANEL CENTOS 7 SERVER

This guide will show you how to set up Redis and PHP Redis to dramatically increase the performance of your server.

Redis is an open-source solution that functions as a database of structured cached data that is saved in your server’s RAM. Instead than relying on disk delay, the cache will deliver significantly higher throughput because it is stored in memory.

The guide presupposed that you have a CentOS 7 server with cPanel installed. If you have a Managed Server the installation can be done by our support.

1) Login through SSH and run the following commands :

sudo yum install epel-release yum-utils
sudo yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
sudo yum-config-manager --enable rem
yum install redis

2) Once installed, you would need to start it:

sudo systemctl start redis
sudo systemctl enable redis
sudo systemctl status redis

The latest command should give you a confirmation of that Redis is running.

sudo systemctl status redis
● redis.service – Redis persistent key-value database
Loaded: loaded (/usr/lib/systemd/system/redis.service; enabled; vendor preset: disabled)
Drop-In: /etc/systemd/system/redis.service.d
└─limit.conf
Active: active (running) since Fri 2021-09-17 12:41:53 EDT; 8s ago
Main PID: 17753 (redis-server)
CGroup: /system.slice/redis.service
└─17753 /usr/bin/redis-server 127.0.0.1:6379

It also returns the port being used (here 6379) which you may need for your application.

3) log in to WHM and search in the WHM sidebar for Module Installers. Click on it and then click on Manage PHP PECL.

4) At the next stage, select the PHP version you would like to install Redis For and inside the Module Search type Redis and click on Go

5) Finally, in the search result click on Install and after a few seconds, it should be completed.

That’s it, you have now enabled a Redis Cache on your server.

./

Installing pdftk on Centos 7

PDFtk is a toolkit for manipulating Portable Document Format documents. It runs on Linux, Windows and MacOS. It comes in three versions: PDFtk Server, PDFtk Free and PDFtk Pro. It is able to concatenate, shuffle, split and rotate PDF files. It can also show and update metadata .

How to Install ?
i search in google but no luck also in pdftk official document don’t have instruction for centos 7 🙁  so here is solution for public

Step 1 : Login Your Server / VPN

Step 2: Open Terminal
Step 3 :  Now  Copy & Past this Code

    copy robert-gcj-epel-7.repo to /etc/yum.repos.d folder

wget https://copr.fedorainfracloud.org/coprs/robert/gcj/repo/epel-7/robert-gcj-epel-7.repo -P /etc/yum.repos.d

robert-pdftk-epel-7.repo to /etc/yum.repos.d folder

wget https://copr.fedorainfracloud.org/coprs/robert/pdftk/repo/epel-7/robert-pdftk-epel-7.repo -P /etc/yum.repos.d

yum install pdftk

Before run all First Check link active or not 

ping copr.fedorainfracloud.org

 

 

Have a Good Day !!!

Install WordPress Toolkit for cPanel

WordPress Toolkit is a feature-rich management interface that allows anyone to install, configure, and manage WordPress websites. WordPress Toolkit Lite is included FREE and WordPress Toolkit Deluxe is a paid upgrade with advanced features and smarter functionality. Availability of these tools may need to be enabled by your hosting provider.

 

Why WordPress Toolkit is Best:-

Advanced Management

Install plugins or themes, even directly from WordPress.org; activate, deactivate, manage, or delete them per website or in bulk across some or all of you sites.

Features Testing

Clone any existing site to a completely safe staging area on it’s own database in order to experiment, then sync back to your live website when you’re ready.

Additional Security

Scan and harden all of your websites against security risks using updates based on recommendations from WordPress community experts.

Smart Updates

Automatically test updates for themes, plugins, languages, and WordPress itself in a completely safe environment at no risk to your live website.

Now Install WordPress Toolkit lite:-

Note:
  • When you upgrade a server with WordPress Manager to cPanel & WHM version 92, it will automatically install WordPress Toolkit.
  • WordPress Toolkit is compatible with the following operating systems and cPanel & WHM versions:
    • Operating Systems: CentOS 7, CentOS 8, CloudLinux™ 6, CloudLinux 7, CloudLinux 8.
    • cPanel & WHM versions: 86 Long Term Support (LTS), 90 and newer.
  • WordPress Toolkit requires that you set a PHP Memory limit of 128MB or higher. You can set this limit in WHM’s MultiPHP INI Editor interface (WHM >> Home >> Software >> MultiPHP INI Editor).

Login Your Server / WHM  Then Open a Terminal  Type This Command
To install WordPress Toolkit manually from the command line, run the following command as the root user:

sh <(curl https://wp-toolkit.plesk.com/cPanel/installer.sh || wget -O - https://wp-toolkit.plesk.com/cPanel/installer.sh)


 

How to Install the PHP Suhosin Extension

What is Suhosin?

Suhosin (pronounced ‘su-ho-shin’) is an advanced protection system for PHP 5 installations. It is designed to protect servers and users from known and unknown flaws in PHP applications and the PHP core. Suhosin comes in two independent parts, that can be used separately or in combination. The first part is a small patch against the PHP core, that implements a few low-level protections against buffer overflows or format string vulnerabilities and the second part is a powerful PHP extension that implements numerous other protections.

Why Suhosin?

The most important question for new users of Suhosin is, why they should use Suhosin at all, if it is really necessary and what they gain by using the patch, the extension or a combination of both.

The answer to this question depends on what your usage of PHP is. If you are using PHP only for your own server and only for your own scripts and applications, then you can judge for yourself, if you trust your code enough. In that case you most probably don’t need the Suhosin extension. Because most of it’s features are meant to protect servers against vulnerable programming techniques. However PHP is a very complex programming language with a lot of pitfalls that are often overseen during the development of applications. Even PHP core programmers are writing insecure code from time to time, because they did not know about a PHP pitfall. Therefore it is always a good idea to have Suhosin as your safety net. The Suhosin-Patch on the other hand comes with Zend Engine Protection features that protect your server from possible buffer overflows and related vulnerabilities in the Zend Engine. History has shown that several of these bugs have always existed in previous PHP versions.

If you are not only running your own PHP scripts but are also hosting 3rd party PHP applications for yourself or even for possible customers, then you cannot trust the code quality of the PHP applications you use. Unfortunately, it is a fact that the pitfalls of the PHP language are not widely known among programmers. Many of these pitfalls are also not documented in the PHP-Security books that have been released during the last year. This is mainly caused by the fact, that the books were written in a hurry to be the first in market and because most of these books were not written by security professionals but by PHP programmers. The worst of these books is the one by Oreilly which contains examples that might fix the problem described but introduces more dangerous vulnerabilities into your application.

Another common error in these books is that they spread the urban legend that the most dangerous problem within PHP “remote code inclusion vulnerabilities” can be fixed by disabling allow_url_fopen in the configuration (or allow_url_include in PHP 5.2.x). This information is simply wrong, because these configuration directives do NOT protect against attacks through php://input or data:// URLs. Our Suhosin and the former Hardening-Patch are the only available protections that close all URL include attacks.

Summed up, it is your free choice to use Suhosin. If you want additional protection for your servers and your business, we can only recommend strongly that you use the extension and the patch. Always keep in mind that you are not only protecting yourself and your users, but also other people on the internet, that might get attacked by your server after it has been turned into a (Spam-/DDOS-)attack drone.

Installing Suhosin on PHP 7.0 or 7.1

To install on PHP 7.X, SSH into your server as root and install the packages required to build the Suhosin extension.

sudo apt-get -y install gcc make autoconf libc-dev pkg-config

Next, run the following commands on your server:

git clone https://github.com/sektioneins/suhosin7
cd suhosin7
/opt/sp/php7.X/bin/phpize
PATH=/opt/sp/php7.X/bin:$PATH ./configure
make
sudo make install
sudo bash -c "echo extension=suhosin.so > /etc/php7.X-sp/conf.d/suhosin.ini"
sudo service php7.X-fpm-sp restart

Installing Suhosin on PHP 5.4, 5.5, or 5.6

To install on PHP 7.X, SSH into your server as root and install the packages required to build the Suhosin extension.

sudo apt-get -y install gcc make autoconf libc-dev pkg-config

Next Download Suhosin
wget https://download.suhosin.org/suhosin-0.9.38.tar.gz
tar xzf suhosin-0.9.38.tar.gz
cd suhosin-0.9.38

Now, compile, install, and restart PHP. To install for multiple PHP versions, repeat the steps below for each PHP version.

/opt/sp/php5.X/bin/phpize
PATH=/opt/sp/php5.X/bin:$PATH ./configure
make
sudo make install
sudo bash -c "echo extension=suhosin.so > /etc/php5.X-sp/conf.d/suhosin.ini"
sudo service php5.X-fpm-sp restart

Verifying the Installation

You can verify Suhosin is installed correctly by running the command:

phpX.Y-sp -i | grep suhosin

You should see the following output:

/etc/phpX.Y-sp/conf.d/suhosin.ini,
suhosin
suhosin.apc_bug_workaround => Off => Off
suhosin.cookie.checkraddr => 0 => 0
suhosin.cookie.cryptdocroot => On => On
suhosin.cookie.cryptkey => [ protected ] => [ protected ]
suhosin.cookie.cryptlist => no value => no value
suhosin.cookie.cryptraddr => 0 => 0
suhosin.cookie.cryptua => On => On
suhosin.cookie.disallow_nul => 1 => 1
suhosin.cookie.disallow_ws => 1 => 1
suhosin.cookie.encrypt => Off => Off