Change website

From Jan 16 2015,


All post content will be move to we's offical website with many content...

Can access website here: http://justox.com

Thanks for your visit!

Thursday 19 December 2013

WHM/cpanel Functionality From the Command Line

Using one many automation scripts available in the /scripts folder, allows you to quickly configure, troubleshoot and execute powerful commands on your cPanel & WHM server by using one of the many automation scripts available in the scripts folder. Here are some of the more popular command line scripts available via cPanel & WHM:

easyapache
This powerful script allows you to compile, upgrade, and re-install Apache, PHP, and various modules. EasyApache makes it simple to compile Apache and PHP modules.
check_cpanel_rpms
The check_cpanel_rpms script validates cPanel-managed RPMs and provides a way to reinstall these RPMs if they have been altered.
*up
The *up script is used to manually update the various services on your cPanel & WHM server using various forms such as mysqlup, phpup and eximup. Although you can configure your services to update with cPanel, *up can be used for finer control.
restartsrv_*
The restartsrv_* script can be used to manually restart the various services on your cPanel server. This is the recommended method for restarting services through SSH.
addpop
The addpop script can be used to add email addresses through SSH. Through interactive prompts, addpop will create the new address and set the email address password under the proper user account.
delpop
The delpop scripts can be used to remove email accounts through SSH. Similar to the addpop script, delpop will remove the email address from the proper account.
wwwacct
The wwwacct script can be used to create accounts for your cPanel & WHM server. We’ve designed this script to allow you define common parameters used for account creation.
killacct
The killacct script can be used in similar fashion as the wwwacct script to automate removal of accounts.
restorepkg
The restorepkg script can be used to manually restore an account from backup.
cpbackup
When using cPanel & WHM’s legacy backup system the cpbackup script can be used to manually trigger system wide backups.
pkgacct
The pkgacct script is used within the cpbackup script and can be manually executed to create account specific backups.
upcp
The upcp script can be used to trigger the update process on your server. You can also configure whether you want server software and the OS updated by the upcp script.
setupmailserver
The setupmailserver script allows you to switch between courier and dovecot, or disable POP3 and IMAP functionality altogether.
setupftpserver
The setupftpserver script allows you to switch between pure-ftpd and proftpd, or disable ftp functionality altogether.
setupnameserver
The setupnameserver script allows you to switch between bind, mydns, and nsd, or disable nameserver functions altogether.
suspendacct
The suspendacct script can be used to automate suspension of accounts on your cPanel & WHM server.
unsuspendacct
The unsuspendacct script can be used to automate unsuspension of accounts on your cPanel & WHM server.
restartsrv_*
The restartsrv family of scripts can be used to restart various services on your cPanel & WHM server, such as Apache, Exim and Dovecot. For administration using the command line, this is the preferred method for restarting services. For a complete list please consult our documentation. Included are: restartsrv_apache
restartsrv_bind
restartsrv_dnsadmin
restartsrv_mailman
*up scripts
rpmup
sysup
 

Creating Account with wwwacct

Cpanel provide several usefull scripts in /scripts folder. /scripts/wwwacct is a script used for creating hosting account.
The syntax of wwwacct script is
[root@server10 root]# /scripts/wwwacct
WWWAcct 10.0 (c) 1997-2005 cPanel, Inc.
Please use the this syntax
wwwacct

[root@server10 root]#

To create hosting account for a domain through SSH do
In this example,
bizhat.com is the domain we are going to add.
bizhat is the user name
12345678 is the password
server10# /scripts/wwwacct bizhat.com bizhat 12345678 50 advanced n
WWWAcct 10.0 (c) 1997-2005 cPanel, Inc.
+===================================+
| New Account Info |
+===================================+
| Domain: bizhat.com
| Ip: 69.59.144.184 (n)
| HasCgi: y
| UserName: bizhat
| PassWord: 12345678
| CpanelMod: advanced
| HomeRoot: /usr/home
| Quota: 50 Meg
| NameServer1: NS1.HOSTONNET.COM
| NameServer2: NS2.HOSTONNET.COM
| NameServer3:
| NameServer4:
| Contact Email:
+===================================+
This ok? yes
Keeping Shell Access (y)
Copying skel files from /root/cpanel3-skel/ to /usr/home/bizhat/
Using Quota v1 Support
Added Entries to httpd.conf
Bind reconfiguring on uncle using rndc
Added Named File
Note: Local version of Apache must use the FrontPage Apache patch.
Starting install, port: 80.
Creating web http://www.bizhat.com.
fpfakeout: getpwnam handled
Not chowning content to root in service /.
Install completed.
Setting Password
Frontpage passthough auth enabled!
Restarting apache
Ftp Password Files synced
Vhost Passwords synced
Notifcation => spam@hostonnet.com via EMAIL [level => 3]
Notifcation => spam@flashwebhost.com via PAGER [level => 3]
wwwacct creation finished
server10#


cPanel Command Line DNS and Cluster Management

DNS clustering is part of setting up a server environment. cPanel has built-in support for DNS clustering to make it easy to deploy centralized nameservers, or have multiple nameservers receive DNS zone updates from one server. This article will help you understand setting up and managing a DNS cluster from command line.

Setting up a Cluster

From the remote nameserver:
You generally don't need to do anything other than enable clustering in WHM. You want the client servers to sync TO this server, not from it. Most of the time, the remote server will be your primary nameserver running cPanel DNSONLY.
From the client:
There are a few files involved in setting up a DNS cluster. Keep in mind that novice users may prefer to use WHM  > Configure Cluster, but this article is focused on the command line.
  • /var/cpanel/cluster/root/config/xxx.xxx.xxx.xxx : The file (named after the IP of the remote nameserver) containing the user, hostname, and remote hash
  • /var/cpanel/cluster/root/config/xxx.xxx.xxx.xxx-dnsrole : The file containing the sync action to the remote nameserver (standalone or sync)
  • /etc/wwwacct.conf : File containing the delegated nameservers for new zones created
  • /var/cpanel/resellers-nameservers : list of nameservers for resellers (overrides /etc/wwwacct.conf for zones created by accounts for that reseller)
  • /var/cpanel/useclusteringdns : Blank file indicating that DNS clustering is enabled (presence of file indicates yes, absence indicates no)
If the server is also going to be a nameserver itself, you will need to enable named in WHM > Service Manager (/etc/chkserv.d/chkservd.conf, set named to '1').
1)  Create a file in /var/cpanel/cluster/root/config as the IP of the remote server. Get the remote access hash for the remote nameserver (/root/.accesshash, located on the remote server) and add it to the file under the cluster user (assuming 'root') and its hostname. In this case, the remote server's IP is 6.7.8.9, so I'm going to create a file called /var/cpanel/cluster/root/config/6.7.8.9 and have it contain:
root
ns1.mynameserver.com
1429r23c1fdec38012a574be14382fd5
14f24bc86f86af9273575677c53aff83
4dc0d2d24cc8b1a7fe275acdb18e8ae8
71298146e796566a0a9fa0ea92644f11
aeceeb5f6eb489f2bb477b783a5a97c0
b24644193bb58b682c28113aa1e0e79f
59b190962fca3fcb2efb13d58d103374
3b68072ffe65a2a58cfa285fa69edeae
aff9e1922e0664acb86698c2c2884191
6cd9bd139252ec83833d07337117b898
ac071d28446cae6531e4dbeebdbe1aa2
511a689a4e2b24c7880a113694618920
a690f5b6bca11863fbc0d5b0d9a0a110
2b75426ca67984898afb71fc86c3ad75
c4a435525fc0f393ec317adbcbf4b99a
ce4b64d04c2f23766ecfb1ca4c9d09ac
36f66070c2ed55362338a1d26315c37a
91af3d1723149727d2e1756233340a57
4d1432bbfa61356b8a4b656abe817cb5
80d40d86c23cc3f4f86e74766c6d1cd6
66d2a4f89773beb02e6f856c9ae13e29
ca3e12219298e51d92f7ee9e7c645b27
dc70e2c151be6d4949d38379f6897d84
1fa9afec98cd6965300a058d77fd792b
5f47b6b791c8739ac4a18064a4420455
cc4bdf1ccf0e91d30fa7fa23b0efd168
2546f63b55f385bab0910711476ddc3e
8ec406c3e388a5639d1f71fd3f47ae8f
b2ebc449921c906602963ed802ca20e1

*Keep in mind that if you're a user other than root, you'd substitute 'root' in the path name for the actual user setting up the cluster.
All of this can also be done via WHM > Configure Cluster as well.

Managing DNS Zones

Synchronize a zone:
You generally want to synchronize a zone if changes were made and you want to push it out to your nameserver cluster. This is essentially the same as going into WHM > Synchronize DNS Records:
/scripts/dnscluster
Running this command by itself will give you a list of options for synchronizing, just as you get in WHM:
  • syncall : sync all zones with all cluster servers. This will find the zone with the largest serial and copy it to all nameservers in the cluster
  • syncalllocal : Finds the zone in the cluster with the highest serial number and copies it to the local server only (instead of to all servers in the cluster) – /scripts/dnscluster syncalllocal –full
  • synczone : Syncs one zone to all servers in the cluster, using the zone with the highest serial number throughout the cluster
  • synczonelocal – Syncs one zone locally, using the zone with the highest serial number throughout the cluster
So for instance, if you have a zone for mydomain.com on your hosting server and you want to synchronize it to all the nameservers in your cluster, you'd run:
/scripts/dnscluster synczone domain.com
Edit a DNS Zone:
To edit a zone, open /var/named/domainname.com.db in a text editor and make your changes. Remember to increment the serial number up by one, so that the correct zone it sync'ed to the nameserver cluster. The serial looks like this:
; cPanel 11.24.4-STABLE_36281
; Zone file for domainnmame.com
$TTL 14400
@      86400 IN      SOA     ns.mynameserver.com. me.mynameserver.com. (
  2009082500 ; serial, todays date+todays
  86400  ; refresh, seconds
  7200  ; retry, seconds
  3600000  ; expire, seconds
  86400 )  ; minimum, seconds
Then use /scripts/dnscluster to copy the zone up to your nameserver cluster. (see above examples)
Removing a DNS zone:
/scripts/killdns domainname.com
Adding a DNS zone:
/scripts/adddns –domain domainname.com
You can also use the  –ip and –reseller flags to indicate what IP and nameservers to use. For usage, just run /scripts/adddns and the help will display.

Additional resources:

http://docs.cpanel.net/twiki/bin/view/AllDocumentation/WHMDocs/ConfigureCluster
http://twiki.cpanel.net/twiki/pub/AllDocumentation/TrainingResources/TrainingSlides09/DNS_Cluster_Configuration.pdf 

Command Line PureFTP Configuration on cPanel
Ftp is easy to configure on a cPanel server using WHM or the pureFTP configuration file. The FTP service configuration in WHM is a no-brainer, but for those looking to set up FTP from command line (such as for automation purposes), you can use cPanel’s built-in template system to apply configuration options that will not be overwritten during cPanel updates.
The pureFTP template is located in /var/cpanel/conf/pureftpd/main, and is set up YAML style similar to most of cPanel’s internal configuration files. The settings in the template correlate directly to the same options in /etc/pure-ftpd.conf, but it’s better to edit the template since cPanel tends to prefer template-based configuration to regenerate (overwrite) config files.
So let’s change an option in the FTP configuration. I’m going to change the LimitRecursion value from 2000 to 10000, which will allow the FTP server to display more than 2000 files in a single folder. To do this, I’ll edit the value in the template file mentioned previously, and then apply the changes using one of the WHM binaries invoked from command line:
/usr/local/cpanel/whostmgr/bin/whostmgr2 doftpconfiguration
What if I wanted to specify an option that isn’t in the template? Well, you can do this one of two ways:
1. Add the option to the template
If you do this, note the syntax in the other FTP options – yes and no are enclosed in single quotes, everything else is not. You also need to envoke doftpconfiguration via the whostmgr2 command as shown above.
2. Change the option to pure-ftp.conf
You can change an option in the FTP configuration file and run /scripts/ftpup –force, and the template will add the changed values to the template as long as they don’t already exist. If they do, the template will change the specified option in pure-ftpd.conf to match its own value.
Generally this would com in use if you’re automating server setups. You can create a standard template for pureFTP, and download it to your server upon setup and update the configuration. This prevents you from having to modify anything manually, which can be a pain when deploying a large number of servers:
wget -O /var/cpanel/conf/pureftp/main http://yourrepo/pureftp/main
/usr/local/cpanel/whostmgr/bin/whostmgr2 doftpconfiguration

 

1 comment:

  1. Nice to be visiting your blog again, it has been months for me. Well this article that i've been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. cannazon market url

    ReplyDelete