cPanel Configuration Files and Handy Commands for Shell

cPanel Configuration Files and Handy Commands for Shell

Posted:  March 12, 2015

cPanel Configuration Files and Handy Commands for Shell

Since I use cPanel and CentOS alot now a days, I want to make sure that I have a handy place I can keep and search for anything I might need for configuring or managing the servers.

Without any further ado, I present you the most comprehensive list of cPanel Stuff, I have ever seen 😉

Configurations and Services They Are Tied To

  • CPanel

    • Configuration File: cpanel.config
    • Path: /var/cpanel/cpanel.config
    • Service: cpanel
  • Apache

    • Default Port: 80
    • Configuration File: httpd.conf
    • Path: /etc/httpd/conf/httpd.conf Or /usr/local/apache/conf/httpd.conf
    • Service: httpd
  • Exim

    • Configuration File: exim.conf
    • Path: /etc/exim.conf
    • Service: exim
  • Bind

    • Default Port: 53
    • Configuration File: named.conf
    • Path: /etc/named.conf
    • Service: named
    • DB location: /var/named
  • FTP server

    • proftp
      • Default Port: 20, 21
      • Configuration File: proftpd.conf
      • Path: /etc/proftpd.conf
      • Service: proftpd
    • pureftp
      • Default Port: 20, 21
      • Configuration File: pure-ftpd.conf
      • Path: /etc/pure-ftpd.conf
      • Service: pure-ftpd
  • MySQL

    • Default Port: 3306
    • Configuration File: my.cnf
    • Path: /etc/my.cnf
    • Service: mysql
    • Recommended Configuration
      • query_cache_type=1
        query_cache_size=16M
        query_cache_limit=1M
        sort_buffer_size=4M
        join_buffer_size=4M
        tmp_table_size=4M
        max_heap_table_size=4M
        thread_cache_size=16M
        max_connections=250
        max_allowed_packet=16M
        key_buffer_size=128M
        read_buffer_size=256K
  • PHP

    • Configuration File: php.ini
    • Path: /usr/local/lib/php.ini
    • Recommended Configuration
  • nGinx

    • Configuration File: nginx.conf
    • Path: /etc/nginx/nginx.conf
    • Service: nginx
    • Recommended Global Configuration
      • user www-data;
        worker_processes 8;
        pid /run/nginx.pid;
        
        events {
         worker_connections 768;
         # multi_accept on;
        }
        
        http {
        
         sendfile on;
         tcp_nopush on;
         tcp_nodelay on;
         keepalive_timeout 10;
         types_hash_max_size 2048;
         server_tokens off;
         fastcgi_read_timeout 3600;
         include /etc/nginx/mime.types;
         default_type application/octet-stream;
         access_log /var/log/nginx/access.log;
         error_log /var/log/nginx/error.log;
         gzip on;
         gzip_disable "msie6";
         gzip_vary on;
         gzip_proxied any;
         gzip_comp_level 9;
         gzip_buffers 16 32k;
         gzip_min_length 50;
         gzip_types 
         text/css
         text/plain
         text/javascript
         application/javascript
         application/json
         application/x-javascript
         application/xml
         application/xml+rss
         application/xhtml+xml
         application/x-font-ttf
         application/x-font-opentype
         application/vnd.ms-fontobject
         image/svg+xml
         image/x-icon
         application/rss+xml
         application/atom_xml;
         
         ignore_invalid_headers on;
         client_max_body_size 1024M;
         client_body_buffer_size 15m;
         client_header_timeout 400;
         client_body_timeout 400;
         send_timeout 400;
         connection_pool_size 256;
         client_header_buffer_size 4k;
         large_client_header_buffers 4 32k;
         request_pool_size 4k;
         output_buffers 4 32k;
         postpone_output 1460;
         open_file_cache max=10000 inactive=10m;
         open_file_cache_valid 2m;
         open_file_cache_min_uses 1;
         open_file_cache_errors on;
         include /etc/nginx/conf.d/*.conf;
         include /etc/nginx/sites-enabled/*;
        }
        
    • Recommended VHost Configuration
      • NOTE: Since CPanel needs Apache to run, we have to set nGinx and php-fpm as proxies.  This one is made special for WordPress
      • server {
                listen 80;
                server_name www.yourdomainname.com;
                rewrite ^(.*) http://yourdomainname.com$1 permanent;
        }
        server {
                listen 80;
                server_name yourdomainname.com;
        
                client_max_body_size 5m;
                client_body_timeout 60;
        
                access_log /var/log/nginx/yourdomainname.com.log;
                error_log /var/log/nginx/yourdomainname.com error;
        
                root /home/theaccountname/public_html;
                index  index.html index.php;
        
                ### root directory ###
                location / {
                        try_files $uri $uri/ /index.php?$args;
                }
        
                ### security ###
                error_page 403 =404;
                location ~ /. { access_log off; log_not_found off; deny all; }
                location ~ ~$ { access_log off; log_not_found off; deny all; }
                location ~* wp-admin/includes { deny all; }
                location ~* wp-includes/theme-compat/ { deny all; }
                location ~* wp-includes/js/tinymce/langs/.*.php { deny all; }
                location /wp-includes/ { internal; }
                #location ~* wp-config.php { deny all; }
                location ~* ^/wp-content/uploads/.*.(html|htm|shtml|php)$ {
                        types { }
                        default_type text/plain;
                }
        
        	# Uncomment this to block access
                #  location ~* wp-admin {
                #      allow <YOUR_IP>;
                #      allow 127.0.0.1;
                #      deny all;
                #  }
        
                ### disable logging ###
                location = /robots.txt { access_log off; log_not_found off; }
                location = /favicon.ico { access_log off; log_not_found off; }
        
                ### caches ###
                include /etc/nginx/conf.d/caches.conf;
        
                ### php block ###
                location ~ .php?$ {
                        try_files $uri =404;
                        include fastcgi_params;
                        #fastcgi_pass 127.0.0.1:9001;
                        fastcgi_pass unix:/var/run/php-main.socket;
                        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                        fastcgi_intercept_errors on;
                        fastcgi_split_path_info ^(.+.php)(.*)$;
                        #Prevent version info leakage
                        fastcgi_hide_header X-Powered-By;
                }
        }
  • php-fpm

    • Configuration File: www.conf
    • Path: /etc/php-fpm.d/www.conf
    • Service: php5-fpm
    • Recommended Configuration
      • user = nginx
        group = nginx
        pm = dynamic
        pm.max_children = 16 # 50% Available RAM
        pm.start_servers = 2 # 25% of Total CPU Cores
        pm.min_spare_servers = 1
        pm.max_spare_servers = 8 # Total CPU Cores
        pm.max_children = 10 
        pm.max_requests = 500
  • Networking Setup

    • /etc/sysconfig/network
    • /etc/hosts – Host entries
    • /etc/resolv.conf – Resolver Configuration
    • /etc/nameserverips – Nameserver IPs
  • clamav

    • Configuration File: clamav.conf
    • Path: /etc/clamav.conf
    • Service: clamd

Contents of /home/user

  • etc
  • mail
  • logs
  • public_html
  • public_ftp
  • hidden directories

Accessing The Control Panel

  • https://192.168.0.1:2083
    • This URL allows you to access cPanel over an encrypted connection with your IP address.
  • https://example.com:2083
    • This URL allows you to access cPanel over an encrypted connection with your domain name.
  • http://192.168.0.1:2082
    • This URL allows you to access cPanel over an unencrypted connection with your IP address.
  • http://example.com:2082
    • This URL allows you to access cPanel over an unencrypted connection with your domain name.
  • WHM Ports: 2086 and 2087
  • WebMail Ports: 2095 and 2096

Scripts & Usage (common first)

  1. Change CPanel Password
    1. /scripts/chpass username password
  2. Syncronize FTP Password
    1. /scripts/ftpupdate
  3. CPHulk Whitelisting
    1. /scripts/cphulkdwhitelist XXX.XXX.XXX.XXX # IP Address
  4. CSF/LFD Whitelisting
    1. csf -a XXX.XXX.XXX.XXX #Allow an IP Address
    2. csf -dr XXX.XXX.XXX.XXX #Remove an IP Address from the blacklist
    3. csf -r #Restart
  5. Check for Shellshock Bash Hack
    1. env X=”() { :;} ; echo shellshock” /bin/sh -c “echo completed”
    2. env X=”() { :;} ; echo shellshock” `which bash` -c “echo completed”
  6. Check for Base64 or Eval Hacks
    1. #!/bin/bash
      
      for filename in /home/* ; do
      
      	ACCT=$(stat -c '%U' "$filename");
      
      	if [ -d "$filename" -a "$ACCT" != "root" ]; then
      		#Possible File Hacks
      		find /home/$ACCT/public_html/ ( -name "*.php" ) -type f -print0 | xargs -0 grep --binary-files=without-match -ir "base64_decodes*(" | awk '{print $1}' | cut -d: -f 1 >> /possible-hacks.txt;
      		find /home/$ACCT/public_html/ ( -name "*.php" ) -type f -print0 | xargs -0 grep --binary-files=without-match -ir "evals*(" | awk '{print $1}' | cut -d: -f 1 >> /possible-hacks.txt;
      		#Possible Image Hacks
      		find /home/$ACCT/public_html/ ( -name "*" ) -type f -print0 | xargs -0 grep --binary-files=without-match -ir "base64_decodes*(" |grep 'jpg|gif|png|bmp' | awk '{print $1}' | cut -d: -f 1 >> /possible-image-hacks.txt;
      		find /home/$ACCT/public_html/ ( -name "*" ) -type f -print0 | xargs -0 grep --binary-files=without-match -ir "evals*(" |grep 'jpg|gif|png|bmp' | awk '{print $1}' | cut -d: -f 1 >> /possible-image-hacks.txt;
      	fi;
      done;
  7. Rebuild Httpd Config
    1. /scripts/rebuildhttpdconf
  8. Clean Out Old Logs
    1. find /the/path/to/search -type f -name “*.log” -mtime +30 -exec rm -f {} ;
  9. Full Account Backup
    1. /scripts/pkgacct ACCOUNTNAME
    2. backup is stored in /home as cpmove-ACCOUNT.tar.gz
  10. Full Account Restore
    1. /scripts/restorepkg –force /path/to/cpmove-file.tar.gz
  11. Verify CPanel License
    1. /usr/local/cpanel/cpkeyclt
  12. Watch an Accounts Traffic
    1. tail -f /usr/local/apache/domlogs/accountname/accountdomain.ext
  13. View All Current Connections
    1. netstat -an –inet

Scripts & Usage (alphabetical)

https://documentation.cpanel.net/display/ALD/WHM+Scripts#WHMScripts-Scripts

Kevin Pirnie

Kevin Pirnie

20+ Years of PC and server maintenance & over 15+ years of web development/design experience; you can rest assured that I take every measure possible to ensure your computers are running to their peak potentials. I treat them as if they were mine, and I am quite a stickler about keeping my machines up to date and optimized to run as well as they can.

Our Privacy Policy

Revised: June 8, 2021

Thank you for choosing to be part of my website at https://kevinpirnie.com (“Company”, “I”, “me”, “mine”). I am committed to protecting your personal information and your right to privacy. If you have any questions or concerns about this privacy notice, or my practices with regards to your personal information, please contact me at .

When you visit my website https://kevinpirnie.com (the “Website”), and more generally, use any of my services (the “Services”, which include the Website), I appreciate that you are trusting me with your personal information. I take your privacy very seriously. In this privacy notice, I seek to explain to you in the clearest way possible what information we collect, how I use it and what rights you have in relation to it. I hope you take some time to read through it carefully, as it is important. If there are any terms in this privacy notice that you do not agree with, please discontinue use of my Services immediately.

This privacy notice applies to all information collected through my Services (which, as described above, includes our Website), as well as, any related services, sales, marketing or events.

Please read this privacy notice carefully as it will help you understand what I do with the information that I collect.

1. WHAT INFORMATION DO I COLLECT?

Information automatically collected

In Short: Some information – such as your Internet Protocol (IP) address and/or browser and device characteristics – is collected automatically when you visit my Website.

I automatically collect certain information when you visit, use or navigate the Website. This information does not reveal your specific identity (like your name or contact information) but may include device and usage information, such as your IP address, browser and device characteristics, operating system, language preferences, referring URLs, device name, country, location, information about how and when you use our Website and other technical information. This information is primarily needed to maintain the security and operation of our Website, and for our internal analytics and reporting purposes.

Like many businesses, I also collect information through cookies and similar technologies.

The information I collect includes:
Log and Usage Data. Log and usage data is service-related, diagnostic, usage and performance information our servers automatically collect when you access or use our Website and which we record in log files. Depending on how you interact with us, this log data may include your IP address, device information, browser type and settings and information about your activity in the Website (such as the date/time stamps associated with your usage, pages and files viewed, searches and other actions you take such as which features you use), device event information (such as system activity, error reports (sometimes called ‘crash dumps’) and hardware settings).

Device Data. I collect device data such as information about your computer, phone, tablet or other device you use to access the Website. Depending on the device used, this device data may include information such as your IP address (or proxy server), device and application identification numbers, location, browser type, hardware model Internet service provider and/or mobile carrier, operating system and system configuration information.

Location Data. I collect location data such as information about your device’s location, which can be either precise or imprecise. How much information I collect depends on the type and settings of the device you use to access the Website. For example, I may use GPS and other technologies to collect geolocation data that tells me your current location (based on your IP address). You can opt out of allowing me to collect this information either by refusing access to the information or by disabling your Location setting on your device. Note however, if you choose to opt out, you may not be able to use certain aspects of the Services.

2. HOW DO I USE YOUR INFORMATION?

In Short: I process your information for purposes based on legitimate business interests, the fulfillment of my contract with you, compliance with my legal obligations, and/or your consent.

I use personal information collected via my Website for a variety of business purposes described below. I process your personal information for these purposes in reliance on my legitimate business interests, in order to enter into or perform a contract with you, with your consent, and/or for compliance with my legal obligations. I indicate the specific processing grounds I rely on next to each purpose listed below.

For other business purposes. I may use your information for other business purposes, such as data analysis, identifying usage trends, determining the effectiveness of our promotional campaigns and to evaluate and improve my Website, products, marketing and your experience. I may use and store this information in aggregated and anonymized form so that it is not associated with individual end users and does not include personal information. I will not use identifiable personal information without your consent.

3. WILL YOUR INFORMATION BE SHARED WITH ANYONE?

In Short: I only share information with your consent, to comply with laws, to provide you with services, to protect your rights, or to fulfill business obligations.

4. DO WE USE COOKIES AND OTHER TRACKING TECHNOLOGIES?

In Short: I may use cookies and other tracking technologies to collect and store your information.

I may use cookies and similar tracking technologies (like web beacons and pixels) to access or store information. Specific information about how I use such technologies and how you can refuse certain cookies is set out in our Cookie Notice.

5. IS YOUR INFORMATION TRANSFERRED INTERNATIONALLY?

In Short: We may transfer, store, and process your information in countries other than your own.

My servers are located in the United States of America, unless otherwise requested by my clients. If you are accessing my Website from outside, please be aware that your information may be transferred to, stored, and processed by me in my facilities and by those third parties with whom I may share your personal information (see “WILL YOUR INFORMATION BE SHARED WITH ANYONE?” above), in and other countries.

If you are a resident in the European Economic Area, then these countries may not necessarily have data protection laws or other similar laws as comprehensive as those in your country. I will however take all necessary measures to protect your personal information in accordance with this privacy notice and applicable law.

6. HOW LONG DO WE KEEP YOUR INFORMATION?

In Short: I keep your information for as long as necessary to fulfill the purposes outlined in this privacy notice unless otherwise required by law.

I will only keep your personal information for as long as it is necessary for the purposes set out in this privacy notice, unless a longer retention period is required or permitted by law (such as tax, accounting or other legal requirements). No purpose in this notice will require me keeping your personal information for longer than 6 months.

When I have no ongoing legitimate business need to process your personal information, I will either delete or anonymize such information, or, if this is not possible (for example, because your personal information has been stored in backup archives), then I will securely store your personal information and isolate it from any further processing until deletion is possible.

7. HOW DO WE KEEP YOUR INFORMATION SAFE?

In Short: I aim to protect your personal information through a system of organizational and technical security measures.

I have implemented appropriate technical and organizational security measures designed to protect the security of any personal information I process. However, despite our safeguards and efforts to secure your information, no electronic transmission over the Internet or information storage technology can be guaranteed to be 100% secure, so I cannot promise or guarantee that hackers, cybercriminals, or other unauthorized third parties will not be able to defeat my security, and improperly collect, access, steal, or modify your information. Although I will do my best to protect your personal information, transmission of personal information to and from my Website is at your own risk. You should only access the Website within a secure environment.

8. DO WE COLLECT INFORMATION FROM MINORS?

In Short: I do not knowingly collect data from or market to children under 18 years of age.

I do not knowingly solicit data from or market to children under 18 years of age. By using the Website, you represent that you are at least 18 or that you are the parent or guardian of such a minor and consent to such minor dependent’s use of the Website. If I learn that personal information from users less than 18 years of age has been collected, I will deactivate the account and take reasonable measures to promptly delete such data from my records. If you become aware of any data I may have collected from children under age 18, please contact me at .

9. WHAT ARE YOUR PRIVACY RIGHTS?

In Short: You may review, change, or terminate your account at any time.

If you are a resident in the European Economic Area and you believe I am unlawfully processing your personal information, you also have the right to complain to your local data protection supervisory authority. You can find their contact details here: http://ec.europa.eu/justice/data-protection/bodies/authorities/index_en.htm.

If you are a resident in Switzerland, the contact details for the data protection authorities are available here: http://ec.europa.eu/justice/data-protection/bodies/authorities/index_en.htm.

Cookies and similar technologies: Most Web browsers are set to accept cookies by default. If you prefer, you can usually choose to set your browser to remove cookies and to reject cookies. If you choose to remove cookies or reject cookies, this could affect certain features or services of my Website.

10. CONTROLS FOR DO-NOT-TRACK FEATURES

Most web browsers and some mobile operating systems and mobile applications include a Do-Not-Track (“DNT”) feature or setting you can activate to signal your privacy preference not to have data about your online browsing activities monitored and collected. At this stage no uniform technology standard for recognizing and implementing DNT signals has been finalized. As such, I do not currently respond to DNT browser signals or any other mechanism that automatically communicates your choice not to be tracked online. If a standard for online tracking is adopted that I must follow in the future, I will inform you about that practice in a revised version of this privacy notice.

11. DO CALIFORNIA RESIDENTS HAVE SPECIFIC PRIVACY RIGHTS?

In Short: Yes, if you are a resident of California, you are granted specific rights regarding access to your personal information.

California Civil Code Section 1798.83, also known as the “Shine The Light” law, permits my users who are California residents to request and obtain from me, once a year and free of charge, information about categories of personal information (if any) I disclosed to third parties for direct marketing purposes and the names and addresses of all third parties with which I shared personal information in the immediately preceding calendar year. If you are a California resident and would like to make such a request, please submit your request in writing to me using the contact information provided below.

If you are under 18 years of age, reside in California, and have a registered account with the Website, you have the right to request removal of unwanted data that you publicly post on the Website. To request removal of such data, please contact us using the contact information provided below, and include the email address associated with your account and a statement that you reside in California. I will make sure the data is not publicly displayed on the Website, but please be aware that the data may not be completely or comprehensively removed from all my systems (e.g. backups, etc.).

12. DO I MAKE UPDATES TO THIS NOTICE?

In Short: Yes, I will update this notice as necessary to stay compliant with relevant laws.

I may update this privacy notice from time to time. The updated version will be indicated by an updated “Revised” date and the updated version will be effective as soon as it is accessible. If I make material changes to this privacy notice, I may notify you either by prominently posting a notice of such changes or by directly sending you a notification. We encourage you to review this privacy notice frequently to be informed of how I am protecting your information.

13. HOW CAN YOU CONTACT ME ABOUT THIS NOTICE?

If you have questions or comments about this notice, you may email me at or by post to:

Kevin C. Pirnie

22 Orlando St.
Feeding Hills, MA 01030
United States of America

14. HOW CAN YOU REVIEW, UPDATE, OR DELETE THE DATA I COLLECT FROM YOU?

Based on the applicable laws of your country, you may have the right to request access to the personal information I collect from you, change that information, or delete it in some circumstances. To request to review, update, or delete your personal information, you may email me at or by post to:

Kevin C. Pirnie

22 Orlando St.
Feeding Hills, MA 01030
United States of America