ndzlogo-1-1
Loading ...

INDIA – HEADQUARTERS

INDIA

UNITED STATES

CANADA

As we all know, the stable version of cpanel got changed to 58 which has easyapache4 integrated with it, by default. In this latest cPanel version, we cannot recompile apache/php by running the command “/scripts/easyapache”, as this command belongs to easyapache3, which is deprecated now. Here cPanel promotes the apache/php module installations via the front panel. Still we can install apache/php modules via command-line. Please go through my findings given here.

understanding-cpanel-easyapache-4

 

cPanel now builds RPM packages with binaries that get easily installed using yum, instead of taking the long route of compiling binaries from the source. So we can install apache/php modules simply by using yum command.

Also easyapache4 is using its own repository “/etc/yum.repos.d/EA4.repo” for apache/php related packages.

We can list the available packages using these commands.
———-
For apache related packages,
yum list available | grep ea-apache*

For php related packages,
yum list available | grep ea-php*

For example, if we need to install “remoteip_module” (it’s an apache module), please follow the steps given below.
——–
Step 1: Search for the module packages
#yum list available | grep ea-apache* | grep remoteip

Step 2: Install the resulted package using yum.
#yum install ea-apache24-mod_remoteip.x86_64

Step 3:
Open the configuration file “/etc/apache2/conf.modules.d/360_mod_remoteip.conf” and update the below lines. Please note, you need to replace the ‘server-ipaddress’ with the front-end server ipaddress.

# Enable mod_remoteip
LoadModule remoteip_module modules/mod_remoteip.so
RemoteIPHeader X-Forwarded-For
RemoteIPTrustedProxy 127.0.0.1 server-ipaddress

Step 4: Note that the client’s ipaddress passing to PHP will be correct now. But Apache continues to log the reverse proxy server ipaddress as the client ipaddress in domains access log.( This is actually a bug!). So We need to correct the log format in apache configuration. Update the lines,

LogFormat “%h %l %u %t \”%r\” %>s %b” common
LogFormat “%h %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined

to,

LogFormat “%a %l %u %t \”%r\” %>s %b” common
LogFormat “%a %l %u %t \”%r\” %>s %b \”%{Referer}i\” \”%{User-Agent}i\”” combined

Step5:  Restart apache service
#/etc/init.d/httpsd restart
——————
We can install  any available modules of apache/php by this method.

Now, regarding the custom modules, cPanel will not allow the conventional method of installation and we need to find out alternative ways. Here I’m illustrating how to configure ‘geoip’ in apache2.4. It is a custom module; the installation and its working is completely tested. 🙂

=============
Step1: Log in to your server via SSH.

Step2: Create the directory for saving Geoip database.
#mkdir /usr/share/GeoIP

Step3: Change the location to the newly created folder.
#cd /usr/share/GeoIP

Step4: Download and install GeoIP database.
#wget https://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz

Step5: Extract the downloaded  database file.
#gzip -d GeoIP.dat.gz

Step6: Install necessary packages related to apache24.
#yum install ea-apache24-devel.x86_64 ea-apache24-tools.x86_64

Step7: Download the custom mod_geoip module for cPanel.
#wget httpss://github.com/maxmind/geoip-api-mod_geoip2/archive/1.2.10.tar.gz

Step8: Extract the downloaded file.
#tar -xvf 1.2.10.tar.gz

Step9: Change the location to extracted folder.
#cd geoip-api-mod_geoip2-1.2.10/

Step10: Install geoip as a shared module
#apxs -i -a -L/usr/local/lib -I/usr/local/include -lGeoIP -c mod_geoip.c

Step11: Load and enable mod_geoip. Open the file ‘/etc/apache2/conf.modules.d/mod_geoip.conf’ and update the below lines.
LoadModule geoip_module /usr/lib64/apache2/modules/mod_geoip.so
GeoIPEnable On
GeoIPDBFile /usr/share/GeoIP/GeoIP.dat MemoryCache

Step12: Restart apache service
#/etc/init.d/httpsd restart
=============

Likewise, we can create custom profiles in easyapache4 based on our preferences or requirements. This profile must be a json file( EA3 saved custom profiles as .yaml files).

cPanel default profiles will be available in the folder ‘/etc/cpanel/ea4/profiles/cpanel/’. And hence, we can create custom profiles in this folder ‘/etc/cpanel/ea4/profiles/custom/’ as json files.

Please note that the syntax of json files should be correct, otherwise we will get error while doing the recompilation. Hence, it is better to create a  json file for the current settings and modify it according to our needs.
#/usr/local/bin/ea_current_to_profile –output=/etc/cpanel/ea4/profiles/custom/current.json

Now we can edit the file ‘etc/cpanel/ea4/profiles/custom/current.json’ according to our requirements.  For installing the new profile, use the below command.
#/usr/local/bin/ea_install_profile –install /etc/cpanel/ea4/profiles/cpanel/default.json

If the installation is fine, it will display the following message:
Finished Transaction
Leaving Shell

Note that easyapache4 allows to run multiple versions of PHP at the same time. We can select the default version of PHP by modifying the file ‘/etc/cpanel/ea4/php.conf’. Here we need to update the line “default:” with the required version of php and restart apache service.

Also there are some changes in the directory structure of apache in latest Cpanel. We can get the current structure from the configuration file ‘/etc/cpanel/ea4/paths.conf’ itself. I’m providing the details below for reference.
===============================================
dir_base=/etc/apache2
dir_logs=/etc/apache2/logs
dir_domlogs=/etc/apache2/logs/domlogs
dir_modules=/etc/apache2/modules
dir_run=/etc/apache2/run
dir_conf=/etc/apache2/conf.d
dir_conf_includes=/etc/apache2/conf.d/includes
dir_conf_userdata=/etc/apache2/conf.d/userdata
dir_docroot=/var/www/html
file_access_log=/etc/apache2/logs/access_log
file_error_log=/etc/apache2/logs/error_log
file_conf=/etc/apache2/conf/httpsd.conf
file_conf_mime_types=/etc/mime.types
file_conf_srm_conf=/etc/apache2/conf.d/srm.conf
file_conf_php_conf=/etc/apache2/conf.d/php.conf
bin_httpsd=/usr/sbin/httpsd
bin_apachectl=/usr/sbin/apachectl
bin_suexec=/usr/sbin/suexec
================================================

Reference:
httpss://confluence2.cpanel.net/display/EA4/EasyApache+4+Home
httpss://confluence2.cpanel.net/display/ALD/58+Release+Notes

 The article has been written by Geordin George