There are thousands of hosting companies on the Internet and maybe this article will help you to start your own. Many companies offering web services are hosting reseller of other (bigger) companies or have partnerships with hosting companies. Maybe you have ever thought to offer hosting services by yourself, with a dedicated server or a VPS hosting account, it’s very easy to offer hosting plans for your existing customers. The following article will show you, using a few examples, how to use a web server installed with the software DirectAdmin to create web hosting accounts using their native API system.
Don’t think it’s easy to pull a new hosting company from the ground. This market is very saturated and we suggest to start offering hosting services most of all to your existing customers only.
VPS hosting versus dedicated server hosting
These days it’s not necessary to have your own dedicated server, a good maintained VPS host is often much more reliable. If the VPS hosting platform is well managed, you don’t have to worry about the shared memory because the virtualization software is able to manage all the resources. Why do you need a dedicated server if a VPS is so powerful? You need your own server for special hardware configurations or if your provider doesn’t have a good VPS platform. While many VPS companies using the same machines, the risk of hardware failures is low because hardware replacements should be a peace of cake. A “special” dedicated or colocated server might be a serious risk, f.e if the motherboard replacement is not available. A VPS host is scalable and often much cheaper than a dedicated server.
Web Server Control Panel
Using a control panel, makes it easy to create or maintain all the web hosting accounts for your customers. Sure as a Linux expert you don’t need a CP, but if you core business is web development, a control panel might really help. There are many of them, most of them are commercial products, but there are also a a few open source projects which are available for free. In this blog post we suggest to use DirectAdmin, because this software is easy to use, the license is not very expensive and there is also a very powerful API system.
After you got your VPS (or dedicated server) you’re ready to install the server software. Before you start the installation process check these DirectAdmin requirements. Most important is that your Linux web server is not pre-installed with software like Apache, MySQL, PHP, FTP… check this warning from the DA website:
Please do not install services such as Apache, PHP, MySQL, Ftp, Sendmail, etc., as we will do this for you. All we need is a CLEAN install of your operating system.
We do not recommend to install DirectAdmin on an existing production server. DirectAdmin does not convert existing data upon install.
For most DirectAdmin hosts CentOS is the preferred Linux operating system. You need also a DirectAdmin license, ask your VPS hosting provider, he can offer the license for a low fee.
DirectAdmin installation resources:
The installation process is not part of this article. If you finished the installation part, you should check this DNS installation guide.
Creating hosting accounts
After the final re-boot and your DirectAdmin server is running, you’re able to setup hosting accounts for your customers. You can create them by yourself using the DA control panel or using the DirectAdmin API within your web application. Think about the following application process:
- Customer has ordered a hosting accpunt from your website
- The payment is cleared and a request is send the API system
- Within DirectAdmin a hosting account is created
- The customer gets the login and hosting accpunt details via e-mail
How far you’re using this features of DA depends on yourself. The DirectAdmin API is able to manage all functions you need. This way you’re able to create your own we application, without telling your customers that a control panel is used.
Access the DirectAdmin API system
The API documentation is very complete and easy to use even for less experienced developers. There is also a custom PHP class to access the API via a HTTP socket, download the code here.
Using this PHP class is very easy, the following code is used to fetch all the user accounts from a reseller/admin account:
include_once 'httpsocket.php'; $sock = new HTTPSocket; $sock->connect('some.server.com', 2222); $sock->set_login('login', 'password'); $sock->query('/CMD_API_SHOW_USERS'); parse_str($sock->fetch_body(), $result); print_r($result); // shows the result in the browser
Next we show how-to add a new user to an existing reseller account (the package named “default” is a pre-defined hosting package):
include_once 'httpsocket.php'; $sock = new HTTPSocket; $sock->connect('some.server.com', 2222); $sock->set_login('login', 'password'); $sock->query('/CMD_API_ACCOUNT_USER', array( 'action' => 'create', 'add' => 'Submit', 'username' => 'abcuser', 'email' => 'firstname.lastname@example.org', 'passwd' => '123456', 'passwd2' => '123456', 'domain' => 'googles.com', 'package' => 'default', 'ip' => '220.127.116.11', 'notify' => 'yes') ); parse_str($sock->fetch_body(), $result); print_r($result); // shows the result in the browser
This API call is the same as creating a user from the web interface:
If you check all the API functions, you will see that it’s possible to create a 100% white labeled web application. Even if you don’t have that kind of web application, it’s very easy to create hosting accounts using the web interface on your DirectAdmin web server.
Published in: Web Hosting