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