⭐ If you would like to buy me a coffee, well thank you very much that is mega kind! : https://www.buymeacoffee.com/honeyvig Hire a web Developer and Designer to upgrade and boost your online presence with cutting edge Technologies
Showing posts with label cPanel. Show all posts
Showing posts with label cPanel. Show all posts

Friday, September 27, 2013

Custom php.ini settings for PHP FCGI

If you want to enable custom php.ini settings for PHP FCGI on your server then follow the below steps :
1. Create a .htaccess file under the directory : /home/username/public_html
cd /home/username/public_html
vi .htaccess
Add the below two lines at the top :
AddHandler php5-fastcgi .php
Action php5-fastcgi /cgi-bin/php.fcgi
save and quit.
2. Go to the cgi-bin directory : /home/username/public_html/cgi-bin
cd /home/username/public-html/cgi-bin
and then copy the default php.ini here
cp /usr/local/lib/php.ini /home/username/public_html/cgi-bin/
3. Create php.fcgi file to load custom php.ini
Please note that you should still be in /home/username/public_html/cgi-bin location.
vi php.fcgi
and then add the below code :
#!/bin/sh
export PHP_FCGI_CHILDREN=1
export PHP_FCGI_MAX_REQUESTS=0
exec /usr/local/cpanel/cgi-sys/php5
save and quit.
Now make the file php.cgi executable:
chmod + x php.fcgi
4. Change ownership of files to correct user:
chown username.username * -R
And if it still does not work for you then follow the below steps as well :
5. Add paths to php.conf file
vi /usr/local/apache/conf/php.conf
and add the below lines :
Action php5-fastcgi /cgi-bin/php.fcgi
AddType application/x-httpd-php .php
save and quit.
and after adding the above two lines the php.conf file should look like this :
root@server[/usr/local/apache/conf] # cat php.conf
# Fastcgi configuration for PHP5
LoadModule fcgid_module modules/mod_fcgid.so
MaxRequestsPerProcess 500
AddHandler fcgid-script .php5 .php4 .php .php3 .php2 .phtml
Action php5-fastcgi /cgi-bin/php.fcgi
AddType application/x-httpd-php .php
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php5
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php4
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php3
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .php2
FCGIWrapper /usr/local/cpanel/cgi-sys/php5 .phtml
# End of autogenerated PHP configuration.
6. Distill and rebuild Apache, then restart Apache
/usr/local/cpanel/bin/apache_conf_distiller –update
/scripts/rebuildhttpdconf
/etc/init.d/httpd restart

Monday, September 9, 2013

How to block emails from a specific address using Exim

Issue :
How to block emails from a specific address on a cPanel/WHM server using Exim ?
Solution :
This is fairly easy to achieve with Exim.
First you’ll need to find the system filter file for Exim. This can be found out through WHM >> Main >> Service Configuration >> Exim Configuration Editor.
Towards the middle of the page, under the section ‘Filters’ , you ‘ll find the path to the file.
Open that file via SSH using your favorite editor and add the following to it :
if first_delivery
and ( (“$h_from:” contains “emailtoblock@domainname.com”)
)
then fail
endif

Monday, July 22, 2013

Exim Remove All messages From the Mail Queue

Question:

 I'm using Exim mail server under CentOS Linux. How do I remove all messages from the Exim mail queue using a shell prompt?

Answer:
Exim is a mail transfer agent (MTA) used on Unix-like operating systems. It aims to be a general and flexible mailer with extensive facilities for checking incoming e-mail.

To print a list of the messages in the queue, enter:

# exim -bp

To remove a message from the queue, enter:

# exim -Mrm {message-id}

To remove all messages from the queue, enter:

# exim -bp | awk '/^ *[0-9]+[mhd]/{print "exim -Mrm " $3}' | bash
Dallas Marlow, suggested following clean command:
# exim -bp | exiqgrep -i | xargs exim -Mrm
DELETE FROZEN MAILS
/usr/sbin/exim -bp | awk '$6~"frozen" { print $3 }' | xargs /usr/sbin/exim -Mrm
REMOVE MAILS FROM SENDER
/usr/sbin/exiqgrep -i -f (MAIL ADDRESS HERE) | xargs /usr/sbin/exim -Mrm 
OR 
/usr/sbin/exim -bp | awk '$4~"info@domain.com" { print $3 }' | xargs /usr/sbin/exim -Mrm

Saturday, April 27, 2013

What are Core Dumps?

What are Core Dumps?

Core dumps are files the system creates when a process running in memory does not finish. The portion of memory that the process was using is then dumped to a file. This can be quite helpful when debugging your scripts. Core dumps typically have a file name like: core.5876
Reviewing Core Dump Files on VPS or Dedicated Servers

For most users, getting usable information from a core dump file can be difficult. If you are a VPS or Dedicated customer with command line (shell) access, most of the information in the core dump can be found by running either one of these two commands:

gbd -c core.####

strings core.####
Reviewing Core Dump Files on Shared Servers

If you are on a shared hosting package, for security reasons you do not have access to the command line. For our shared customers, we've created a basic PHP script that uses the commands above to allow you to find any core dump files in your account. The script can be found here:

http://inmotionhosting.com/support/files/scripts/coredumpcheck.txt

    Upload the coredumpcheck.txt file to the folder where you want to view core dumps.
    Rename the file to coredumpcheck.php
    Access coredumpcheck.php file in your browser. For example, if you have core dumps in your public_html folder then you would go to http://yourdomain.com/coredumpcheck.php
    The script will list all the core dumps in the current directory. Click any of the file names to view more details about the core dump.
    Look under the "RUNNING: gdb -c core.30387" heading to find the script that is causing the problem. It will look something like:

    Core was generated by '/usr/bin/php /home/training/public_html/t2c_escalation/escalatet2s.php'.


Resolving Core Dumps

Core dumps are advanced in nature. It's best practice to contact your web developer with the information that you have using the coredumpcheck.php script. If you are using a CMS such as WordPress, Joomla, or Drupal and the core dump is being caused by a plugin or module, your can disable or remove that module to resolve the issue.

Monday, March 11, 2013

Locations of Common Log Files on cPanel Servers

Apache

Apache is the web server that is typically utilized by cPanel.  On cPanel servers Apache does write to a rather high number of logs as each site has its own traffic log.


    /usr/local/apache/logs/access_log

The access_log is used to log all http requests to ether the hostname of the server, requests directed at the servers IPs, or sites that resolve to the server but are no longer hosted on it.

    /usr/local/apache/logs/error_log

On cPanel servers all Apache errors, regardless of site, are logged in the error_log.

    /usr/local/apache/domlogs

Within the domlogs folder each site on the server will have its own log file.  These files will be the fully qualified domain name for the domain, ie domain.com, liquidweb.com.  All http traffic to a site will be logged in this log file.

Exim

Exim is the MTA(Mail Transfer Agent) that cPanel utilizes.  Exim has three primary logs, but only two of these logs contain useful information

    /var/log/exim_mainlog

The exim_mainlog contains ALL interactions that exim handles, so both incoming and outgoing mail transactions.

    /var/log/exim_rejectlog

The exim_rejectlog contains all connection attempts that were denied.  This information is also logged in the exim_mainlog.

For more information on Exim’s logs try a Google search for “Exim Cheat Sheet”.

cPanel

Cpanel does log all http traffic to WHM, webmail, and cPanel access.  All cPanel logs are located in the /usr/local/cpanel/logs directory.

    /usr/local/cpanel/logs/access_log

This access_log contains all traffic to WHM, cPanel, and webmail over http.

    /usr/local/cpanel/logs/error_log

This error_log contains all errors that occur when accessing a cPanel related site over http or https.
FTP

Regardless of FTP deamon in use, cPanel does log connections, uploads, and downloads.  However, FTP does not have its own log file it is instead threaded into the systemside messages log file.

    /var/log/messages

All FTP transactions are recorded in messages.  They are however interwoven with all over system messages that are logged in this file.

Tuesday, February 19, 2013

How To Install And Configure Advanced Policy Firewall (APF)

This tutorial explains how you can install and configure APF - an interface to IPTables which lets you easily configure a full featured firewall to secure servers and workstations connected to a network. This guide describes an example installation on a server with cPanel but it's only a matter of port numbers which must be open for everything to work. APF can be used on any system.
The makers of cPanel recommend CentOS to be the base for their software. That's why I've used this distribution for my example. Any distribution with IPTables will do.
From Advanced Policy Firewall's website:
"Advanced Policy Firewall (APF) is an IPTables(Netfilter) based firewall system designed around the essential needs of today's Linux servers. The configuration is designed to be very informative and easy to follow. The management on a day-to-day basis is conducted from the command line with the 'apf' command, which includes detailed usage information on all the features."

Installation

We will begin with downloading and extracting the archive with APF:

wget http://www.rfxn.com/downloads/apf-current.tar.gz
tar -zxvf http://www.rfxn.com/downloads/apf-current.tar.gz
cd apf-9.7-1

and installing it:

sh ./install.sh

After the installation finishes APF will display locations of it's executable and configuration files as well as ports detected as being used on our system. You have to verify that the numbers are correct to avoid mistakes.

More information about ports used by cPanel can be found here: http://docs.cpanel.net/twiki/bin/view/AllDocumentation/AllFAQ/LinuxFAQ#Which_ports_should_be_open_if_I


Configuration

APF's basic configuration file is /etc/apf/conf.apf so we edit it like this:

nano -w /etc/apf/conf.apf

The configuration file is pretty well commented so it's not hard to understand which options are responsible for certain functions. What You should remember is that by default everything is locked and You have to configure APF to open ports You need to use.

Let's get to work!

DEVEL_MODE="1" - be sure to set this option to 1 until You're satisfied with the settings.
Development mode sets a cron job to deactivate APF every 5 minutes. This really lets You install it on a remote machine without the risk of cutting Yourself out.

SET_MONOKERN="0" - APF supports monolithic kernels. If IPTables was not compiled as a module (APF then complains about IPTables even without setting up a firewall for example: Starting APF:Unable to load iptables module (ip_tables), aborting.)

IFACE_IN="eth0" and IFACE_OUT="eth0" - untrusted interfaces connected to the network, mostly the Internet

IG_TCP_CPORTS="20,21,22,25,26,37,43,53,80,110,113,143,443,465,873,993,995,2077,2078,2082,2083,2086,2087,2095,2096,3306,6666" - inbound TCP ports to open

IG_UDP_CPORTS="53,6277" - inbound UDP ports to open

IG_ICMP_TYPES="3,5,11,30" - inbound ICMP port numbers. I've removed ports 0 and 8 so the server won't answer any pings, what partially hides it on the network. Leave them in place if You or Your datacenter is using ping packets (ex. network monitoring).

EG_TCP_CPORTS="21,25,37,53,80,110,113,#123,443,43,873,953,2089,2703" - outbound TCP ports to open. At this point by blocking certain services like SSH we gain the possibility of stopping hackers that would break into our system and want to connect to other servers
EG_UDP_CPORTS="20,21,53,873,953,6277" - outbound UDP port numbers

TCP_STOP="DROP" - defines a reaction in case of TCP connections that violate the rules

UDP_STOP="DROP" - defines a reaction in case of UDP connections that violate the rules

ALL_STOP="DROP" - defines a reaction to any other connections

We can send a TCP/IP reset (RESET), drop the packet without answering (DROP), reject it (REJECT) or send icmp-host-prohibited answer (PROHIBIT) in case of UDP.

BLK_PRVNET="1" - blocks all private ipv4 addresses. If Your machine is behind NAT then set this to 0

It's worth spending some more time to get familiar with more configuration options as APF is very feature rich.


Testing

Keeping in mind the DEVEL_MODE option we start APF like that:

/usr/local/sbin/apf -s

We can use the following parameters:

-s - start APF

-r - restart APF

-f - stop APF

-l - list statistics

-st - status of APF

-a host - allow connections from "host"

-d host - deny connections from "host"

Now we can test our firewall with a port scanner like nmap or any other tool. If we run into any problems we will be able to fix it remotly because Cron will flush the rules every 5 minutes.


Final Preparation

Now that we are sure that the firewall is working and isn't blocking ports that we need, we can change DEVEL_MODE="1" option in the configuration file to 0 and restart APF.

Next we make sure APF is started at boot time, so using setup command we go to System Services, tick APF and save the settings. After restarting the system APF should start automatically.


Links

    CentOS - http://www.centos.org
    Advanced Policy Firewall - http://www.rfxn.com/projects/advanced-policy-firewall
    cPanel - http://www.cpanel.net

Friday, February 15, 2013

Install ConfigServer Apps On A cPanel/WHM Server

ConfigServer provide a range of paid and free applications, including a significantly more advanced firewall, that plug directly into WHM on your cPanel server. These applications are highly recommended for anyone who is serious about the security of their cPanel Server, as they not only provide enhanced security functionality, but also allow you to easily manage a number of other basic cPanel functions, such as mail settings, mail queues, and a more advanced ModSecurity tool.
Below is a list of the free applications that we will be providing the simple installation instructions for:
  1. CSF - this is an advanced firewall system utilising Linux ip tables
  2. Mail Manage – allows you to adjust mail settings, such as hourly limits and email forwarders, on a per account basis
  3. Mail Queues – easily manage your email queues with the ability to force run the queue and delete stuck messages
  4. ModSecurity Control – if you have installed ModSecurity on your cPanel Server, this provide an advanced management interface
  5. Explorer – This is a file system explorer web interface which allows you to also run basic shell commands within folders – WARNING: While this utility can be very useful it is also very dangerous indeed. You can easily render your server inoperable and unrecoverable by performing ill advised actions. No warranty or guarantee is provided with the product that protects against system damage.
NOTE: All of the installations below require you to be logged into SSH as root.
Install ConfigServer Security & Firewall
rm -fv csf.tgz
wget http://www.configserver.com/free/csf.tgz
tar -xzf csf.tgz
cd csf
sh install.sh
Remove installation files:
cd ..
rm -Rfv csf/ csf.tgz
Install ConfigServer Mail Manage
rm -fv cmm.tgz
wget http://www.configserver.com/free/cmm.tgz
tar -xzf cmm.tgz
cd cmm
sh install.sh
Remove installation files:
cd ..
rm -Rfv cmm/ cmm.tgz
To uninstall:
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/addon_cmm.cgi
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/cmmversion.txt
rm -Rfv /usr/local/cpanel/whostmgr/docroot/cgi/cmm/
Install ConfigServer Mail Queues
rm -fv cmq.tgz
wget http://www.configserver.com/free/cmq.tgz
tar -xzf cmq.tgz
cd cmq
sh install.sh
Remove installation files:
cd ..
rm -Rfv cmq/ cmq.tgz
To uninstall:
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/addon_cmq.cgi
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/cmqversion.txt
rm -Rfv /usr/local/cpanel/whostmgr/docroot/cgi/cmq/
Install ConfigServer ModSecurity Control
rm -fv cmc.tgz
wget http://www.configserver.com/free/cmc.tgz
tar -xzf cmc.tgz
cd cmc
sh install.sh
Remove installation files:
cd ..
rm -Rfv cmc/ cmc.tgz
To uninstall:
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/addon_cmc.cgi
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/cmcversion.txt
rm -Rfv /usr/local/cpanel/whostmgr/docroot/cgi/cmc/
Install ConfigServer Explorer
rm -fv cse.tgz
wget http://www.configserver.com/free/cse.tgz
tar -xzf cse.tgz
cd cse
sh install.sh
Remove installation files:
cd ..
rm -Rfv cse/ cse.tgz
To uninstall:
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/addon_cse.cgi
rm -fv /usr/local/cpanel/whostmgr/docroot/cgi/cseversion.txt
If you run into any issue with the install, just head over to the ConfigServer forums and you’ll find plenty of people who can assist you.

Monday, February 4, 2013

How to install Linux Malware Detect (LMD)

How to install Linux Malware Detect (LMD)


Maldet also known as Linux Malware Detect virus scanner for Linux.

Download the tar file using the below link:

    wget http://www.rfxn.com/downloads/maldetect-current.tar.gz

Extract the file using the below command

    tar -xzf maldetect-current.tar.gz

go to the maldet folder

    cd maldetect-*

Now, run the below command to install maldet.

    sh ./install.sh or sudo sh ./install.sh

It will give below output

    Linux Malware Detect v1.3.4
    (C) 1999-2010, R-fx Networks <proj@r-fx.org>
    (C) 2010, Ryan MacDonald <ryan@r-fx.org>
    inotifywait (C) 2007, Rohan McGovern <rohan@mcgovern.id.au>
    This program may be freely redistributed under the terms of the GNU GPL

    installation completed to /usr/local/maldetect
    config file: /usr/local/maldetect/conf.maldet
    exec file: /usr/local/maldetect/maldet
    exec link: /usr/local/sbin/maldet
    cron.daily: /etc/cron.daily/maldet

    maldet(32517): {sigup} performing signature update check…
    maldet(32517): {sigup} local signature set is version 2010051510029
    maldet(32517): {sigup} latest signature set already installed

    

To update the maldet use the below commands.

    maldet –update-ver

    maldet –update[/i]

To scan the files.

    maldet -a /home/username/

It will scan all the files and provide you the output.



To scan all user uder public_html paths under /home*/ this can be done with:

    root@server[~]# maldet –scan-all /home?/?/public_html

To scan the same path but the content that has been created/modified in the last 5 days:

    root@server[~]# maldet –scan-recent /home?/?/public_html 5

To scan but forget to turn on the quarantine option, you could quarantine all malware results from a previous scan with:

    root@server[~]# maldet –quarantine SCANID

If you wanted to attempt a clean on all malware results from a previous scan that did not have the feature enabled, you would do with.

    root@server[~]# maldet –clean SCANID

If you had a file that was quarantined from a false positive or that you simply want to restore (i.e: you manually cleaned it), you can use the following:

    root@server[~]# maldet –restore config.php.2384
    root@server[~]# maldet –restore /usr/local/maldetect/quarantine/config.php.2384

Wednesday, August 1, 2012

How to chage the server time zone in cpanel


The following article explains how to set the time and time zone in cPanel. The time zone can either be based on the location of the server (EST) or a time zone of your choosing.

To set the time and time zone, please follow these steps:

  1. Open a web browser and connect to your cPanel Control Panel located at https://ip address:2087.
  2. Login as the Administrator using the information sent to you in your setup email.
  3. From the Server Configuration menu, click Server Time.
  4. Select your time zone from the drop down list.
  5. Click Change TimeZone.
  6. Click Sync Time with Time Server to sync the time with the time zone.
On Shared Server

Can I change the server clock or time zone?

The server clock is set to Central Standard Time. You cannot change the time on a shared server's clock.
You can change the time zone being displayed with a PHP script. (Unfortunately, I cannot tell you where to put this code. You will need to consult with the program developer.) Here are two sample codes:
<?php
putenv("TZ=Europe/Amsterdam");
?>
<?php
date_default_timezone_set("America/Los_Angeles");
?>
You can set the timezone in .htaccess as well. (You can create a New File and name it ".htaccess", or you can edit the existing one. The .htaccess file belongs in /public_html/ - or a subdirectory if for a subdomain or addon domain). Add the line:
SetEnv TZ America/Indianapolis
Here is a list of supported timezones.

How do I change the timestamp on my emails?

Each webmail client has a timezone setting, which is set to the server clock by default.
SquirrelMail
  1. Go inside the webmail program and click Options at the top.
  2. Click the first link called Personal Information.
  3. Under Timezone Options, look for "Your current timezone:"
  4. Change the drop down to your time zone.
  5. Click the Submit button.
Horde
  1. Go inside the webmail program and click Options at the top.
  2. Click the second link called Locale and Time.
  3. Look for "Your current time zone:"
  4. Change the drop down to your time zone.
  5. Click the Save Options button.
RoundCube
  1. Go inside the webmail program and click Personal Settings at the top right.
  2. Under User Interface, look for "Time zone"
  3. Change the drop down to your time zone.
  4. Click the Save button.
Outlook 2007 - At any time, you can change the time zone in Outlook so that it matches your current geographic location. Please consult the Outlook Help menu for assistance with other versions.
  1. On the Tools menu, click Options.
  2. Click Calendar Options.
  3. Click Time Zone.
  4. Under Current time zone, type a name for the current time zone in the Label box.
  5. In the Time zone list, click the time zone that you want to use.
  6. If you want your computer clock to automatically adjust for daylight saving time (DST) changes, select the Adjust for daylight saving time check box. This option is available only in time zones that use daylight saving time (DST).
  7. Click OK and you are done.

Monday, March 7, 2011

How to access MySQL database remotely in cPanel - Remote MySQL Database Access(Access Host)

I have rectly encountered a problem with MySQL database connectivity,what was that see it

I'm having problem with accessing database from one of my site to another..

I have one site say a.com and I want to replicate the database from this site to my another site say b.com...

I'm using Cpanel in both the sites. In site A.com, I have created a user with required privileges and also added the other website (b.com) in the access hosts..

Now to access a.com database from b.com, I can use the username and password I have created on a.com but I'm not sure what hostname should I use..

Website a.com use localhost as the hostname..what should I use with b.com..


Solution:

-If a.com and b.com are on the same server, then you can use localhost.

-If they are on different servers, then use the IP address or domain name instead of localhost.

If the site with the database is a cPanel account, then you will need to give permission for remote access. This is done in cPanel>>MySQL databases

Look towards the bottom for a section called Access Hosts.

Start with % (wildcard). Once it works then

Add the IP address of the server that is wishing to access the database.
Then delete the wildcard (%)

-If already changed the "access hosts"
but this mysql error shows up


GRANT ALL PRIVILEGES ON `the_DB` . * TO 'username'@ 'domain_ip';


Try above sql query from MySQL prompt. and flush the prvileges. Check from your end.