Thursday, August 24, 2017

cpanel autossl not working

Logs :

WARN The domain “redacted” failed domain control validation: The system

queried for a temporary file at “
href="http://redacted/2ECBADE46934FE927D361915199E5FDC.txt">http://abc

cted/2ECBADE46934FE927D361915199E5FDC.txt
”, but the web server

responded with the following error: 404 (Not Found). A
title="Domain Name System">DNS
or web server misconfiguration

may exist.


Edit .htaccess with following code-


RewriteEngine On
RewriteCond %{REQUEST_URI} !\.(txt|tmp)$

++++

Why is AutoSSL not working on cPanel?

One of the most common issues for cPanel users while activating AutoSSL is to find that the AutoSSL is not working at all, even if cPanel said it was finished.
There may be a few reasons on why your AutoSSL is not working, let’s explore each one of them:

1)  The domain failed domain control validation: The system queried for a temporary file at but the web server responded with the following error: 403 (Forbidden). A DNS or web server misconfiguration may exist. at bin/autossl_check.pl line 565.

This means AutoSSL verification script is not able to create a temporary file for the domain
To fix it, just try to assign 755 permissions and the correct owner to your public_html directory:
chmod 755 /home/user/public_html -v
chown user.user /home/user/public_html/ -R
Make sure you change user.user with your real cPanel user for that website.
And also check your .htaccess in case you have allow/deny directives that may be preventing the cPanel AutoSSL verification script to access your website.
That will do the trick and allow cPanel to write the temporary file.

2) The domain “mail.yourdomain.com” failed domain control validation: “mail.yourdomain.com” does not resolve to any IPv4 addresses on the internet. at bin/autossl_check.pl line 565.

There is a missing record for your mail.domain.com DNS record, just add a record to fix it.

3) Your domain doesn’t not resolve properly to the server.

As suggested by @tekgurl_kayla, make sure the domain resolves to the server & check redirects, too. Make sure you’re aware of the limits as well.

4) The certificate is not available. (processing)

You noticed this is ‘processing’, and in some cases that can take minutes (normal) or even hours, in this cases AutoSSL process is stuck and it continues to be unable to retrieve a valid AutoSSL certificate.
cPanel & WHM’s AutoSSL/SSL ordering process works on this way: cPanel system will automatically stop attempting to retrieve a certificate after 1 day (86400 secs), so if it hasn’t been completely issued within 24 hours, then it will be removed from the autossl queue.
When you find AutoSSL is not working, the first thing to do is to check the autossl logs, as you see in this image below:
Screenshot of AutoSSL Log Manager, the best tool to figure out why AutoSSL not working
Screenshot of AutoSSL Log Manager, the best tool to figure out why AutoSSL is not not working
Log for the AutoSSL run for “nixcp”: Saturday, February 11, 2017 4:25:39 AM GMT-3 (cPanel (powered by Comodo))[/B][/SIZE]
10:20:32 PM This system has AutoSSL set to use “cPanel (powered by Comodo)”.
10:20:32 PM Checking websites for “nixcp” …
10:20:32 PM The website “nixcp.com”, owned by “nixcp”, has no SSL certificate. AutoSSL will attempt to obtain a new certificate and install it.
10:20:33 PM The system will attempt to renew SSL certificates for the following websites:
10:20:33 PM nixcp.com (nixcp.com nixcp.org. [URL='http://www.nixcp.com']www.nixcp.com[/URL] [URL='http://www.nixcp.org']www.nixcp.org[/URL])
10:20:33 PM The system has completed the AutoSSL check for “cpaeltips.com”.
10:20:33 PM The system has finished checking 1 user.
The following script runs every 5 minutes, you can run it manually to see what’s going on and get your SSL processed:
/usr/local/cpanel/bin/autossl_check_cpstore_queue
After running this script, it will try to force a queue run for your pending autossl requests. The result may look similar to this:
[root@server.nixcp.com:~]/usr/local/cpanel/bin/autossl_check_cpstore_queue
Polling for “user1”’s new certificate for “yoursite.org” (order item ID “113902861”) … The certificate is available. The system will now attempt to install it. The certificate is now installed!

Polling for “user2”’s new certificate for “yoursite2.com” (order item ID “113902877”) … The certificate is available. The system will now attempt to install it. The certificate is now installed! [root@server.nixcp.com:~]
If you still have problems and your autossl not working after running that script, check out this post on cPanel forums, or contact your hosting provider for support.

Saturday, February 11, 2017

Find List of email ids belong to all domains exist in cpanel server

Unfortunately there is no built-in way in WHM/cPanel to list every POP3/IMAP account for every domain in one listing, however, using the command line and our built-in API system, you can run a query to list true email accounts:

1. as root change to /var/cpanel/users
# cd /var/cpanel/users

2. run the following one-line query against our API system:

# for file in *; do whmapi1 list_pops_for user=$file 2>/dev/null | grep \@ | grep -F @; done

This will result in an output such as:

root@server [/var/cpanel/users]# for file in *; do whmapi1 list_pops_for user=$file 2>/dev/null | grep \@ | grep -F @; done
- a@domain1.com
- x@domain1.com
- belle@domain2.com
- brian@domain3.com
- demos@domain3.com
- greypromo@domain3.com
- info@domain4.com
- kage@domain5.com
- news@domain6.com
- release@domain6.com
- sales@domain6.com

and so forth. These are all of the true email accounts on for every domain on your server.

Hope this information helps!

Friday, February 10, 2017

Tomcat/java



How to check java/tomcat version on cpanel 


+++
[root@ns1 /]# /etc/init.d/tomcat version

Server version: Apache Tomcat/7.0.65
Server built:   Jan 6 2016 18:50:03 UTC
Server number:  7.0.65.0
OS Name:        Linux
OS Version:     2.6.32-573.26.1.el6.x86_64
Architecture:   amd64
JVM Version:    1.7.0_101-mockbuild_2016_04_21_13_21-b00
JVM Vendor:     Oracle Corporation
++++


Below is the code for test.jsp   testing script when java/tomcat is enabled on server.


++++

    Test JSP page
   
       

Working JSP page!


        This is a page to verify that .jsp support has been enabled


       
           
               
               
           
           
               
               
           
           
               
               
           
           
               
               
           
       
Date:<%= new java.util.Date() %>
Remote Address:<%= request.getRemoteAddr() %>
Request Method:<%= request.getMethod() %>
Servlet Path:<%= request.getServletPath() %>

   

++++

htaccess code 


As the servlet mapping only works on port 8080 and doesn't work on the Apache mod_jk proxy on port 80, we have to add below two lines needed for these to work with Apache into the user's .htaccess file at /home/user/public_html location:


+++
SetHandler jakarta-servlet
SetEnv JK_WORKER_NAME ajp13
+++

Script to print tomcat version 


++++++++++++++
[root@ns1 public_html]# cat version.jsp

Server info: <%= application.getServerInfo() %>

Servlet version: <%= application.getMajorVersion() %>.<%= application.getMinorVersion() %>

JSP version: <%= JspFactory.getDefaultFactory().getEngineInfo().getSpecificationVersion() %>

Java version: <%= System.getProperty("java.version") %>
++++++++

You can view this script using http://website/version.jsp

Check Inode usage

You can check Inode usage using below script.

echo "Detailed Inode usage for: $(pwd)" ; for d in `find -maxdepth 1 -type d |cut -d\/ -f2 |grep -xv . |sort`; do c=$(find $d |wc -l) ; printf "$c\t\t- $d\n" ; done ; printf "Total: \t\t$(find $(pwd) | wc -l)\n"

add googlebot in csf

How to allow googlebot in CSF



Add below entries in /etc/csf/csf.rignore

.googlebot.com
.crawl.yahoo.net
.search.msn.com
.search.msn.com
.configserver.co.uk
.configserver.com
.aws.amazon.com

save this file and restart csf service.

Tuesday, January 31, 2017

INSTALL MYSQL 5.7 ON CPANEL SERVER

CPanel and WHM have been leaning towards support of MariaDB over other flavors. This is partly due to the upstream repos replacing the MySQL package with MariaDB (for example, on CentOS).
MySQL 5.6 is still supported though, which means they are keeping support for core MySQL products. But if you want to get some extra performance enhancements or enterprise features for free, without getting too many bells and whistles, you might want to install Percona Server.
I’ve done this work on a new dedicated server with the latest WHM and CPanel on CentOS 7, with MySQL 5.6 installed. Besides the backup, this is a fairly quick process.
It’s pretty simple. From the Percona Server for MySQL 5.7 installation doc, we can get the YUM repo. (Run commands as root if you can, otherwise as sudo.)

1

yum install http://www.percona.com/downloads/percona-release/redhat/0.1-3/percona-release-0.1-3.noarch.rpm
Now that we have the repo, let’s install Percona XtraBackup in case we need to roll this back at any point:
This server had a drive mounted at /backup, so I created the backup with the following commands:
Now that we have a good backup, let’s remove MySQL:
Depending on your dependency chain, this could remove Percona XtraBackup, but that can be fixed. Let’s accept this uninstall.
Let’s install Percona Server for MySQL 5.7 and Percona Toolkit:
Now that it’s installed ensure the mysql service is running. If it isn’t, start it. Now let’s upgrade:
NOTE. This works if you can log in as root without a password; if you can’t, you will need to specify the -u and -p flags.
Once you run the upgrade, restart the mysql service:
And there you go, you are now running on Percona Server for MySQL 5.7. If your managed providers tell you it’s not supported, don’t worry! It works as long as CPanel supports MySQL 5.6.
If you have any issues, just restore the backup.
NOTE: One thing to keep in mind is that 5.7 breaks CPanel’s ability to create users in MySQL. I believe this is due to the changes to the mysql.user table. If this is an issue for you, you can always use Percona Server for MySQL 5.6.

Wednesday, December 28, 2016

check envtype on cpanel server

check envtype on cpanel server -(vmware or virtuozzo)

root@host [~]# cat /var/cpanel/envtype
vmware
root@host [~]#

Thursday, December 15, 2016

How to change PHP Handler in cPanel EasyApache 4

A PHP handler defines the method that Apache uses to communicate with your PHP scripts. By default, cPanel & WHM offers four PHP handlers – SuPHP, DSO, FastCGI and CGI. Each handler differs in its files and implementation. This affects Apache’s performance because it determines how Apache serves PHP. So, in this tutorial, we will see in detail about how each of these handlers function and how to change PHP Handler in cPanel EasyApache 4.

PHP Handlers

SuPHP

SuPHP requires mod_suphp Apache module. It offers maximum security for the scripts and runs the scripts as the owner of the script. It is technically a CGI module with high security.
The main disadvantage of suPHP is speed and CPU load. suPHP runs much slower than the other handlers, and you will see a significant increase in your overall CPU load when switched to it. It also does not support Opcode caching likeeAccelerator, APC, Memcached etc.

DSO

The DSO handler requires the MPM Prefork Apache module. PHP applications execute as the nobody user when you use the DSO PHP handler unless you use the mod_mpm_itk or mod_ruid2 Apache modules. The major benefits of DSO are speed and the ability to use opcode caching like eAccelerator, APC, Memcached etc.

FastCGI

FastCGI serves PHP applications through the mod_proxy_fcgi Apache module. This method is faster than SuPHP, but may require changes to the FastCGI directives to work efficiently. With SuExec enabled, FastCGI runs PHP scripts as the user (like SuPHP). It also provides enhanced security compared with DSO. The Main disadvantage of FastCGI is high memory usage. This is because FastCGI keeps PHP sessions opened in the background in memory for quicker access and this allows you to use an opcode caching extension such as eAcceleartor or APC with it to increase performance.

CGI

CGI stands for Common Gateway Interface. As the name implies it executes PHP applications through the mod_cgi or the mod_cgid Apache modules. It is highly configurable. However, It is also slow and insecure. Hence not recommended to use.

How to change PHP Handler in cPanel EasyApache 4


*GUI METHOD

cPanel EasyApache 4 provides a very cool interface to change the PHP Version and PHP Handler.
1) Move to WHM >> Home >> Software >> MultiPHP Manager >> PHP Handlersphp_handler2) Click on the edit button of the particular PHP version for which you need to change the PHP Handler. php_handler_save3) Select the proper PHP handler and Click on Apply button to save the changes.
Note: If you couldn’t find any of the PHP Handlers in the list, you can easily install it from cPanel WHM >> Home >> Software >> EasyApache 4 or via command line using “yum install module_name”.
The module details are given in the table below.
PHP HandlerModule Name
CGIea-apache24-mod_cgi or
ea-apache24-mod_cgid
FastCGIea-apache24-mod_proxy_fcgi
SuPHPea-apache24-mod_suphp
DSOea_php5x_php

command line:

Check the current PHP configuration of your server:
You can check the current PHP configuration using the following script:

/usr/local/cpanel/bin/rebuild_phpconf --current
Sample output:
DEFAULT PHP: ea-php56
ea-php55 SAPI: suphp
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp

Check the available PHP handlers on your cPanel server:
To check the available PHP handlers on the cPanel server, please use the option “–available”
Eg:
[root@cpaneltest ~]# /usr/local/cpanel/bin/rebuild_phpconf --available
ea-php55: cgi none suphp
ea-php56: cgi dso none suphp
ea-php70: cgi none suphp

Change the PHP Handler associated with a particular PHP version:
Use the following command to change the PHP handler associated with a PHP version.
/usr/local/cpanel/bin/rebuild_phpconf --$package=$handler
Where,
$package : represents the name of the PHP package that you want to change and
$handler : represents the PHP handler that you wish to use.
Eg:
[root@cpaneltest ~]# /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php55 SAPI: suphp
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp
Here, the current PHP Handler associated with PHP version 5.5 is SuPHP.
We can now check the available PHP handlers on this cPanel server.
[root@cpaneltest ~]# /usr/local/cpanel/bin/rebuild_phpconf --available
ea-php55: cgi none suphp
ea-php56: cgi dso none suphp
ea-php70: cgi none suphp
Above details shows that the other PHP handler available on the server for PHP 5.5 is CGI. So, in this example we will change the PHP handler of PHP version 5.5 from SuPHP to CGI using the command given below.
[root@cpaneltest ~]# /usr/local/cpanel/bin/rebuild_phpconf --ea-php55=cgi
Check and verify the new PHP configuration using:
[root@cpaneltest ~]# /usr/local/cpanel/bin/rebuild_phpconf --current
DEFAULT PHP: ea-php56
ea-php55 SAPI: cgi
ea-php56 SAPI: cgi
ea-php70 SAPI: suphp
That’s it. We are done.

Friday, November 25, 2016

E-mail usage seems to show incorrectly in cPanel

Try running /scripts/generate_maildirsize on the affected account.
The syntax would be:

Code:

# /scripts/generate_maildirsize --confirm --allaccounts --verbose $USER

Replace $USER with the actual cPanel account username (the cPanel user, not the DOMAIN ).

If this does not help, log out of cPanel and delete the email_accounts.yaml and email_accounts.cache files from the cPanel account's .cpanel directory. The files will automatically be created the next time you log into cPanel.

If neither of these actions solves the problem, please submit a ticket so that we may look at your server directly.

LITESPEED INSTALLATION ON CPANEL SERVER

LITESPEED INSTALLATION ON CPANEL SERVER


Purpose:LiteSpeed Web Server is a high-performance web server that is an alternative to Apache, yet fully compatible with existing Apache configuration files. It is very well suited to high traffic websites, and those that use a large number of scripts.

Overview
cPanel officially supports LiteSpeed Web Server use through our WHM Plugin. The WHM Plugin is our longest running control panel plugin. It includes all the basic plugin features as well as some cPanel-exclusive features.


Prerequisites

1. This auto-installer can only be used for cPanel/WHM installations.
2. Make sure beforehand that all sites are working fine with Apache.
3. PHP must have been built with EasyApache. LiteSpeed will build its matching PHP (with LSAPI)         based on this build of PHP.
4. This only works with LiteSpeed Enterprise Edition, you need a trial key or an Enterprise         License serial number.


Step 1: Install LiteSpeed WHM plugin


Run the following commands from ssh as root

cd /usr/src; curl http://www.litespeedtech.com/packages/cpanel/lsws_whm_plugin_install.sh | sh

Step 2: Install LiteSpeed Speed Web Server from within WHM

1. Click the “LiteSpeed Web Server” plugin. (In the “Plugins” section at the bottom of the         scroll menu)
2. Click “Install LiteSpeed Web Server”
3. Fill in the form to specify
Trial license key or serial number
LiteSpeed target installation directory
Port Offset (set to 0 to replace Apache otherwise set a number like “2000” for example to         try LiteSpeed on port 2080)
Whether to enable PHP SuEXEC
Your Administrators email address.
Username and password for LWSW WebAdmin Console
4. Click “Next” to install LiteSpeed


Step 3: Config PHP


For EA4, Plugin will handle it through script
Our plugin will detect the right configuration and correct them when needed. You don't need to build matching PHP any more.
For EA3, Build matching PHP binary
LSWS comes with a pre-built PHP 4 binary. However, you should build your own PHP binary using configuration options matching those used by Apache mod_php.
Then, click “Build Matching LSPHP”. This step will take a while.
NOTE:If you see one of the below error messages when running “Build Matching LSPHP”, try increasing “Max cPanel process memory (minimum: 512)” in the side menu under Server Configuration » Tweak Settings to at least 512MB.
Found Errors

ERROR: /usr/local/bin/php -i returns 6

You can try to build matching PHP from command line:
"/usr/local/cpanel/whostmgr/cgi/lsws/cmd_buildmatchingphp.sh"
Or
Found Errors

ERROR: /usr/local/bin/php -i returns 134

You can try to build matching PHP from command line:
"/usr/local/cpanel/whostmgr/cgi/lsws/cmd_buildmatchingphp.sh"


Step 4: Start LiteSpeed again

Click “Restart LiteSpeed”.
You can now verify if everything is working as expected. It should be!
You can now replace Apache with LiteSpeed Web Server. Click “Change Port Offset” and set the value to 0 if you had not done so previously. Click “Switch to LiteSpeed” and that's it!

WARNING: Do NOT uncheck the “Apache Web Server” (httpd) service under WHM's service manager. If you do this WHM will not restart LiteSpeed automatically when configuration changes have been made.

Note: To uninstall WHM LiteSpeed plugin, run the following command:

/usr/local/cpanel/whostmgr/docroot/cgi/lsws/lsws_whm_plugin_uninstall.sh

How to install Python 2.7 or Python 3.x + Django 1.8 + on CentOS 6 + cPanel

Python is one of the core packages that comes by default with CentOS Linux. However, it is not updated at all on CentOS 6.x, the default version is 2.6.6, which is a little bit old for the current dev requirements when you are building a web app based on this language.
If you need to install Python 2.7 or 3.x versions on CentOS 6, there is one way to install this alternatives without breaking the default Python version, which is widely used by the OS and its tools like yum/dnf.
This may work on CentOS plain servers, but also on cPanel servers.

3 steps to Install Python 2.7 and Django on CentOS 6

1) Get latest Python 2.7.x version
Extract, configure, compile and install.
In the last step make sure you run: make altinstall, to avoid any conflicts with the default CentOS python version.
mkdir /root/temp && cd /root/temp
wget http://python.org/ftp/python/2.7.10/Python-2.7.10.tgz
tar -xvpzf Python-2.7.10.tgz
./configure
cd Python-2.7.10
./configure
make
make altinstall
At this point you should be able to execute python 2.7.x using this binary:
/usr/local/bin/python2.7
or simply:
python2.7
Now that we have Python 2.7 working, let’s get PIP to install some additional modules:
2) Install PIP
PIP is the right tool to manage and install python packages, make sure you run the installer calling the python2.7 binary.
cd /root/temp
wget https://bootstrap.pypa.io/get-pip.py
/usr/local/bin/python2.7 /root/temp/get-pip.py 
3) Install Django 1.8
Django is one of the most popular Python frameworks. Let’s use PIP to install Django 1.8.x.
pip2.7 install Django==1.8.3
Need to Install additional Python modules?
Let’s use pip too, as easy as it looks:
pip2.7 install django-debug-toolbar
pip2.7 install django-smart-selects
pip2.7 install mysqlclient
pip2.7 install Pillow
pip2.7 install python-dateutil
pip2.7 install PyYAML
Repeat the same procedure for all the python/django modules you need.
That’s all. At this point you should have two Python versions, the default from CentOS and the alternative we installed. 

command to check swap utilization

for file in /proc/*/status; do awk '/VmSwap|Name/{printf $2 " " $3}END{print ""}' $file; done | less

Tuesday, March 17, 2015

Disable cphulked

1)Get the console
2)connect to mysql and execute following commands-

3)
#mysql

mysql> connect cphulkd

mysql> delete from brutes;
Query OK, 0 rows affected (0.00 sec)

mysql> delete from logins;
Query OK, 32 rows affected (0.00 sec)


4)After that you can disable cphulked with following command.

#/usr/local/cpanel/etc/init/stopcphulkd

Wednesday, February 18, 2015

exim port check

While checking the exim logs if you are getting "timeout" error then you should check the port  as below -

1) IN to OUT port check-

[root@ns1 ~]# telnet mail.xxx.com 25
Trying 1.2.3.4...
Connected to mail.xxx.com.//you will get time-out here
Escape character is '^]'.
220 host.xxx.net ESMTP Postfix

2)Out to IN port check
check with url http://ping.eu

3)Make sure the ports 25,465,587,110 are open for server x.x.x.x on both side. 

check mysql processes in plesk

check mysql processes in plesk
mysql -uadmin -p`cat /etc/psa/.psa.shadow` -e 'show processlist' 

find and delete script command

1)find /home/username/mail/new -name "123*" -exec rm -fv {} \;

Replace the "123*" entry with a prefix of what your files within this directory start with. This is a safeguard so you do not use the command incorrectly and delete files you are not supposed to. Ensure you are careful with the directory that you enter in this command because we do not generally recommend mass deletion of files.


2)find  ~/user/images/* -maxdepth 1 -type f | wc -l  
It will show you the count of images present under specified folder.

3)find /newdata/active_images/images -type f -iname "*.jpg"
output =>
/newdata/active_images/images/9780548358559.JPG
/newdata/active_images/images/9781240551071.jpg
/newdata/active_images/images/9781286130742.jpg

3) root@host [/newdata/active_images]# cat rm.php
// Specify the target directory and add forward slash
$path = "images/";
// Loop over all of the files in the folder
foreach(glob($path ."*") as $file) {
    unlink($file); // Delete each file through the loop
}
?>

=> This script delete all files present under image folder.

Exim commands

# List all queued messages, grouped by sender address
exim -bpr | grep -Eo "<[^ ]*@[^ ]*>" | sort | uniq -c

# List all queued messages, grouped by recipient address
exim -bpr | grep -Eo "^\s*[^ ]*@[^ ]*$" | sort | uniq -c

# Remove all messages older than 12hrs (43000 seconds)
exiqgrep -o 43000 -i | xargs exim -Mrm

# Remove all frozen messages from the queue
exiqgrep -z -i | xargs exim -Mrm

# Remove all messages from a particular sender
exiqgrep -i -f [user]@domain.com | xargs exim -Mrm

# Remove all messages from a sender that are older than 12hrs
exiqgrep -o 43000 -i -f [user]@domain.com | xargs exim -Mrm

cpanel required ports

If your server is having cpanel , you should open following ports in firewall
---
20,21,25,26,43,53,80,110,143,443,465,873,993,995,2083,2082,2086,2087,2095,2096,3306,2089
--

not able to sent mail

Not able to send mails to particular email id only x@xxx.com  and getting following logs -

2015-02-17 15:23:39 [3230] 1YNeqU-0000q1-No ** x@xxx.com F= P= R=dkim_lookuphost T=dkim_remote_smtp: SMTP error from remote mail server after initial connection: host x1x.xxx.com [192.8.186.129]: 554 x1x.xxx.com

Solution -
1)check hostname file.
2)Make sure that you have setup RDNS for the MX record.

Recursive chmod

Recursive chmod within folder:

For suphp you should have 644 permissions to all file and 755 permission for directories.
If not then you can modify it with below commands -
--------------------------------------------
find . -type f -exec chmod 0644 {} \;

find . -type d -exec chmod 0755 {} \;
--------------------------------------------