Assuming you have your project repository in Gitlab, and a Plesk hosting interface to work with, follow these steps to create a CI/CD between your gitlab repository and your hosting panel, and publishing automagically your laravel application.
Before you begin, some details:
- If not available, ask your hosting provider to install the GIT Plesk extension. It's free and it's mandatory, to make this CI/CD work.
- Plesk has a default webroot public folder for your website, called 'httpdocs'. We will instead use the default laravel 'public' folder. So, enter your plesk admin panel, and click the Hosting Settings link. Change the value in the interface, as you see in this screenshot:
- Open your project subscription in Plesk;
- Click the GIT icon (if not installed, proceed to install the GIT extension, or ask your hosting provider to do so)
- Click to Add Repository
- Enter the gitlab ssh or the https address in the repository URL
Plesk will generate a ssh public key, maybe it will be already automatically copied in your clipboard. Copy it.
- Go to your gitlab project, then go to settings -> repository, then click the Expand button of the 'Deploy Keys' section.
- Insert a name for your key, then paste the copied key in the field below. Check the 'Grant write permission to this key' option, then click the 'add key' button below.
- Return to your plesk interface, then click again the Git icon. You will find a panel like this one below:
here you can change which branch will be published on your web server. Choose the one you need.
Next, we will change the default deployment location. Click the settings icon in the lower right corner of the panel, then change the Server Path leaving a simple slash /, removing the default folder, 'httpdocs'.
- click the Deploy now button to pull the git files onto the web server root.
Finally, you will need to make your laravel application work within your plesk hosting, running composer and npm. Refer to this article.
Top comments (0)