diff --git a/backend/app/service/website_utils.go b/backend/app/service/website_utils.go index 0bd235fcb..0fe47b38c 100644 --- a/backend/app/service/website_utils.go +++ b/backend/app/service/website_utils.go @@ -2,6 +2,7 @@ package service import ( "fmt" + "github.com/1Panel-dev/1Panel/backend/utils/cmd" "path" "strconv" "strings" @@ -58,8 +59,6 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error { if runtime.Type == constant.RuntimePHP { indexPath = path.Join(indexFolder, "index.php") indexContent = string(nginx_conf.IndexPHP) - } else { - return nil } } @@ -74,6 +73,11 @@ func createIndexFile(website *model.Website, runtime *model.Runtime) error { return err } } + if runtime.Resource == constant.ResourceAppstore { + if err := chownRootDir(indexFolder); err != nil { + return err + } + } if err := fileOp.WriteFile(indexPath, strings.NewReader(indexContent), 0755); err != nil { return err } @@ -97,19 +101,21 @@ func createWebsiteFolder(nginxInstall model.AppInstall, website *model.Website, if err := fileOp.CreateFile(path.Join(siteFolder, "log", "error.log")); err != nil { return err } - if err := fileOp.CreateDir(path.Join(siteFolder, "index"), 0755); err != nil { + if err := fileOp.CreateDir(path.Join(siteFolder, "index"), 0775); err != nil { return err } if err := fileOp.CreateDir(path.Join(siteFolder, "ssl"), 0755); err != nil { return err } - if website.Type == constant.Runtime && runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceLocal { - phpPoolDir := path.Join(siteFolder, "php-pool") - if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil { - return err - } - if err := fileOp.CreateFile(path.Join(phpPoolDir, "php-fpm.sock")); err != nil { - return err + if website.Type == constant.Runtime { + if runtime.Type == constant.RuntimePHP && runtime.Resource == constant.ResourceLocal { + phpPoolDir := path.Join(siteFolder, "php-pool") + if err := fileOp.CreateDir(phpPoolDir, 0755); err != nil { + return err + } + if err := fileOp.CreateFile(path.Join(phpPoolDir, "php-fpm.sock")); err != nil { + return err + } } } if website.Type == constant.Static || website.Type == constant.Runtime { @@ -505,3 +511,11 @@ func checkIsLinkApp(website model.Website) bool { } return false } + +func chownRootDir(path string) error { + _, err := cmd.ExecWithTimeOut(fmt.Sprintf("chown -R 1000:1000 %s", path), 1*time.Second) + if err != nil { + return err + } + return nil +}