File permission issue after git deployment

Discussion in 'Server Operation' started by yasine, Aug 21, 2024.

  1. yasine

    yasine Member

    I 've setup git deployment on my server, the bar repository is like so :
    Code:
    #!/bin/sh
    GIT_WORK_TREE=/var/www/preprod.kodingschools.com/web/wp-content git checkout -f main
    , but after every push, can not edit any file in FTP due to file permission issue ( upload_2024-8-21_8-50-14.png ) , I should after every deployment change the permission of wp-content folder and all subfolders and files,
    the permissions list for the web folder :
    Code:
    root@cloud:/var/www/preprod.kodingschools.com/web# ls -al
    total 292
    drwxr-xr-x 12 web3     client1  4096 Jul 24 19:32 .
    drwxr-xr-x 13 root     root     4096 Jun 27 19:12 ..
    -rwxr-xr-x  1 web3     client1   131 Jun 26 22:51 .htpasswd
    drwxrwxrwx  2 web3     client1  4096 Jul 16 17:32 .tmb
    drwxr-xr-x  4 web3     client1  4096 Jun 26 19:49 .well-known
    drwxr-xr-x  3 web3     client1  4096 Jun 26 19:49 .wp-cli
    -rw-r--r--  1 web3     client1     0 Jun 26 19:49 apple-touch-icon-precomposed.png
    -rw-r--r--  1 web3     client1     0 Jun 26 19:49 apple-touch-icon.png
    drwx------ 16 www-data root     4096 Jul 31 10:38 cache
    drwxr-xr-x  2 web3     client1  4096 Jun 26 19:49 cgi-bin
    drwxr-xr-x  2 web3     client1  4096 Jul 20 02:11 error
    -rw-r--r--  1 web3     client1     0 Jun 26 19:49 favicon.ico
    -rw-r--r--  1 web3     client1   405 Jun 28 17:56 index.php
    -rw-r--r--  1 web3     client1 19915 Jul 20 15:30 license.txt
    -rw-r--r--  1 web3     client1  3564 Jul 25 12:10 process-csv-batch.php
    -rw-r--r--  1 web3     client1  7409 Jul 20 15:30 readme.html
    -rwxr-xr--  1 web3     client1    14 Jun 10 13:50 robots.txt
    drwxr-xr-x  4 web3     client1  4096 Aug 21 00:02 stats
    -rw-r--r--  1 web3     client1   592 Jun 26 19:49 wordfence-waf.php
    -rw-r--r--  1 web3     client1  7387 Jun 26 19:49 wp-activate.php
    drwxr-xr-x  9 web3     client1  4096 Jun 26 19:49 wp-admin
    -rw-r--r--  1 web3     client1   351 Jun 26 19:49 wp-blog-header.php
    -rw-r--r--  1 web3     client1  2323 Jun 26 19:49 wp-comments-post.php
    -rw-r--r--  1 web3     client1  3033 Jul 20 15:30 wp-config-sample.php
    -rw-r--r--  1 web3     client1  3545 Aug 20 08:37 wp-config.php
    drwxrwxr-x 19 web3     client1  4096 Aug 20 19:07 wp-content
    -rw-r--r--  1 web3     client1  5638 Jun 26 19:49 wp-cron.php
    drwxr-xr-x 30 web3     client1 16384 Jul 20 15:30 wp-includes
    -rw-r--r--  1 web3     client1  2502 Jun 26 19:49 wp-links-opml.php
    -rw-r--r--  1 web3     client1  3937 Jul 20 15:30 wp-load.php
    -rw-r--r--  1 web3     client1 51238 Jul 20 15:30 wp-login.php
    -rw-r--r--  1 web3     client1  8525 Jun 26 19:49 wp-mail.php
    -rw-r--r--  1 web3     client1 28774 Jul 20 15:30 wp-settings.php
    -rw-r--r--  1 web3     client1 34385 Jun 26 19:49 wp-signup.php
    -rw-r--r--  1 web3     client1  4885 Jun 26 19:49 wp-trackback.php
    -rw-r--r--  1 web3     client1  3246 Jun 26 19:49 xmlrpc.php
    the problem is that the ownership of edited files change from
    Code:
    web3 client1
    to
    Code:
    root root
    Code:
     ls -al
    total 96
    drwxrwxr-x 3 web3 client1  4096 Aug 20 14:55 .
    drwxrwxr-x 6 web3 client1  4096 Aug 20 14:55 ..
    -rw-r--r-- 1 root root       11 Aug  9 00:37 assign.php
    -rw-r--r-- 1 root root    11457 Aug 20 14:55 bulk-import.php
    -rw-r--r-- 1 root root     9285 Aug 20 14:55 create.php
    -rw-r--r-- 1 root root        6 Aug  9 00:37 delete.php
    -rw-rw-r-- 1 root client1  8363 Jul 29 09:23 front-old.php
    -rw-r--r-- 1 root root    10069 Aug 20 14:55 front.php
    -rw-r--r-- 1 root root     4530 Aug  9 00:37 functions.php
    -rw-r--r-- 1 root root    17984 Aug  9 00:37 students-credentials.php
    drwxrwxr-x 3 web3 client1  4096 Jul 20 18:56 uploads
    is there any way to get rid of this problem ?
     
    Last edited: Aug 21, 2024
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Seems as if you run the checkout script as wrong user, you must run it as user web3. You can do this either by logging in as ssh user of this website (which you created in ISPConfig) or by using sudo in your checkout script
     
    ahrasis and yasine like this.

Share This Page