Using Remote Git Hosting with Plesk

Introducing Plesk

Plesk is web hosting and data center automation software. It has a hosting control panel designed for providers of Windows- and Linux-based retail hosting services.

The Plesk user management model accommodates dedicated and shared hosting. Server administrators can set up new sites and reseller accounts. They can also edit and create DNS entries via an online interface.

Plesk’s main features include automation and management of: domain names; web applications; email accounts; databases and infrastructure tasks to deliver a ready-to-code environment and cutting-edge security on all operating systems and layers.

Introducing Git

Git is the most widely used version control system. It tracks any adjustments made to files, giving you a detailed record of edits. You’re free to restore previous versions as required.

Collaboration is also simpler: changes made by several users can be combined into a single source.

Git could work well for you, whether you write code for your own use or you operate within a team. It runs locally, while your files and their respective histories remain on your computer. You can take advantage of web-based hosts (e.g. Bitbucket or GitHub) if you want to store a copy of files and revision histories online too.

You’ll find collaborating with developers easier when you have a centrally located space for uploading and downloading changes. Git can combine these changes automatically, allowing two users to focus on separate areas in the same file, without losing their respective work.

How Do Plesk and Git Work Together?

Plesk can be integrated with Git (the most commonly used source code management system for developers) easily. Git repositories can be managed and sites can be deployed from them to specific public directories. It can be a valuable transport for initial publishing and future updates.

Please be aware, though, that this feature isn’t supported in Plesk installations that run on Windows Server 2008.

Take these steps if you want to start working with Git:

  1. Install the Git extension in Plesk
  2. Make a domain in Plesk with a service plan that enables the Git management permission.

You can add two kinds of Git repositories in Plesk. Your choice will vary depending on the situation:

  1. Leveraging a local repository on your workstation. In this scenario, you would transfer the edits to Plesk from your local repository. Plesk would then deploy those adjustments to your site. You can find more in this guide to using local repositories.
  2. Leveraging remote Git hosting. This situation may apply if you work with a remote repository in BitBucket or GitHub already. You would transfer the edits to the remote repository, and Plesk would take them from the remote repository. They would then be deployed to your site. You can find more in this guide covering remote Git hosting.

After you enable Git repositories in your domain, you’ll see a list of created repositories on the domain’s page. The name, current branch, and deployment path for each repository will be included.

The Deploy button close to the repository name enables you to deploy files from a repository (when manual deployment is set up). You can hit the Pull Updates button if you want to gather changes from the remote repository.

How to Use Remote Git Hosting

This may apply if you work with a remote repository in GitHub or BitBucket already.

You would transfer the changes to this remote repository. Plesk would take them and deploy them to your site.

How to Clone a Git Repository

You can clone a remote repository to make a Git repository. Make your way to Websites & Domains, then hit Git. You can click the Add Repository button if you’ve made Git repositories for your domain already. You’ll be presented with a screen for making a new repository.

The first thing to do is pick the location in which your code will be stored. In this case, pick Remote Git hosting like GitHub or BitBucket.

Remote Git repository. Input the path to your remote repository in GitHub or BitBucket (in SSH or HTTPS). There’s no support for HTTP/HTTPS authentication, so you can only use HTTP/HTTPS protocol if a repository doesn’t need to be verified.

If you use a private Git repository, you need to verify with an SSH key created by Plesk. You can check out this guide to using SSH connection for more.

Define the following in the Your Website section:

  • The deployment mode: Automatic deployment is used by default. With this enabled, changes pushed to the Git repository are deployed to the production site automatically. If you want to adjust the deployment mode, hit the automatically deployed link and pick another option in the Deployment Mode window that is opened. If you have chosen Manual deployment, you should deploy files from the Git repository to your hosting manually. When you opt for No deployment, the files won’t be deployed to the production site. You can use this for storing and exchanging code, among other things.
  • A target directory for the publication of Git files on your website. The /httpdocs directory will be utilized instead, though you can switch it to a different existing directory by clicking on the name of the intended directory.

Click OK and Plesk will attempt to clone the remote repository after connecting to it. Once the progress dialog reveals that the cloning has been successful, the new repository will be shown on the Git page.

The new repository will be presented at Websites & Domains > Git. The remote repository’s name will be utilized as a Git repository name, though you can change its name at a later date. To find out more, visit the section dedicated to renaming or removing a repository.

The repository that has been created will be a clone of the remote repository, and can be leveraged to gather changes from it before they’re deployed to the target directory.

How to Use SSH Connection

You can connect to the remote Git repository with SSH. In this situation, when you add a new repository, define the URL of the remote repository in the SSH format. The SSH public key box will be displayed, as will the SSH public key Plesk has generated automatically.

Before you click the OK button, you should add the SSH key to the remote Git’s repository settings. Look at the documentation covering how to add an SSH key for GitHub and BitBucket.

How to Pull and Deploy Files

Once you commit your site files and send them to the remote repository, you should go to Websites & Domains. Next, hit the Pull Updates button positioned beside the repository name. The cloned Git repository will retrieve the changes from the remote repository.

The most recent commit information is available at Websites & Domain > Git.

Plesk utilizes the Automatic deployment mode as standard. After a file has been sent to the repository, it will be deployed to the target directory straight away. You can turn this mode off if you need to.

How to Adjust Branch or Path

Deployment from a new branch

It’s normal to work with multiple branches in a single repository, and just one branch may be active at any time. The master branch will be utilized for deployment as standard.

If you want to add a new branch, you have to make it in your remote repository before you start pulling the changes.

Next, choose any number of active branches in Plesk. Navigate to Websites & Domains > Git, and then hit Change branch and path. Pick the branch name in the Branch menu in the opened window.

When you’ve selected a new branch, hit OK and Plesk will show the new active branch.

Changing the deployment path

The /httpdocs directory is utilized to publish Git files on your site by default. To adjust the path of deployment, go to Websites & Domains > Git. Next, click on the Change branch and path link. Choose the new directory in the opened window.

How to Choose a Deploy Mode

You can pick a deploy mode for your repository easily. Navigate to Websites & Domains > Git. Hit Repository Settings and choose one of the following options at Select deploy mode:

  • Automatic deployment: Pick this option if you’d rather all changes were deployed to the production site straight away.
  • Manual deployment: Files will need to be deployed manually. To do so, hit the Deploy from Repository button at Websites & Domains > Git. Files can be deployed manually by clicking on the Deploy button beside the repository name at Websites & Domains.
  • No deployment (repository hosting): There will be no deployment of files to the production site. This option could prove useful if you were to use a Git repository for storing and exchanging code.

How to Use Webhooks to Pull Automatically

Webhooks can be used to set up your remote repository to send Plesk notifications regarding specific events (such as pushing files to the repository). You can find more information on webhook management in GitHub or BitBucket in the official documentation.

Webhook URLs are made for a repository automatically. You should click Repository Settings if you want to see the webhook URL.

Copy and add the webhook URL to your remote repository. Set it up to be activated in case a push to the repository occurs. With this in effect, Plesk will be notified whenever a file is pushed to the remote repository. Files will be pulled automatically, negating the need to hit the Pull Updates button.

If an automatic deployment is set up for a repository, those files pulled will be deployed to the site instantly.

However, the webhook might fail when called through the HTTPS protocol if Plesk has been secured with a self-signed certificate. This is a result of SSL/TLS handshake problems. Specify the HTTP protocol in the webhook URL if this is the case.

How to Activate Extra Deployment Options

File publishing won’t be adequate to complete the deployment of a website in a lot of situations. For instance, when a framework such as Ruby on Rails is used, you might need to run a data migration task following deployment, using a command like this: bin/rails db:migrate.

Plesk provides you with the option to specify one or more extra commands that will run each time the files are deployed to the site. Navigate to Websites & Domains > Git, and click on Repository Settings. Choose Enable additional deploy actions, then enter one or more shell commands. These will run whenever deployment of the repository contents takes place. You should input each individual command in a fresh line.

Please be aware, though, that a chrooted environment will be used for running specified commands on Linux, if SSH access is prohibited for the domain’s system user. The home directory of the subscription’s system user will be used as the file system root for that subscription. No executable files outside the chroot jail will be run.

So, if the path to your site were /var/www/vhosts/example.com/httpdocs in a chrooted environment, the path would be ./httpdocs. You would be unable to execute commands outside one level above the /httpdocs directory.

How to View Commit Logs

If you want to view the entire commit history for the present branch, visit Websites & Domains > Git. Then, click on the Commit Logs link. This information will be presented for every commit:

  • unique identifier
  • time
  • user name
  • commit message

To update the commit log, hit Refresh.

The commit logs can be filtered by any parameter. For instance, you can view all the commits performed by a specific user beginning at a specific date. Click the “down arrow” button, input the relevant search parameters, and hit Search.

How to Change a Repository’s Name or Remove it

A repository can be renamed at any point. For example, you might opt to retitle a repository from website-dev to website once development has been finished, to avoid potential confusion. Make your way to Websites & Domains > Git and hit Repository Settings. Input the new name into the Repository name box.

What should you do if you want to take out the repository? Click on the Remote Repository link on the Git screen. Plesk will take out the repository, but the target directory with the published data will stay the same.

No comment yet, add your voice below!

Add a Comment

Your email address will not be published. Required fields are marked *

GET LATEST NEWS AND TIPS

  • Yes, please, I agree to receiving my personal Plesk Newsletter! WebPros International GmbH and other WebPros group companies may store and process the data I provide for the purpose of delivering the newsletter according to the WebPros Privacy Policy. In order to tailor its offerings to me, Plesk may further use additional information like usage and behavior data (Profiling). I can unsubscribe from the newsletter at any time by sending an email to [email protected] or use the unsubscribe link in any of the newsletters.

  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden
  • Hidden

Related Posts

Knowledge Base

Plesk uses LiveChat system (3rd party).

By proceeding below, I hereby agree to use LiveChat as an external third party technology. This may involve a transfer of my personal data (e.g. IP Address) to third parties in- or outside of Europe. For more information, please see our Privacy Policy.

Search
Generic filters
Exact matches only
Search in title
Search in content
Search in excerpt