WHM
WebHost Manager (WHM) is a web-based tool used by server administrators and resellers to manage hosting accounts on a web server.
WHM listens on ports 2086 and 2087 by default.
cPanel
cPanel is a Unix based web hosting control panel that provides a graphical interface and automation tools designed to simplify the process of hosting a web site. cPanel utilizes a 3 tier structure that provides functionality for administrators, resellers, and end-user website owners to control the various aspects of website and server administration through a standard web browser.
cPanel is commonly accessed on port 2082, with an SSL-secured server operating on port 2083.
Use cpanel and Whm API's in Rails
Panelbeater gem is used for communicating with the cPanel and WHM API's.
Ruby library for the WHM & cPanel API.
Installation
Github path https://github.com/BeenaShetty/panelbeater
Specify gem 'panelbeater' in gemfile
Usage
Create a server object and connect to WHM using host and secure hash:
server = Panelbeater::Whm::Commands.new( :url => url, :api_key => secure_hash, :port => port, :user => username )
Now,you can access the modules of WHM by calling server.module
Example
Creating a new account
Requires only a username and domain
result = server.createacct( :username => 'newuser', :domain => 'newuser.com' )
Output
createaact => {result => { :status => boolean, :statusmsg => "" }}
status (boolean) — Status of the operation.
1 — success.
0 — failure.
statusmsg (string) — Status or error message.
Reference : CreateAccount
Delete account
Requires only username
result = server.removeacct(:user => 'newuser')
Output
removeacct => {result => { :status => boolean, :statusmsg => "" }}
status (boolean) — Status of the operation.
1 — success.
0 — failure.
statusmsg (string) — Message about the status of the operation.
Reference: RemoveAccount
Using Cpanel methods
Connect to cpanel using server.cpanel
domain = Domain.find(5) server.cpanel(domain.username, { :cpanel_jsonapi_module => api_module, :cpanel_jsonapi_func => api_function, :cpanel_jsonapi_apiversion => api_version })
Note: If you use a cPanel port (2082 or 2083) to access the XML or JSON API, you can only use it to run API1 and API2 functions. Native XML and JSON API calls will not work. The ports are assigned as follows:
2082 — cPanel (unsecured).
2083 — cPanel (secured).
2086 — WHM (unsecured).
2087 — WHM (secured).
Fast Mode
Fast Mode is a newer way to use the cpanel function call in the XML or JSON API. This method is preferred, since it simplifies building the request, no longer requiring you to enter XML tags as input. The server-side processing of Fast Mode requests is also much quicker than the processing of XML requests.
XML Input
The cpanel XML function call in Fast Mode takes the following variables as input.
The following variables are required:
cpanel_xmlapi_user (string) — The user as whom you wish to call the function.
cpanel_xmlapi_module (string) — Name of the module to access.
Important: API1 and API2 variables are case-sensitive. For example, specifying Email is different from specifying email.
cpanel_xmlapi_func (string) — Name of the function to access.
The following variables are optional, depending on the call:
cpanel_xmlapi_apiversion (integer) — Version of the API to access.
1 — API1.
2 — API2.
No input — Defaults to API2.
arg (string) — List of arguments. These variables are numbered such that the first is arg-0, the second is arg-1, and so on.
Example: arg-0=username&arg-1=somepass
JSON Input
The cpanel JSON function call in Fast Mode takes the following variables as input.
The following variables are required:
cpanel_jsonapi_user (string) — The user as whom you wish to call the function.
cpanel_jsonapi_module (string) — Name of the module to access.
Important: API1 and API2 variables are case-sensitive. For example, specifying Email is different from specifying email.
cpanel_jsonapi_func (string) — Name of the function to access.
The following variables are optional, depending on the call:
cpanel_jsonapi_apiversion (integer) — Version of the API to access.
1 — API1.
2 — API2.
No input — Defaults to API2.
API1: arg (string) — List of arguments. These variables are numbered such that the first is arg-0, the second is arg-1, and so on.
Example: arg-0=username&arg-1=somepass
API2: arg (string) — List of arguments. These variables are given by name.
Example: email=bob&domain=fred.com
Output
cpanelresult — Container for the result of the cPanel operation.
apiversion (string) — Version of API accessed (1 or 2).
module (string) — Name of the module accessed.
func (string) — Name of the function accessed.
type (string) — Type of function.
source (string) — Source of the call (internal or external).
data — Data provided by the function.
result (string) — Result of the function
Reference: Cpanel
Example
1. Email::listpopswithdisk
List email accounts associated with a particular domain.
server.cpanel(domain.username, { :cpanel_jsonapi_module => "Email", :cpanel_jsonapi_func => "listpopswithdisk", :cpanel_jsonapi_apiversion => 2 })
2. Email::addpop
Add(create) an e-mail account.
server.cpanel(domain.username, { :cpanel_jsonapi_module => "Email", :cpanel_jsonapi_func => "addpop", :cpanel_jsonapi_apiversion => , :domain => "user.com", :email => "test", :password => "12345", :quota => 10 })
Output
<data>
<reason> A string value that contains the email address if the function completes successfully. This value will contain a reason for failure if the function encounters an error.
</reason>
<result> A boolean value that indicates success or failure. '1' indicates that the function completed successfully.
</result>
</data>
Reference: API1 Version , API2 Version
Thanks, 24x7 server support provide cpanel server management which is available 24x7 to solve all your cPanel server issues at the affordable prices. Get your cPanel server support now!
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteBlogs are very good way of exchanging the information and I love to read post and sometime some blogs give me so much of knowledge and this is one kind of those blogs. Wow both of the videos that you have shared in your post are very good and interesting.
ReplyDeletehttps://supportwala.net/cpanel-server-management
اما ممکن است این سوال به ذهنتان بیاید که یک خرید هاست خرید هاست اشتراکی ارزان ارزان چه هاستی است و چه ویژگی هایی باید دارا باشد در ادامه مقاله قصد داریم ویژگی های هاست ارزان را معرفی کنیم و در آخر به معرفی بهترین هاست ایران از میان هاستینگ های برتر کشور بپردازیم .اگر قصد راه اندازی یک سایت باکیفیت و پر بازدید را دارید حتما باید نکته هایی را رعایت نمایید قسمت سخت افزار از انتخاب ها تشکیل می شود و مناسب برای سایت هست که به سرور استفاده شده با سی پی یو ، رم و استفاده از دیگر سخت افزارها با ویژگی های عنوان شده مربوط می شود هاست پرسرعت برای وردپرس .نرم افراز به دو بخش جدا تقسیم می شود که بخشی از آن به هاست و سرور مربوط هست و بخش دیگر به سیستم مدیریت محتوا سایت شما بستگی دارد .و در نهایت بخش محتوا ارتباط با کار سئو و بهینه سازی سایت برای موتورهای جستجو و هم چنین بازاریابی خرید هاست لینوکسی ارزان از طریق محتوا است .در حقیقت هاست یک بستر الکترونیکی هست که محتویات و مطالب سایت شما داخل آن ذخیره خواهد شد .و این محتویات همان فایل و دیتابیس شما است که از طریق اتصال اینترنتی کاربران به سرور در دسترس خواهد بود .لازم است که هاست و دامنه به یک دیگر متصل باشند که این فرآیند از طریق Name server صورت می گیرد .بدین ترتیب اولین کاری که بعد از خرید هاست از شرکت های معتبر هاستینگ باید انجام دهید این هست که نیم سرور های هاست را بر روی دامنه خودتان ست کنید تا نهایتا بعد از گذشت ۷۲ ساعت هاست و دامنه به هم دیگر متصل شوند
ReplyDelete