pocketarc / git-deploy-php

git-deploy-php is a simple php-based tool that deploys your Git repositories to FTP/SFTP servers, and keeps them updated automatically.
http://brunodebarros.github.io/git-deploy-php
292 stars 45 forks source link

Unable to make deploy using sftp #90

Open alcarazolabs opened 3 years ago

alcarazolabs commented 3 years ago

Hi, I just installed in a virtual machine using ubuntu 20 a sftp server and on there I have a apache server and all my projects are saved inside of "var/www/html". To test this tool "git-deploy-php" I created another virtual machine with ubuntu and installed on there php and git.. I tested my sftp server and is working correctly, I can make a connection using my second virtual machine were I want to make the deploy and I also tested my sftp server with windows 10 using Filezilla and again I was capabable of upload files inside of "html" folder of the apache server.

My sftp user has permissions for write inside of "var/www/html". I just created a folder with one index.html file which is the file that I want deploy in my server and also I created a .gitignore file to ignore this files "git-deploy.php and deploy.ini".

This is my deploy.ini code:

[example]
scheme = sftp

skip = false
user = "usuario_sftp"
pass = "123456"
host = "192.168.0.13"
port = 22
path = "/var/www/html/googleros"
passive = true

When I execute the git-deploy it was unable of uploade the index.html file, here is the logs:

devjunior@devjunior-pc:~/Documentos/proyects/googleros$ sudo php git-deploy deploy.ini
[2021-07-31 20:30:07 -0400] Connected to: sftp://usuario_sftp@192.168.0.13:22/var/www/html/googleros
[2021-07-31 20:30:07 -0400] Disconnected from: sftp://usuario_sftp@192.168.0.13:22/var/www/html/googleros
[2021-07-31 20:30:07 -0400] Started working on: sftp://usuario_sftp@192.168.0.13:22/var/www/html/googleros
[2021-07-31 20:30:07 -0400] Deploying to server for the first time...
[2021-07-31 20:30:07 -0400] Will upload 3 files.
[2021-07-31 20:30:07 -0400] Will delete 0 files.
[2021-07-31 20:30:12 -0400] Connected to: sftp://usuario_sftp@192.168.0.13:22/var/www/html/googleros
[2021-07-31 20:30:12 -0400] ERROR: Failed to upload index.html. Deployment will stop to allow you to check what went wrong.

It said: "ERROR: Failed to upload index.html. Deployment will stop to allow you to check what went wrong." Before of run this I init a repo "git init" then I did "git add ." and then git commit -m "first deploy". and the executed git-deploy

I checked my branch and his name is "master", I'm supposing that this branch will be deployed in the production server.

This is my project:

image

is composer required? In my production server I only installed an apache server, php and mysql, is the problem with this rule [example] I don't know it.

I don't know the reason why this happens, it is my first time using this tool. I will appreciate any idea to fix this problem. Thanks so much.

pocketarc commented 3 years ago

Does the googleros folder exist? That's the only thing that comes to my mind as the reason why it might've gone wrong.

Composer is not required, everything should work well.

If you're still having issues with this and that folder exists, let me know. I might be able to add some code to help explain what went wrong, since that error message is really not helpful at all.

alcarazolabs commented 3 years ago

Does the googleros folder exist? That's the only thing that comes to my mind as the reason why it might've gone wrong.

Composer is not required, everything should work well.

If you're still having issues with this and that folder exists, let me know. I might be able to add some code to help explain what went wrong, since that error message is really not helpful at all.

Thanks bro. The problem was in the path of the deploy.ini here I was using /var/www/html/googleros ok. But when I tried to run the deploy I couldn't go to googleros/ because in the configuration of the file sshd_config of the sftp server the rule ChrootDirecotry had this value /var/www/ it means that when an user make a connection by default will be positionate here inside of www/ but it can't go from /var/www/html/ then to fix this I updated my path of the deploy.ini to html/googleros and it worked!

[2021-08-04 13:11:41 -0400] Connected to: sftp://freddy@192.168.0.13:22/html/googleros
[2021-08-04 13:11:41 -0400] Disconnected from: sftp://freddy@192.168.0.13:22/html/googleros
[2021-08-04 13:11:41 -0400] Started working on: sftp://freddy@192.168.0.13:22/html/googleros
[2021-08-04 13:11:41 -0400] Deploying to server for the first time...
[2021-08-04 13:11:41 -0400] Will upload 4 files.
[2021-08-04 13:11:41 -0400] Will delete 0 files.
[2021-08-04 13:11:42 -0400] Connected to: sftp://freddy@192.168.0.13:22/html/googleros
[2021-08-04 13:11:42 -0400] Uploaded: index.html
[2021-08-04 13:11:42 -0400] Uploaded: phploy.ini
[2021-08-04 13:11:42 -0400] Uploaded: REVISION
[2021-08-04 13:11:42 -0400] Uploaded: PREVIOUS_REVISION
[2021-08-04 13:11:42 -0400] Finished working on: sftp://freddy@192.168.0.13:22/html/googleros
[2021-08-04 13:11:42 -0400] Disconnected from: sftp://freddy@192.168.0.13:22/html/googleros

In general, what problems can have tool present? can you upload large files? files named with spaces? what should I know that I don't currently know.

Thanks.

The tool should allow you to create the folder on the production server if it doesn't exist. You could do something like git-deploy --force and it should create the directory inside the server and then run the deploy.

pocketarc commented 3 years ago

@alcarazolabs You shouldn't have any issues with uploads of files, regardless of size, spaces, anything like that. Everything should just work.

As for creating the folder if it doesn't exist, that's an interesting idea, but when the folder doesn't exist it's usually an issue with configuration (just like it was for you). Imagine if the tool had deployed thousands of files files to /var/www/html/etc inside your /var/www because of ChrootDirectory (so it'd become /var/www/var/www/html/googleros). It's best to not try and get too clever in situations like this.