Archive

Archive for the ‘CPanel / WHM’ Category

Resetting email account password from Command line in cPanel

March 17th, 2018 No comments

Resetting email account password from Command line in cPanel

1) Login to the server as root via SSH

2) Run the command “openssl” and you will see this:

[email protected] [~]# openssl
OpenSSL>

3) Now in the OpenSSL prompt give the command : passwd -1 “your_new_email_password”

[email protected] [~]# openssl
OpenSSL> passwd -1 “[email protected]
$1$m4pq941w/j$1KYI5VwHl8C6h9H6ScTFNWy/
OpenSSL> quit

Please note the option in command: passwd -1 “[email protected]”. It is not alphabet “-l”. It is numeric “-1”.
You will get the MD5 encrypted format for your password. Copy it somewhere.

4) Now you need to go to cpanel account’s home directory and then into etc folder.

[email protected] [~]# cd /home/test/etc/test.com
[email protected] [/home/test/etc/test.com]#

5) There you will be seeing some files : passwd, passwd,v , quota, quota,v , shadow, shadow,v .
Here the file we should consider is shadow and shadow,v.

6) If you check out shadow folder, you will see

[email protected] [/home/test/etc/test.com]# cat shadow
test:$6$itlQRsdN/bGoiCB/n/$53X3P/wy.lsS6uds4u7vporiAqdKBnfsF8Zx8b6MXs6/oxM0inzns3lsDfHdXNygq3pdPOFR57ryWHk63A7JJr2r61:15673::::::

Please note that the dark black colored part is the password part. You need to replace it with the MD5 format of your new password which you copied from OpenSSL prompt earlier.

test:$1$m4pq941w/j$1KYI5VwHl8C6h9H6ScTFNWy/:16673::::::

Save and close the file.

If shadow,v file is present then replace the encrypted part same as above. If a file is not present then try login to webmail it will work.

Categories: CPanel / WHM Tags:

cPanel EasyApache 4 Installing Redis and Redis PHP extension

March 17th, 2018 No comments

cPanel EasyApache 4 Installing Redis and Redis PHP extension

Installing the Redis daemon:

for CentOS 6/RHEL 6

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum -y install redis --enablerepo=remi --disableplugin=priorities
chkconfig redis on
service redis start

for CentOS 7/RHEL 7

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
yum -y install redis --enablerepo=remi --disableplugin=priorities
systemctl enable redis
systemctl start redis

Installing the Redis PHP extension for all available versions of PHP.
Copy and paste the entire block into SSH, don’t do line by line.

for phpver in $(ls -1 /opt/cpanel/ |grep ea-php | sed 's/ea-php//g') ; do
cd ~
wget -O redis.tgz https://pecl.php.net/get/redis
tar -xvf redis.tgz
cd ~/redis* || exit
/opt/cpanel/ea-php"$phpver"/root/usr/bin/phpize
./configure --with-php-config=/opt/cpanel/ea-php"$phpver"/root/usr/bin/php-config
make clean && make install
echo 'extension=redis.so' > /opt/cpanel/ea-php"$phpver"/root/etc/php.d/redis.ini
rm -rf ~/redis*
done

/scripts/restartsrv_httpd
/scripts/restartsrv_apache_php_fpm

All done! Check to make sure the PHP extension is loaded in each version of PHP:
Copy and paste the entire block into SSH, don’t do line by line.

for phpver in $(ls -1 /opt/cpanel/ |grep php | sed 's/ea-php//g') ; do
echo "PHP $phpver" ; /opt/cpanel/ea-php$phpver/root/usr/bin/php -i |grep "Redis Support"
done

Output should be:

PHP 55
Redis Support => enabled
PHP 56
Redis Support => enabled
PHP 70
Redis Support => enabled
PHP 71
Redis Support => enabled
Categories: CPanel / WHM, Installation Tags:

command to activate VG on LVM?

February 10th, 2018 No comments

Command to activate VG on LVM?

When you create a volume group, by default, it is activated. Sometimes you may need to activate it manually to make the kernel aware of volume groups.

To activate,

# vhchage -ay my_vg_name

To De-activate,

# vgchnage -an my_vg_name

A command to activate the VG in a cluster?

To activate exclusively on one node,

# vgchange -aey my_vg_name

To deactivate exclusively on one node,

# vgchange -aen my_vg_name

To activate only on the local node,

# vgchange -aly my_vg_name
To deactivate only on the local node,
# vgchange -aln my_vg_name

 

 

Optimize MySQL & Apache on cPanel/WHM server

January 27th, 2018 No comments

Optimize MySQL & Apache on cPanel/WHM server

On this optimization process, we will go over the Apache core configuration and modules that are part of Apache core. We think that with the correct settings of Apache and MySQL you can get excellent results and the correct level of resource use without installing third-party proxy and cache modules. So let’s start,

 

Apache & PHP

In the first stage we run the Easy Apache and selected the following:

  • Apache Version 2.4+

  • PHP Version 5.6+

  • In step 5 “Exhaustive Options List” select

– Deflate

– Expires

– MPM Worker

After Easy Apache finished go to your WHM » Service Configuration » Apache Configuration » “Global Configuration” and set the values by the level of resources available on your server.

Apache Directive       (From 2GB memory or less and to 12GB+ memory)       

StartServers            4       8       16  
MinSpareServers         4       8       16  
MaxSpareServers         8       16      32  
ServerLimit             128         256         512     
MaxRequestWorkers       150         250         500     
MaxConnectionsPerChild      1000        2500        5000 
Keep-Alive          On      On      On
Keep-Alive Timeout      1       1        1
Max Keep-Alive Requests     30      30      30
Timeout             60      60      60

Now go to WHM » Service Configuration » Apache Configuration » Include Editor » “Pre VirtualHost Include” and allow users minimal cache and data compression to allow the server to work less for the same things by pasting the code below into the text field.

# Cache Control Settings for one hour cache
<FilesMatch ".(ico|pdf|flv|jpg|jpeg|png|gif|js|css|swf)$">
Header set Cache-Control "max-age=3600, public"
</FilesMatch>

<FilesMatch ".(xml|txt)$">
Header set Cache-Control "max-age=3600, public, must-revalidate"
</FilesMatch>

<FilesMatch ".(html|htm)$">
Header set Cache-Control "max-age=3600, must-revalidate"
</FilesMatch>

# Mod Deflate performs data compression
<IfModule mod_deflate.c>
<FilesMatch ".(js|css|html|php|xml|jpg|png|gif)$">
SetOutputFilter DEFLATE
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4.0[678] no-gzip
BrowserMatch bMSIE no-gzip
</FilesMatch>
</IfModule>

Go to WHM » Service Configuration » “PHP Configuration Editor” and set the parameters according to your needs:

– memory_limit

– max_execution_time

– max_input_time

 

MySQL

For MySQL you need to update the configuration file that usually in /etc/my.cnf

Best config base on 2 core & 4GB memory MySQL 5.6 \ MariaDB 10:

[mysqld]
    local-infile = 0
    max_connections = 250
    key_buffer = 64M
    myisam_sort_buffer_size = 64M
    join_buffer_size = 1M
    read_buffer_size = 1M
    sort_buffer_size = 2M
    max_heap_table_size = 16M
    table_cache = 5000
    thread_cache_size = 286
    interactive_timeout = 25
    wait_timeout = 7000
    connect_timeout = 15
    max_allowed_packet = 16M
    max_connect_errors = 10
    query_cache_limit = 2M
    query_cache_size = 32M
    query_cache_type = 1
    tmp_table_size = 16M
    open_files_limit=25280

[mysqld_safe]

[mysqldump]
    quick
    max_allowed_packet = 16M
[myisamchk]
    key_buffer = 64M
    sort_buffer = 64M
    read_buffer = 16M
    write_buffer = 16M
[mysqlhotcopy]
    interactive-timeout

Best config base on 8 core & 16GB+ memory (Shared server) MySQL 5.6 \ MariaDB 10:

[mysqld]
local-infile=0
max_connections = 600
max_user_connections=1000
key_buffer_size = 512M
myisam_sort_buffer_size = 64M
read_buffer_size = 1M
table_open_cache = 5000
thread_cache_size = 384
wait_timeout = 20
connect_timeout = 10
tmp_table_size = 256M
max_heap_table_size = 128M
max_allowed_packet = 64M
net_buffer_length = 16384
max_connect_errors = 10
concurrent_insert = 2
read_rnd_buffer_size = 786432
bulk_insert_buffer_size = 8M
query_cache_limit = 5M
query_cache_size = 128M
query_cache_type = 1
query_prealloc_size = 262144
query_alloc_block_size = 65535
transaction_alloc_block_size = 8192
transaction_prealloc_size = 4096
max_write_lock_count = 8
slow_query_log
log-error
external-locking=FALSE
open_files_limit=50000

[mysqld_safe]

[mysqldump]
quick
max_allowed_packet = 16M

[isamchk]
key_buffer = 384M
sort_buffer = 384M
read_buffer = 256M
write_buffer = 256M

[myisamchk]
key_buffer = 384M
sort_buffer = 384M
read_buffer = 256M
write_buffer = 256M

sort_buffer_size = 1M
join_buffer_size = 1M
thread_stack = 192K

Categories: Control Panel, CPanel / WHM, Tweaks Tags:

Can’t locate DateTime perl module

July 22nd, 2017 No comments

If you are getting below error while installing any application on linux then perl date time module is missing.

Can’t locate DateTime.
pm in @INC (@INC contains: /usr/local/lib/perl5 /usr/local/share/perl5 /usr/lib/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib/perl5 /usr/share/perl5 .) at gatherbot_en.pl line 13.
BEGIN failed–compilation aborted at gatherbot_en.pl line 13.

You can use below command to install Datetime on server.

yum install perl-DateTime-TimeZone

After that if you are getting below error.

Can’t locate Date/Parse.pm in @INC

Then please run below command. It will ask to install some modules then keep on typing yes or hit enter.

cpan install Date::Parse

 

Categories: CPanel / WHM, Installation Tags:

How to change the color of your BASH prompt

May 11th, 2017 No comments

How to change the color of your BASH prompt

You can change the color of your BASH prompt to green with this command:

export PS1=”\e[0;32m[\[email protected]\h \W]\$ \e[m”

It will change the colour of bash temporarily. To make it permanent then add code in bash_profile page.

vi ~/.bash_profile

and paste above code save the file and you are done.

For other colors please see the attached list:

Color Code
Black 0;30
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Blue 0;34
Green 0;32
Cyan 0;36
Red 0;31
Purple 0;35
Brown 0;33
Light Color Code
Light Black 1;30
Light Blue 1;34
Light Green 1;32
Light Cyan 1;36
Light Red 1;31
Light Purple 1;35
Light Brown 1;33
Light Blue 1;34
Light Green 1;32
Light Cyan 1;36
Light Red 1;31
Light Purple 1;35
Light Brown 1;33

Categories: Cloud Linux, CPanel / WHM, Tweaks Tags:

Kill restore process in new cpanel

October 14th, 2014 No comments

Kill restore process in new cpanel

 

In new cpanel/WHM when we try to kill restore process it is still showing in WHM >> restore full backup. Below are the steps to remove that process from WHM.

You can manually mark the transfer as completed using the following instructions:

Ensure the transfer is no longer running by clicking on the “View” option under “Sessions in Progress” for this transfer. In the new window, there will be a line that looks like this:

You may close this window and view the transfer on the command line: /usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro

Access your server via SSH and run that command (the transfer name will be different on your server):

/usr/local/cpanel/bin/view_transfer 1071601843quick20141013154952IAZhRro

As an example, you might see output like this:

Transfer running with pid: paused
[795 ][MASTER ]: Start Session
[795 ][MASTER ]: Version: 1.9

You will note that the master PID for this transfer is xxx. If the process still exists, and the transfer has failed, then you can kill that process:

kill -9 xxx

The next step requires you to change the entry for this transfer in the whmxfer.sessions table in MySQL. Find the entry with the session ID for your migration. In the example we have been using, it’s ‘ 1071601843quick20141013154952IAZhRro .’ It will look like this:

mysql -e “select * from whmxfer.sessions where sessionid=’1071601843quick20141013152137YIVT7Ze'”
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+
| sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+
| 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps1.insurancedxb.com | localhost | 50 | 2014-10-13 08:21:37 | NULL |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———+

You will need to change the ‘state’ field to 100, and change the ‘endtime’ field from NULL to a time after the ‘starttime’ field:

mysql -e “update whmxfer.sessions set state=’100′, endtime=’2014-10-14 09:37:52′ where sessionid=’1071601843quick20141013152137YIVT7Ze'”

If you check it again then you will notice that process ended.

+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+
| sessionid | initiator | pid | version | target_host | source_host | state | starttime | endtime |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+
| 1071601843quick20141013152137YIVT7Ze | quickrestore | 21295 | 1.9 | vps1.insurancedxb.com | localhost | 100 | 2014-10-13 08:21:37 | 2014-10-14 09:37:52 |
+————————————–+————–+——-+———+———————–+————-+——-+———————+———————+

The transfer should then no longer appear under “Sessions in Progress.”

You can reconfirm the same by login into WHM.

Categories: CPanel / WHM, Uncategorized Tags:

How to replace MySQL with MariaDB in cpanel

September 30th, 2014 No comments

Backup existing MySQL data

Make sure to save all existing data just in case there are any issues.

cp -Rf /var/lib/mysql /var/lib/mysql-old
mv /etc/my.cnf /etc/my.cnf-old

Disable the targets so cPanel no longer handles MySQL updates

The following will mark the versions of MySQL we distribute as uninstalled so they are no longer maintained by cPanel/WHM

/scripts/update_local_rpm_versions –edit target_settings.MySQL50 uninstalled
/scripts/update_local_rpm_versions –edit target_settings.MySQL51 uninstalled
/scripts/update_local_rpm_versions –edit target_settings.MySQL55 uninstalled

Remove existing MySQL RPM’s so theres a clean slate for MariaDB

The below command will uninstall the MySQL RPM’s!

/scripts/check_cpanel_rpms –fix –targets=MySQL50,MySQL51,MySQL55

Create a yum repository for MariaDB

vi /etc/yum.repos.d/MariaDB.repo

place the following inside of it depending on the DISTRO (https://downloads.mariadb.org/mariadb/repositories/):

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/5.5.29/centos6-amd64/
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Remove php from the /etc/yum.conf file then run the following commands

yum install MariaDB-server MariaDB-client MariaDB-devel
/etc/init.d/mysql start
mysql_upgrade
/etc/init.d/mysql restart

Add php back to the /etc/yum.conf file to ensure future php updates don’t get clobbered

Rebuild easyapache/php to ensure modules are intact/working

/scripts/easyapache –build

 

Default Automatic index page when new account is created in cpanel/WHM

November 29th, 2013 No comments

Default Automatic index page when new account is created in cpanel/WHM

 

We all want to show default index page when new account is setup. Below are the steps:

First of all we have to create below  folder.

mkdir /root/cpanel3-skel

mkdir /root/cpanel3-skel/public_html

Create default index page.

vi /root/cpanel3-skel/public_html/index.html

save and quit the file.

 

If you want user have a customized .bashrc file for their SSH sessions then you can create it.

/root/cpanel3-skel/.bashrc

 

 

 

 

Categories: CPanel / WHM Tags:

How to Configure Multiple shared IP’s in WHM

November 29th, 2013 No comments

How to Configure Multiple shared IP’s in WHM

 

It is not possible to add multiple shared IP’s from WHM but it is possible to do it from SSH.

First of all we need to create a /var/cpanel/mainips/ directory if it is not present.

mkdir /var/cpanel/mainips/

Then we have to create a file.

vi /var/cpanel/mainips/root

Add all IP’s into it. save the file and quit.

121.127.250.152
121.127.250.153
121.127.250.154

Now login to WHM and check the IP’s

Home>>IP Functions>>Show/Edit Reserved IPs

 

Categories: CPanel / WHM Tags:
%d bloggers like this: