Use cPanel Git Version Control to Host Website Using Custom Domain
Git is a distributed version control system used by many programmers. The cPanel Git Version Control tool provides a convenient graphical interface that allows access to Git features without using the command line.
You can use this tool to install and update a web site stored in a Git repository. This article shows how to install a simple 'Hello World!' example. You can follow the same steps to install an application of any size.
This article also shows how to clone a private Git repository.
Installing the site
In this example, a developer has created a web page and placed it in a repository on Github. To install the site from the Git repository, follow these steps:
- Log in to cPanel.
- Open the Git Version Control tool:
- In the FILES section of the cPanel home page, click Git Version Controls
- On the Git Version Control page, click Create:
- On the Create Repository page, confirm that the Clone a Repository slider is enabled.
- In the Clone URL text box, type the URL of the repository to clone. In this example, the site is being cloned from GitHub:
- In the Repository Path text box, type the path to the document root of the site:
- In the Repository Name text box, type a descriptive name for your repository:
- Click Create:
In the document root directory there is now the index.html file containing the 'Hello World!' message and a .git directory that contains files used by Git:
Updating the site
The site developer has created an 'About' page to supplement the 'Hello World!' message, and has added it to the Github repository. To update the site, follow these steps:
- Log in to cPanel.
- Open the Git Version Control tool:
- Locate the hello-world repository, and then click Manage:
- Click the Pull or Deploy tab:
- Click Update from Remote:
- The new about.html page is now in the document root directory:
Cloning a private repository
For public repositories, the previous procedures work as expected. However, if you try to clone a private repository using the procedure above, you receive an error message that resembles the following:
Error: (XID xna4yx) “/usr/local/cpanel/3rdparty/bin/git” reported error code “128” when it ended: fatal: could not read Username for 'https://github.com': No such device or address
To clone a private repository, you must use an SSH key pair and the SSH protocol in the clone URL. To do this, follow these steps:
Step 1. At the command line on your A2 Hosting account, if you have not already done so, create an SSH key pair:
ssh-keygen -t rsa
Step 2. View the text of the public key:
cat ~/.ssh/id_rsa.pub
Step 3. Copy the text of the public key you obtained in step 2.
Step 4. Add the SSH public key text to the Git provider you are using:
- For information about how to add an SSH key in GitHub, please visit https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh/adding-a-new-ssh-key-to-your-github-account.
- For information about how to add an SSH key in GitLab, please visit https://docs.gitlab.com/ee/ssh.
- For information about how to add an SSH key in Bitbucket, please visit https://confluence.atlassian.com/bitbucketserver/enable-ssh-access-to-git-repositories-776640358.html.
Step 5. At the command line on your account, type one of the following commands to test the connection to the Git provider:
- For GitHub, type the following command:
ssh -vT git@github.com
- For GitLab, type the following command:
ssh -vT git@gitlab.com
- For Bitbucket, type the following command:
ssh -vT git@bitbucket.org
Step 6. After you verify that the SSH connection is working, you are ready to clone the private repository using the ssh:// protocol. Dont use the https:// protocol as it will cause errors for ssh system. In cPanel, follow these steps:
- Open the Git Version Control tool:
- On the Git Version Control page, click Create:
- On the Create Repository page, confirm that the Clone a Repository slider is enabled.
- In the Clone URL text box, type the URL of the repository to clone, using the ssh:// protocol. For example, to clone a private GitHub repository you would type ssh://git@github.com/username/repository.git, where username represents your GitHub username, and repository represents the name of the repository you want to clone.
- In the Repository Path text box, type the path to the document root of the site:
- In the Repository Name text box, type a descriptive name for your repository:
- Click Create:
cPanel clones the private repository with the settings you specified. To update the repository, follow the steps in Updating the site above.
/
0 Comments
Add a comment