You are here:Home»KB»Web Server»cPanel»My cPanel Notes
Sunday, 05 November 2023 09:29

My cPanel Notes

Written by

These is a collection my cPanel notes.

General

  • Using FlashFXP to upload files causes my IP to get black listed
    • when i upload a whole website or an operation in flashfxp with a lot of files my IP gets blacklisted
    • This is casued by a misconfiguration of the server's firewall where it is not closing the connection after each file upload. You would see errors in the firewall log simliar to below:
      Jan 29 10:49:11 host33 lfd[495799]: (CT) IP 146.199.161.166 (GB/United Kingdom/166.161.199.146.dyn.someisp.net) found to have 119 connections - *Blocked in csf* for 1800 secs [CT_LIMIT]
    • Support quote "As per the logs there were 119 connections found in 1800 secs from this IP address which exceeded the connections limit under the csf firewall and the IP address 146.199.161.166 got blocked on the server firewall."
    • Cause
      • Support Quote: "The firewall configuration is set correctly on the server. Sometimes TIME_WAIT connections are triggered under the csf firewall and due to which it detects the more number of connections from the IP address due to which IP address gets blocked at the server end. "
    • Solution
      • Support Quote "We have done port changes at host level can you please try and let us know if you are still facing any issue. Also please let us know if you are using Passive or Active connection of your ftp client."
      • I can now FTP up all of my files and I did not get blocked by the firewall.
  • Do I need CGI?
    • Q:
      • Do i need CGI, does anyone use this normally?
      • I am performing housekeeping and on all of my accounts and there is a folder cgi-bin what is its purpose etc.
    • A:
      • Hoster Response: The cgi-bin directory is used to contain CGI scripts which are rarely used nowadays but can be called, usually using the Perl coding language. However, since the management of content on your site is beyond the scope of our responsibilities I cannot tell how important the cgi-bin folder is for your domains in particular. Depending on whether or not your site uses the directory or CGI scripts deleting the cgi-bin can either break a site or have no effect. Also, cPanel may automatically regenerate the cgi-bin directory if it is deleted. Usually the cgi-bin takes up little or no space on the server so there is little need to remove it.
      • Disable automatic cgi-bin generation | cPanel Forums - I see no reason to have .cgi-bin in any of my sites. Please stop making it a default.
        • You can browse to "WHM Home --> Server Configuration --> Basic cPanel & WHM Setup" and set the following option to "No":
        • Automatically create a cgi-bin script alias. This setting can be individually overridden during account creation.
        • Also, as far as CGI access, you can disable the following options for your packages via "WHM --> Packages --> Edit a Package": CGI Access"
      • CGI Script Alias | Web Hosting Talk - Can i disable CGI Script to prevent virus issue ?
        • You can add the following line inside the global area to disable CGI for all domains.
          Options -ExecCGI
        • To disable it for all the domains on your server, edit the Apache configuration file
          pico /usr/local/apache/conf/httpd.conf 
        • Search for the line
          Options -Indexes FollowSymLinks MultiViews
        • in "<Directory "/home">" section and add the following at the end
          -ExecCGI
        • This should disable it for all the accounts. And yes, you can set n - No for the new accounts, however, the above mentioned changes will disable cgi for the newly created accounts as well.
        • Will it create any issues for working websites if i disable it? Yes, it will. The .pl and .cgi files will not work.
  • Allow SSH connection
    • Add your IP into the hosts.allow file.
    • WHM --> Home --> Security Center »Host Access Control section.
  • To enable Brotli on your cPanel/WHM server:
    • Brotli support in cPanel/EasyApache 4 - PlotHost
      1. Log in to your WHM panel as root.
      2. Navigate to Software->EasyApache 4
      3. Click the Customize button
      4. Now on the Apache Modules tab, search and select mod_brotli.
      5. Click the Next button few times and in the end click Provision button.
      6. You will see the confirmation message The provision process is complete.
  • OS Upgrade
    • cPanel elevate documentation - The cPanel ELevate Project provides a script to upgrade an existing cPanel & WHM CentOS 7 server installation to AlmaLinux 8 or Rocky Linux 8.
  • How to enable terminal and SSH
    • You would be able to get Shell terminal access of server from WHM panel from following steps.
    • Login to WHM --> Home --> Server Configuration --> Terminal
    • If you want to directly get ssh access of server from any SSH client then do let me know your local network's static IP address. So that I would be able to set that in ssh whitelist on your server's /etc/hosts.allow file.
  • Fix Kernel care failing to check for updates etc..
    • Add the following allow IP rule to the firewall (i.e. just add the IP via quick allow)
      69.175.106.203 # Manually allowed: 69.175.106.203 (US/United States/patches1.kernelcare.com) - Mon Mar 9 17:32:01 2020
  • Change cPanel theme
    • Menu --> cpanel --> customization --> Customize Style --> Basic = set as default
      • This changes it for all accounts as they are set to use default (usually) unless changed.
    • I want to hide the 'Switch to Glass' option for existing customers.
      • You can disable "Change Style" in WHM --> Feature Manager for your feature list(s). That's the only way I see now unfortunately to disable this unfinished theme.

Transfer, Backup and Restore Accounts

  • WHM cPanel account restore
    • Transfer or Restore a cPanel Account | cPanel & WHM Documentation - This interface lets you perform a transfer or restore for a cPanel account via an account archive file.
      • The Transfer or Restore a cPanel Account interface lets you transfer a cPanel account or restore one from an account archive file. An archive file is a cPanel account’s backup file or a cpmove file.
    • How to restore cPanel accounts from WHM - YouTube | PlotHost - How to restore cPanel accounts in WHM.
    • My Instructions
      • Upload the backup file to the `/usr/` folder as there is not much in it. do this as root.
      • I logged in to WHM as root (https://server.yourdomain.co.uk:2087/)
      • Navigate to WHM --> Backup Restoration --> Restore a Full Backup/cpmove File -->
  • HostDime custom backup script
    • This will backup all of the accounts your reseller account owns.
    • The following line had been placed in the root crontab to provide you with client backups:
      10 0 1 * * /bin/bash /home/.hd/crons/hdbackup_allyourcpanelaccounts.sh | mail -s "Backup cron ran" hosting@yourdomain.co.uk
    • The following is the context of the script "hdbackup_allyourcpanelaccounts.sh" that was customized by Kevin the System Administrator of the time.
      =========================================================
      #!/bin/bash
      # HostDime custom backup script
      # Author: Kevin B.
      # System Administrator
      
      RESELLER=yourreselleraccount
      DATE=$(date +"%Y-%m-%d")
      LOGFILE=/home/yourreselleraccount/cpanel-backups/logs/$DATE.log
      USERLIST=/home/yourreselleraccount/accounts.list
      BK_DIR=$(\ls -1 /backup | grep -E "[0-9]{4}-[0-9]{2}-[0-9]{2}" | sort | tail -1)
      mkdir -p /home/yourreselleraccount/cpanel-backups/$DATE;
      mkdir -p /home/yourreselleraccount/cpanel-backups/logs;
      
      hdbackup () {
      
      ## Get a list of users
      
      grep -l "OWNER=yourreselleraccount" /var/cpanel/users/* | cut -d / -f5 > /home/yourreselleraccount/accounts.list
      
      ## Skip users that are skipped in backups
      
      echo -e "$(date "+%b %d %H:%M:%S") Verifying users";
      while read line;
      do
      egrep -l "^BACKUP=0|^SUSPENDED=1" /var/cpanel/users/$line | cut -d / -f5 | while read user;
      do
      sed -i "/$user/d" $USERLIST;
      done;
      done < $USERLIST
      
      ## Tar backups to a folder in the yourreselleraccount account
      
      echo -e "$(date "+%b %d %H:%M:%S") Compressing backups";
      cat $USERLIST | while read USER; do
      if [[ -d /backup/"$BK_DIR"/accounts/"$USER" ]]; then
      echo -e "$(date "+%b %d %H:%M:%S") Copying /backup/"$BK_DIR"/accounts/${USER}";
      /usr/local/cpanel/bin/cpuwatch $(grep -c \^processor /proc/cpuinfo) tar -zcf /home/yourreselleraccount/cpanel-backups/"$DATE"/"$USER".tar.gz -C /backup/"$BK_DIR"/accounts/ $USER ;
      else
      echo -e "$(date "+%b %d %H:%M:%S") Backup does not exist for $USER at /backup/"$BK_DIR"/accounts/${USER}";
      fi
      done;
      
      ## Prune old backups
      
      echo -e "$(date "+%b %d %H:%M:%S") Pruning old backups"
      find /home/yourreselleraccount/cpanel-backups/ ! -path '/home/yourreselleraccount/cpanel-backups/' ! -path '/home/yourreselleraccount/cpanel-backups/logs' ! -name "*.log" -mtime +30 -print -delete
      
      ## Fix permissions
      
      echo -e "$(date "+%b %d %H:%M:%S") Fixing Permissions";
      chown -vR yourreselleraccount: /home/yourreselleraccount/cpanel-backups/
      
      echo -e "$(date "+%b %d %H:%M:%S") Backup Complete";
      
      }
      =========================================================
  • The errors bellow are caused by the remote server being blocked by the firewall when transferring cPanel accounts or an incorrect password.
      • [Solved] cPanel copy an account from another server failed | BaseZap - You might have encountered following error while using ” Copy an Account From Another Server With an Account Password
        Starting “TRANSFER” for “Account” “Username”.
        Attempting to copy “Username” from “Source IP”.
        Trying to fetch cpmove file via cPanel API!
        Fetching current backups from remote server …cPanel Login Failed: 403 Forbidden Access denied
        Failed to fetch cpmove file via cPanel API.
        Failed: Error while executing “/usr/local/cpanel/scripts/getremotecpmove”. The “/usr/local/cpanel/scripts/getremotecpmove SourceIP Username” command (process 2364424) reported error number 1 when it ended.:
      • Another error
        TRANSFER: 0 completed, 0 had warnings, and 1 failed.
        RESTORE: 0 completed, 0 had warnings, and 1 failed.
        TRANSFER: Account “cpanelaccount”: Error while executing “/usr/local/cpanel/scripts/getremotecpmove”. The “/usr/local/cpanel/scripts/getremotecpmove 31.31.31.31 cpanelaccount” command (process 7144) reported error number 255 when it ended.: Cpanel::Exception::HTTP::Network/(XID myb7yt) The system failed to send an <abbr title="Hypertext Transfer Protocol">HTTP</abbr> “GET” request to “https://31.31.31.31:2083/json-api/cpanel?cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=listfullbackups&cpanel_jsonapi_apiversion=1” because of an error: Could not connect to '31.31.31.31:2083': Connection refused at /usr/local/cpanel/Cpanel/HTTP/Client.pm line 115, <STDIN> line 1. Cpanel::HTTP::Client::request(Cpanel::HTTP::Client=HASH(0x23167b0), "GET", "https://31.31.31.31:2083/json-api/cpanel?cpanel_jsonapi_modul"..., HASH(0x2316930)) called at /usr/local/cpanel/scripts/getremotecpmove line 298 scripts::getremotecpmove::get_current_backups("31.31.31.31", "cpanelaccount", "PUp05bR_Ij%f") called at /usr/local/cpanel/scripts/getremotecpmove line 116 scripts::getremotecpmove::fetch_acct_by_cpanel(__CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__) called at /usr/local/cpanel/scripts/getremotecpmove line 56 scripts::getremotecpmove::script("scripts::getremotecpmove", "31.31.31.31", "cpanelaccount") called at /usr/local/cpanel/scripts/getremotecpmove line 29
        RESTORE: Account “cpanelaccount”: Error while executing “/usr/local/cpanel/scripts/getremotecpmove”. The “/usr/local/cpanel/scripts/getremotecpmove 31.31.31.31 cpanelaccount” command (process 7144) reported error number 255 when it ended.: Cpanel::Exception::HTTP::Network/(XID myb7yt) The system failed to send an <abbr title="Hypertext Transfer Protocol">HTTP</abbr> “GET” request to “https://31.31.31.31:2083/json-api/cpanel?cpanel_jsonapi_module=Fileman&cpanel_jsonapi_func=listfullbackups&cpanel_jsonapi_apiversion=1” because of an error: Could not connect to '31.31.31.31:2083': Connection refused at /usr/local/cpanel/Cpanel/HTTP/Client.pm line 115, <STDIN> line 1. Cpanel::HTTP::Client::request(Cpanel::HTTP::Client=HASH(0x23167b0), "GET", "https://31.31.31.31:2083/json-api/cpanel?cpanel_jsonapi_modul"..., HASH(0x2316930)) called at /usr/local/cpanel/scripts/getremotecpmove line 298 scripts::getremotecpmove::get_current_backups("31.31.31.31", "cpanelaccount", "PUp05bR_Ij%f") called at /usr/local/cpanel/scripts/getremotecpmove line 116 scripts::getremotecpmove::fetch_acct_by_cpanel(__CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__, __CPANEL_HIDDEN__) called at /usr/local/cpanel/scripts/getremotecpmove line 56 scripts::getremotecpmove::script("scripts::getremotecpmove", "31.31.31.31", "cpanelaccount") called at /usr/local/cpanel/scripts/getremotecpmove line 29
  • How to Move All cPanel Accounts from One Server to Another | cPanel & WHM Documentation - This tutorial explains how to migrate your cPanel accounts, SSL certificates, and main server IP address from one server to another. Typically, you would do this when you need to replace your server.

Email

  • PDFs are getting stripped from emails when using webmail.
    • You might get an message simliar to this:
      [Attachment stripped: Original attachment type: "application/pdf", name: "ycc 1581-1.pdf"]
    • Horde -> Attachment stripped | cPanel Forums - You can solve the problem of attachments being stripped from your "sent-box" by simply adjusting your Horde preferences.
      1. Login to your webmail
      2. Click to view your Inbox
      3. Click the "Options" button at the top of the page
      4. Click on "Message Composition"
      5. Look for the following, near the bottom of the list of settings:
        "When saving sent-mail, should we save attachment data?"
        Then set it to "Always Save Attachments" Or any of the other options that suit your personal preference.
      6. Click "Save Options"
  • Email disk Usage ignoring Trash folder
    • SOLVED - Email disk Usage ignoring Trash folder | cPanel Forums
      • Q: How is there 350mb allowed in trash, when i have a limit of 250mb set on the account.
      • A:
        • However, cPanel do not count trash emails in the email account quota as it is excluded by cPanel.
        • It can be enabled from WHM >> Mailserver Configuration >> Include Trash in Quota.
        • But as it is a shared server, it will affect all the accounts on the server so it is not recommended to enable this feature.
        • That is the reason the .Trash folder below is counted in Other Usage instead of email account quota.
  • Emails from ebay and paypal (and other domains) can take ages to turn up, but sometimes they do turn up.
    • Greylisting is enabled
    • The "Bypass Greylisting for Hosts with Valid SPF Records" is not turned on
  • The webmail sub domain (i.e. http://webmail.quantumwarp.com) cannot be accessed, but you can access webmail via https://quantumwarp.com/webmail
    • You might also find other subdomains cannot be accessed and this is most likely becasue your DNS Zone has been corrupted.
    • This sometimes can be caused when migrating betweenb cPanel servers due to differences in version numbers.
    • Solution
      • Backup and customizations you have added to your DNS Zone
      • Reset DNS Zone
      • If this is your primary reseller account you will need to add back in your 'ns1' and 'ns2' entries as these will not be added back in automatically.
      • Re-add your DNS customisations.
  • Have SpamAssassin for non-SPF validated emails
    • Go into SpamAssassin rules and add the following:
      SPF_FAIL = 10     (SPF Hard Failure
  • Some useful notes on spam
    • The spam filter identified spam based on a point value system. Signs of spam such as a blacklisted URL, key words, or little to no verification add points to a messages spam score. Signs of legitimate mail such as proper identification or verification and clear text formatting reduce the spam score. SpamAssassin is currently configured to identify a message spam if it reaches a spam score of 5, though this message received a score of 2.2 with only 1.2 of those points originating from the blacklisting.
    • Blacklisted URLs are not a very effected way to determine if an entire message is considered spam. These rules cause hits regardless of how the URL is provided within the message. For instance, if you were to send an e-mail with a picture taken from the site to show someone it is a scam, SpamAssassin would see the picture is hosted on the blacklisted site, thus giving your legitimate message more points towards the spam score. As a result, we avoid server wide rules for increasing spam scores based on blacklisted URLs alone.
    • As we previously mentioned, we can train SpamAssassin to better identify other parts of the message to increase the spam score. In your case, the Bayes algorithm provided a -1.9 score making it appear more legitimate. This algorithm determines how well this spam message as a whole compares to known spam samples. By training Spam Assassin, the Bayes portion of the filter can identify these types of spam with much higher scores, ensuring the message is properly identified as well as helping prevent future false positives.
  • Horde - large cache of files
    • SOLVED - [CPANEL-12976] Horde generating large number of cache files | cPanel Forums
      • Internal case CPANEL-12976 is open to address the issue where temporary cache files associated with Horde can build up over time in the /home/user/tmp/ (when PHP-FPM for cPanel is enabled) or /home/user/tmp/horde/ directories because they are not automatically removed.
      • The temporary workaround is to manually remove these files, or to setup a cron job to manually remove those specific files after they reach a certain age.
      • Solution
        • In cPanel & WHM version 78, we added the Age, in days, of content to purge users' Horde cache files option to the Mail section of WHM's Tweak Settings interface (WHM >> Home >> Server Configuration >> Tweak Settings). This setting determines the minimum age, in days, of files that the system will automatically delete users' Horde cache files.
        • This setting accepts a minimum value of 1, and defaults to Disabled.
  • Manually train SpamAssassin
    • When our clients are receiving too much spam, we recommend they train SpamAssassin to better identify the type of spam they are receiving.
      • This is done by creating 2 folders using IMAP or webmail, in any email account that falls under the cPanel account that is receiving the excess spam.
      • The 2 folders should be named ".HAM-TRAIN" and ".SPAM-TRAIN", where each of the folders should be populated with at least 200 messages.
      • In the .HAM-TRAIN folder, you should place the legitimate messages received and place the spam messages in the .SPAM-TRAIN folder.
      • Once both folders are populated, let us know so we can perform the training which affects the entire cPanel account, which means this training and folder creation is not necessary to redo on a per email or domain basis
    • The instructions are to move the emails into these folders using the webmail, but can I forward emails to a honeypot email account?
      • In regards to your first question, forwarding messages completely alters the e-mail headers and various sections of the e-mail that may interfere with proper training. Rather than identify incoming spam mail, SpamAssassin may begin to think forwarded mail is spam, thus automatically marking all forwarded mail you receive as spam.
      • Training data is shared across entire cPanel accounts rather than domains or individual e-mail users.
      • We can add the training folders to user@quantumwarp.com and then you simply move the spam/ham messages into their respective folders via webmail or IMAP. Afterwards, we can train using this data and that training data will be used for all domains and all e-mail accounts under that cPanel account.
    • If you would like to copy training data to other domains NOT on the same cPanel account,
      • You will need to copy the two files [bayes_seen] and [bayes_toks] from the SpamAssassin directory within the cPanel account. For example, the account [lancast] has it's training data stored in following two files:
        /home/yourcpanelaccount/.spamassassin/bayes_seen
        /home/yourcpanelaccount/.spamassassin/bayes_toks
      • These files can be copied and moved to other cPanel accounts to share training data.
    • Unfortunately, cPanel does not offer any direct ability to train SpamAssassin, and as such there is little documentation on the topic:
    • For further information on SpamAssassin training, I recommend reviewing the official SpamAssassin training documentation found here:
    • If i use the inbuilt cPanel forwarding feature this should put a copy of the email in another mailbox without altering it so i can then use that spare account via webmail to move spam into the spam folders without affecting my normal work flow?
      • As mentioned previously, we do not recommend setting up a forwarder to send a copy of the messages to another inbox and use the spare inbox to train SpamAssassin.
      • This does alter the message as the message source is now originating from an email account on the server and not the original recipient.
      • The simplest way to fill up your SpamAssassin training folders without affecting your work flow would be to copy the messages from your inbox into the designated SpamAssassin training folders(.SPAM-TRAIN and .HAM-TRAIN), this way you still have the original messages in the folders they were originally in.
    • I am trying to ascertain if a cPanel forwarder is the same as a normal email forward. {see image}. I thought that cpanel just made an exact copy of the email message and effectively copied it and not forwarded it in the traditional sense.
      • A cPanel forwarder is still considered a forwarder where the message headers are altered
    • The training data applies to the entire cPanel account. Each cPanel account under your reseller maintains its own set of training data.
    • You can purge the training data ans start again if you seem to be getting incorrect results
    • The training data on your account can looks like this:
      ####################
      0.000 0 211 0 non-token data: nspam
      0.000 0 947 0 non-token data: nham
      0.000 0 107557 0 non-token data: ntokens
      ####################
  • Manually adding SpamAssassin rules
    • The inability to add/remove these rules is simply a limitation in cPanel's UI when viewing the configuration file.
    • These can be manually edited by editing the /home/yourcpanelaccouny/.spamassassin/user_prefs file.
  • Forwarded emails are not getting delivered because they are flagged as SPAM with a 550 error.
  • Increase allowed email size (exim)

SSL

PHP

  • PHP-FPM
  • zlib.output_compression should be disabled
    • This is an option in php.ini settings, and on my server is on by default.
    • Whether to transparently compress pages. If this option is set to "On" in php.ini or the Apache configuration, pages are compressed if the browser sends an "Accept-Encoding: gzip" or "deflate" header.
    • zlib.output_compression Should Be Off on Cloud Server for Performance - zlib.output_compression, Specifically for PHP-MySQL Web Software Like WordPress Should Be Off on Cloud Server for Performance. Here is Why.
    • How to Enable GZIP Compression to Speed Up WordPress Sites - Learn how to enable GZIP compression to speed up your WordPress site on various web servers like Apache, Nginx, and IIS.
  • mime_content_type() function not defined
    • php - mime_content_type() function not defined - Stack OverflowI
      • If you are on shared hosting, chances are that the fileinfo PHP extension is either not enabled or installed.
      • In the case where it's not enabled, navigate to the Software section of CPanel (consult documentation of your control panel if you're not using CPanel) and click Select PHP Version (or something related to that) and enable the extension by checking its box and saving your action.
      • If it's not installed, the extension won't be part of the PHP extensions at cPanel > Software > Select PHP Version > Extensions, edit your php.ini file and uncomment extension=php_fileinfo.dll if you're on Windows. Consult your hosting provider's docs if any of these don't work.
    • Add php73-php-fileinfo to Apache by using  EasyApache

Database

  • This is an example of how our server was tuned using MySQL Tuner
  • We have ran the mysql tuner and as per the suggestions by MySQL tuner, we have changed the MySQL configuration from
  • Before
    query_cache_size = 48M
    query_cache_type = 2
    query_cache_limit = 30M
    join_buffer_size = 128M
    key_buffer_size = 256M
    innodb_buffer_pool_size >> unlimited
  • After
    query_cache_size = 0
    query_cache_type = 0
    query_cache_limit = 32M
    join_buffer_size = 140M
    key_buffer_size = 56M
    innodb_buffer_pool_size=512M
  • ddddd

 

 

 

 

 

 

Read 128 times Last modified on Saturday, 18 November 2023 15:11