×
Community Blog Building a Shared Web Hosting Business on Alibaba Cloud

Building a Shared Web Hosting Business on Alibaba Cloud

In this article, we will show you how to set up your own shared web hosting service for your businesses on Alibaba Cloud.

By Partha Sarathy, Alibaba Cloud Tech Share Author. Tech Share is Alibaba Cloud’s incentive program to encourage the sharing of technical knowledge and best practices within the cloud community.

Are you ready to start your own web hosting business? If your answer is yes, then you will find this tutorial useful! In this article, we will be teaching you how to set up your own shared web hosting service for your businesses on Alibaba Cloud.

Architecture Diagram

We need three Elastic Compute Service (ECS) instances, one ApsaraDB for RDS MySQL instance, and two domain names for this project. I will be using the domain sarathy.info as my primary domain and sarathy.site as my secondary domain.

The two ECS instances shown on the left-hand side of the following architecture diagram will host our main website. One ECS instance is used for deploying WHMCS and the other one for deploying WordPress. Both WordPress and WHMCS require MySQL. So we will also deploy an ApsaraDB for RDS instance.

ECS instance shown on the right-hand side of the below diagram will be used to host our customers' sites. We will automate everything using a very popular software called WHM (Web Hosting Manager).

1
Architecture Diagram

Prerequisites

  • Two ECS instances running on Ubuntu 18.04 and one ECS instance running on CentOS 7 with at least 20 GB disk space & 1 GB of RAM
  • An ApsaraDB for RDS instance running the latest version of MySQL with two databases and two user accounts
  • Two domain names

Step 1: Configure DNS

DNS configuration for our primary domain

Record Type Host Value
A @ ECS Instance's IP (running WordPress)
A www ECS Instance's IP (running WordPress)
A portal ECS Instance's IP (running WHMCS)

DNS configuration for our secondary domain

Record Type Host Value
NS ns1 ECS Instance's IP (running WHM)
NS ns2 ECS Instance's IP (running WHM)

Step 2: WHMCS Server Setup

First of all, you need to download WHMCS from their official website

2

Next, we have to copy the downloaded file to our server via SCP( Secure Copy) protocol

scp -i path-to-ssh-key.pem path-to-whmccs.zip root@instance-ip:/root 

Now the WHMCS installation file will be copied to the root user's home directory ( /root) of our server.

Let’s log in to our ECS instance for installing WHMCS

ssh -i path-to-ssh-key.pem root@ecs-instance-ip

You will be logged into the ECS instance as shown as follows

3

Verify whether we have successfully transferred the WHMCS installation file to into our ECS instance or not.

ls /root

If you get the following output, you are ready to go!

4

Update the system

apt update

Upgrade the system

apt full-upgrade -y

Remove unnecessary packages

apt auoremove -y

Install the required components

apt install unzip sendmail software-properties-common wget -y

Install Apache web server

apt install apache2 -y

Verify Apache server’s installation by accessing the ECS instance's IP address in your web browser

5

Start Apache during boot

systemctl enable apache2

Install PHP

apt install php-fpm -y

Install the PHP extensions required by WHMCS

apt install php-curl php-gd php-json php-mbstring php-imap php-iconv php-dev php-mysql -y

Install Ioncube loader

cd /root
Wget http://downloads3.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz
tar -xf ioncube*
cp ioncube/ioncube_loader_lin_7.2.so /use/lib/php/20170718/

Create a custom PHP configuration file

nano /etc/php/7.2/apache2/conf.d/10-custom.ini

Paste the following lines

zend_extension="/usr/lib/php/20170718/ioncube_loader_lin_7.2.so"
max_execution_time = 60
max_input_time =60
memory_limit = 512M
max_input_vars = 6000
upload_max_filesize = 512M
post_max_size = 512M

Restart PHP and Apache web server

systemctl restart php7.2-fpm
systemctl restart apache2

Remove the default web page

rm -rf /var/www/htm/index.html

Modify Apache's configuration file

vim /etc/apache2/sites-available/000-default.conf

Add the following line

ServerName your-primary-domain.tld

Restart Apache web server

systemctl restart apache2

Unzip the WHMCS installation package

cd /root
unzip whmcs_v771_full.zip

Move the installation files to web server’s root directory

mv whmcs/* /var/www/html

Create a new WHMCS configuration file

cd /var/www/html
mv configuration.php.new configuration.php

Change ownership of the web server's root directory

chown -R www-data:www-data /var/www/html

Step 3: Deploying HTTPS for WHMCS

HTTPS protocol provides a secured encrypted connection between our servers and clients. We will install an SSL certificate from Let's Encrypt Certificate Authority. We will use a program called certbot for automating the process of issuing SSL certificates

Add certbot PPA

apt-add-repository ppa:certbot/certbot

Update the packages

apt update

Install certbot for Apache web server

apt install python-certbot-apache -y

Issue an SSL certificate

certbot --apache -d portal.your-primary-domaindomain.tld

Enter your email and agree to the terms and conditions by entering A.

Once the certificate is issued, certbot will show you two options. Choose Redirect all requests to secure HTTPS access

6

Once you select the above option, HTTPS will be deployed successfully.

Certificates provided by Let's Encrypt CA are valid for only 90 days.

So you have to log in to your server every 3 months and enter the following command to renew the certificate

certbot renew

Step 4: Installing WHMCS

So far, we have completed all the necessary steps to install WHMCS. Now its time to start the installation process

Go to https://portal.your-rimarydomain.tld/install/install.php from your web browser

After reading the Terms & Conditions, click Agree

7

WHMCS will check for all the basic requirements. If the requirements are satisfied, you can proceed with the installation. Otherwise, WHMCS will let you know the missing requirement

Click Begin Installation

8

You will be asked to enter your Licence key and Database details. You can get your licence key from your WHMCS dashboard. For database details, enter your RDS instance details. After entering the details, click Continue

9

The installation is almost is complete. We have to just add a cronjob and delete the installation folder

Login into the ECS instance & run the following commands

crontab -e

Add the following line

*/5 * * * * /usr/bin/php -q /var/www/html/crons/cron.php

Delete the installation directory

rm -rf /var/www/html/install

Go to https://portal.your-primary-domain.tld/admin to log in to WHMCS

Step 5: Installing WordPress

Login to the another ECS instance which is running on Ubuntu 18.04 via SSH

ssh -i path-to-public-key.pem root@ecs-instance-ip

Install EasyEngine

wget -qO ee rt.cx/ee4 && bash ee

When the installation is completed, you will get the summary of the installation similar to the following image

10

Let's deploy our WordPress site

ee site create YOUR-PRIMARY-DOMAIN.TLD \
--cache \
--type=wp \
--admin-user=YOUR-WORDPRESS-USERNAME \
--admin-pass=YOUR-WORDPRESS_PASSWORD \
--admin-email=YOUR WORDPRESS EMAIL \
--dbname=YOUR DB NAME \
--dbuser=YOUR DB USERNAME \
--dbhost=YOUR RDS INSTANCE HOSTNAME \
--ssl=le

Once the site is deployed, you will get the summary of the deployed website similar to the following image

11

Now go to https://your-primary-domain.tld/wp-admin

Step 6: Installing WHM

Login to the ECS which is running on CentOS 7 via SSH

ssh -i path-to-public-key.pem root@ecs-instance-ip

Update the system

yum update

Set the Fully Qualified Damion Name(FQDN)

echo "server.your-primary-domain.tld" > /etc/hostname
hostname -F /etc/hostname

Disable Firewall

iptables.save > ~/firewall.rules
systemctl stop firewalld.service
systemctl disable firewalld.service

Disable Network Manger

systemctl stop NetworkManager.service
systemctl disable NetworkManager.service

Download and install WHM

cd /home
curl -o latest -L https://securedownloads.cpanel.net/latest
sh latest

The installation will take up to 45 minutes to complete. Once the installation is over, get the WHM login URL using the following command.

Whmlogin

12

Go to the displayed login URL & complete the installation

Step 6: Integrating WordPress and WHMCS

Login to WordPress

Go to Plugins >> Add New

13

Search for WHMCS Bridge

Click Install Now once you find it

14

Click the Activate button to activate the plugin

Go to Settings >> WHMCS Bridge

Enter your WHMCS URL

15

Click Check My Installation

If the integration is successful, a success message will be shown as follows

16

That's it!

Step 7: Integrating WHM and WHMCS

Login to WHMCS

Go to Setup >> Products/Services >> Servers

Click Add New Server

17

Enter the Server name, IP address, network hostname, etc

Then, log in to WHM

Go to Development >> Manage API Tokens

Click Generate Token

18

Check the following permissions & click Save

19

Copy the generated API token

20

Go back to WHMCS. Fill the following details

  • Server Type: CPanel
  • Username: root
  • Password: YOUR WHM PASSWORD
  • API Token: Paste the token that you have copied from WHM

Click Save Changes

Now we have successfully integrated WHMCS and WHM

Step 8: Integrating PayPal with WHMCS

We will use PayPal to receive payments from our customers.

Go to PayPal.Com & SignUp for a Business account. If you already have a PayPal personal account,you have the option to upgrade it to a Business account as shown below

Once you have done creating a business account, go to Tools >> Business Setup >> Payment Setup >> On Your Website

Click the Continue button under Process all payments including credit and debit cards through PayPal

21

Click Get Your API credentials

22

Choose Request API Signature & click Agree and Submit

23

Copy the API Username, API Password, API Signature

Login to WHMCS

Go to Setup >> Payments >> Payment Gateways >> PayPal Express Checkout

Paste the copied API Username, API Password & API Signature.

Then click Save Changes

24

We have now successfully integrated PayPal with WHMCS!

Conclusion

We have successfully installed and configured WHMCS, WHM & WordPress for our web hosting company. Now it is time to create your own hosting packages and start selling. If you have any questions, feel free to ask in the comment section

1 0 0
Share on

Alibaba Clouder

2,599 posts | 762 followers

You may also like

Comments

5980169036806800 April 15, 2020 at 12:00 pm

how about the package that we offer?