From 9fbb63df954642aa735a9dc004da0863cf0d150a Mon Sep 17 00:00:00 2001 From: CityFun <31820853+zhengkunwang223@users.noreply.github.com> Date: Thu, 26 Jun 2025 16:31:23 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Resolve=20command=20execution=20failures?= =?UTF-8?q?=20in=20the=20PHP=20runtime=20environmen=E2=80=A6=20(#9299)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refs https://github.com/1Panel-dev/1Panel/issues/9286 --- agent/app/service/runtime.go | 1 + agent/app/service/runtime_utils.go | 17 ++++++++++++++++- .../website/runtime/components/terminal.vue | 3 ++- .../src/views/website/runtime/php/index.vue | 2 +- 4 files changed, 20 insertions(+), 3 deletions(-) diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index fb76456c0..29c820763 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -743,6 +743,7 @@ func (r *RuntimeService) InstallPHPExtension(req request.PHPExtensionInstallReq) } } } + handlePHPDir(*runtime) if err = restartRuntime(runtime); err != nil { return err } diff --git a/agent/app/service/runtime_utils.go b/agent/app/service/runtime_utils.go index c488e2409..b4302377f 100644 --- a/agent/app/service/runtime_utils.go +++ b/agent/app/service/runtime_utils.go @@ -89,7 +89,7 @@ func handlePHP(create request.RuntimeCreate, runtime *model.Runtime, fileOp file version, ok := create.Params["PHP_VERSION"] if ok { extensionsDir := path.Join(projectDir, "extensions", getExtensionDir(version.(string))) - _ = fileOp.CreateDir(extensionsDir, 0644) + _ = fileOp.CreateDir(extensionsDir, 0755) } composeContent, envContent, forms, err := handleParams(create, projectDir) @@ -401,6 +401,7 @@ func buildRuntime(runtime *model.Runtime, oldImageID string, oldEnv string, rebu if deleteImageID != "" { deleteImageByID(deleteImageID, runtime.Image, client) } + handlePHPDir(*runtime) if out, err := compose.DownAndUp(composePath); err != nil { runtime.Status = constant.StatusStartErr runtime.Message = out @@ -987,3 +988,17 @@ func handleRuntimeDTO(res *response.RuntimeDTO, runtime model.Runtime) error { } return nil } + +func handlePHPDir(runtime model.Runtime) { + fileOp := files.NewFileOp() + dirs := []string{ + path.Join(runtime.GetPath(), "conf"), + path.Join(runtime.GetPath(), "extensions"), + path.Join(runtime.GetPath(), "composer"), + path.Join(runtime.GetPath(), "log"), + } + for _, dir := range dirs { + _ = fileOp.ChmodR(dir, 0755, true) + _ = fileOp.ChownR(dir, strconv.Itoa(1000), strconv.Itoa(1000), true) + } +} diff --git a/frontend/src/views/website/runtime/components/terminal.vue b/frontend/src/views/website/runtime/components/terminal.vue index 29dab572e..bbe844635 100644 --- a/frontend/src/views/website/runtime/components/terminal.vue +++ b/frontend/src/views/website/runtime/components/terminal.vue @@ -41,13 +41,14 @@ const terminalRef = ref | null>(null); interface DialogProps { containerID: string; container: string; + user: string; } const acceptParams = async (params: DialogProps): Promise => { terminalVisible.value = true; form.containerID = params.containerID; title.value = params.container; form.isCustom = false; - form.user = ''; + form.user = params.user; form.command = '/bin/bash'; initTerm(); }; diff --git a/frontend/src/views/website/runtime/php/index.vue b/frontend/src/views/website/runtime/php/index.vue index 2f50bacbe..a8a535be4 100644 --- a/frontend/src/views/website/runtime/php/index.vue +++ b/frontend/src/views/website/runtime/php/index.vue @@ -296,7 +296,7 @@ const openSupervisor = (row: Runtime.Runtime) => { const openTerminal = (row: Runtime.Runtime) => { const container = row.params['CONTAINER_NAME']; - terminalRef.value.acceptParams({ containerID: container, container: container }); + terminalRef.value.acceptParams({ containerID: container, container: container, user: 'www-data' }); }; const openLog = (row: Runtime.RuntimeDTO) => {