diff --git a/agent/app/api/v2/runtime.go b/agent/app/api/v2/runtime.go index 344b3774c..378d169ef 100644 --- a/agent/app/api/v2/runtime.go +++ b/agent/app/api/v2/runtime.go @@ -297,3 +297,89 @@ func (b *BaseApi) UnInstallPHPExtension(c *gin.Context) { } helper.SuccessWithOutData(c) } + +// @Tags Runtime +// @Summary Load php runtime conf +// @Description 获取 php 运行环境配置 +// @Accept json +// @Param id path integer true "request" +// @Success 200 {object} response.PHPConfig +// @Security ApiKeyAuth +// @Router /runtimes/php/config/:id [get] +func (b *BaseApi) GetPHPConfig(c *gin.Context) { + id, err := helper.GetParamID(c) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil) + return + } + data, err := runtimeService.GetPHPConfig(id) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, data) +} + +// @Tags Runtime +// @Summary Update runtime php conf +// @Description 更新运行环境 PHP 配置 +// @Accept json +// @Param request body request.PHPConfigUpdate true "request" +// @Success 200 +// @Security ApiKeyAuth +// @Router /runtimes/php/config [post] +// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"} +func (b *BaseApi) UpdatePHPConfig(c *gin.Context) { + var req request.PHPConfigUpdate + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + if err := runtimeService.UpdatePHPConfig(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} + +// @Tags Runtime +// @Summary Update php conf file +// @Description 更新 php 配置文件 +// @Accept json +// @Param request body request.WebsitePHPFileUpdate true "request" +// @Success 200 +// @Security ApiKeyAuth +// @Router /runtimes/php/update [post] +// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"} +func (b *BaseApi) UpdatePHPFile(c *gin.Context) { + var req request.PHPFileUpdate + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + if err := runtimeService.UpdatePHPConfigFile(req); err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, nil) +} + +// 写一个调用 GetPHPConfigFile 的方法 +// @Tags Runtime +// @Summary Get php conf file +// @Description 获取 php 配置文件 +// @Accept json +// @Param request body request.PHPFileReq true "request" +// @Success 200 +// @Security ApiKeyAuth +// @Router /runtimes/php/file [post] +func (b *BaseApi) GetPHPConfigFile(c *gin.Context) { + var req request.PHPFileReq + if err := helper.CheckBindAndValidate(&req, c); err != nil { + return + } + data, err := runtimeService.GetPHPConfigFile(req) + if err != nil { + helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) + return + } + helper.SuccessWithData(c, data) +} diff --git a/agent/app/api/v2/website.go b/agent/app/api/v2/website.go index 084c00197..36ab1ccdd 100644 --- a/agent/app/api/v2/website.go +++ b/agent/app/api/v2/website.go @@ -373,70 +373,6 @@ func (b *BaseApi) ChangeDefaultServer(c *gin.Context) { helper.SuccessWithData(c, nil) } -// @Tags Website -// @Summary Load website php conf -// @Description 获取网站 php 配置 -// @Accept json -// @Param id path integer true "request" -// @Success 200 {object} response.PHPConfig -// @Security ApiKeyAuth -// @Router /websites/php/config/:id [get] -func (b *BaseApi) GetWebsitePHPConfig(c *gin.Context) { - id, err := helper.GetParamID(c) - if err != nil { - helper.ErrorWithDetail(c, constant.CodeErrBadRequest, constant.ErrTypeInternalServer, nil) - return - } - data, err := websiteService.GetPHPConfig(id) - if err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } - helper.SuccessWithData(c, data) -} - -// @Tags Website PHP -// @Summary Update website php conf -// @Description 更新 网站 PHP 配置 -// @Accept json -// @Param request body request.WebsitePHPConfigUpdate true "request" -// @Success 200 -// @Security ApiKeyAuth -// @Router /websites/php/config [post] -// @x-panel-log {"bodyKeys":["id"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"id","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"[domain] PHP 配置修改","formatEN":"[domain] PHP conf update"} -func (b *BaseApi) UpdateWebsitePHPConfig(c *gin.Context) { - var req request.WebsitePHPConfigUpdate - if err := helper.CheckBindAndValidate(&req, c); err != nil { - return - } - if err := websiteService.UpdatePHPConfig(req); err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } - helper.SuccessWithData(c, nil) -} - -// @Tags Website PHP -// @Summary Update php conf -// @Description 更新 php 配置文件 -// @Accept json -// @Param request body request.WebsitePHPFileUpdate true "request" -// @Success 200 -// @Security ApiKeyAuth -// @Router /websites/php/update [post] -// @x-panel-log {"bodyKeys":["websiteId"],"paramKeys":[],"BeforeFunctions":[{"input_column":"id","input_value":"websiteId","isList":false,"db":"websites","output_column":"primary_domain","output_value":"domain"}],"formatZH":"php 配置修改 [domain]","formatEN":"Nginx conf update [domain]"} -func (b *BaseApi) UpdatePHPFile(c *gin.Context) { - var req request.WebsitePHPFileUpdate - if err := helper.CheckBindAndValidate(&req, c); err != nil { - return - } - if err := websiteService.UpdatePHPConfigFile(req); err != nil { - helper.ErrorWithDetail(c, constant.CodeErrInternalServer, constant.ErrTypeInternalServer, err) - return - } - helper.SuccessWithData(c, nil) -} - // @Tags Website PHP // @Summary Update php version // @Description 变更 php 版本 diff --git a/agent/app/dto/request/runtime.go b/agent/app/dto/request/runtime.go index 3300a44e6..23c288648 100644 --- a/agent/app/dto/request/runtime.go +++ b/agent/app/dto/request/runtime.go @@ -76,3 +76,22 @@ type PHPExtensionInstallReq struct { Name string `json:"name" validate:"required"` TaskID string `json:"taskID"` } + +type PHPConfigUpdate struct { + ID uint `json:"id" validate:"required"` + Params map[string]string `json:"params"` + Scope string `json:"scope" validate:"required"` + DisableFunctions []string `json:"disableFunctions"` + UploadMaxSize string `json:"uploadMaxSize"` +} + +type PHPFileUpdate struct { + ID uint `json:"id" validate:"required"` + Type string `json:"type" validate:"required"` + Content string `json:"content" validate:"required"` +} + +type PHPFileReq struct { + ID uint `json:"id" validate:"required"` + Type string `json:"type" validate:"required"` +} diff --git a/agent/app/dto/request/website.go b/agent/app/dto/request/website.go index 1fef31e04..2ed599cd3 100644 --- a/agent/app/dto/request/website.go +++ b/agent/app/dto/request/website.go @@ -181,20 +181,6 @@ type WebsiteDefaultUpdate struct { ID uint `json:"id"` } -type WebsitePHPConfigUpdate struct { - ID uint `json:"id" validate:"required"` - Params map[string]string `json:"params"` - Scope string `json:"scope" validate:"required"` - DisableFunctions []string `json:"disableFunctions"` - UploadMaxSize string `json:"uploadMaxSize"` -} - -type WebsitePHPFileUpdate struct { - ID uint `json:"id" validate:"required"` - Type string `json:"type" validate:"required"` - Content string `json:"content" validate:"required"` -} - type WebsitePHPVersionReq struct { WebsiteID uint `json:"websiteID" validate:"required"` RuntimeID uint `json:"runtimeID" validate:"required"` diff --git a/agent/app/service/runtime.go b/agent/app/service/runtime.go index fbf12386c..206c9c4c5 100644 --- a/agent/app/service/runtime.go +++ b/agent/app/service/runtime.go @@ -1,11 +1,13 @@ package service import ( + "bufio" "context" "encoding/json" "fmt" "github.com/1Panel-dev/1Panel/agent/app/task" "github.com/1Panel-dev/1Panel/agent/cmd/server/nginx_conf" + "gopkg.in/ini.v1" "os" "path" "path/filepath" @@ -51,6 +53,10 @@ type IRuntimeService interface { GetPHPExtensions(runtimeID uint) (response.PHPExtensionRes, error) InstallPHPExtension(req request.PHPExtensionInstallReq) error UnInstallPHPExtension(req request.PHPExtensionInstallReq) error + GetPHPConfig(id uint) (*response.PHPConfig, error) + UpdatePHPConfig(req request.PHPConfigUpdate) (err error) + UpdatePHPConfigFile(req request.PHPFileUpdate) error + GetPHPConfigFile(req request.PHPFileReq) (*response.FileInfo, error) } func NewRuntimeService() IRuntimeService { @@ -744,3 +750,163 @@ func (r *RuntimeService) UnInstallPHPExtension(req request.PHPExtensionInstallRe } return runtimeRepo.Save(runtime) } + +func (r *RuntimeService) GetPHPConfig(id uint) (*response.PHPConfig, error) { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(id)) + if err != nil { + return nil, err + } + phpConfigPath := path.Join(runtime.GetPath(), "conf", "php.ini") + fileOp := files.NewFileOp() + if !fileOp.Stat(phpConfigPath) { + return nil, buserr.WithName("ErrFileNotFound", "php.ini") + } + params := make(map[string]string) + configFile, err := fileOp.OpenFile(phpConfigPath) + if err != nil { + return nil, err + } + defer configFile.Close() + scanner := bufio.NewScanner(configFile) + for scanner.Scan() { + line := strings.TrimSpace(scanner.Text()) + if strings.HasPrefix(line, ";") { + continue + } + matches := regexp.MustCompile(`^\s*([a-z_]+)\s*=\s*(.*)$`).FindStringSubmatch(line) + if len(matches) == 3 { + params[matches[1]] = matches[2] + } + } + cfg, err := ini.Load(phpConfigPath) + if err != nil { + return nil, err + } + phpConfig, err := cfg.GetSection("PHP") + if err != nil { + return nil, err + } + disableFunctionStr := phpConfig.Key("disable_functions").Value() + res := &response.PHPConfig{Params: params} + if disableFunctionStr != "" { + disableFunctions := strings.Split(disableFunctionStr, ",") + if len(disableFunctions) > 0 { + res.DisableFunctions = disableFunctions + } + } + uploadMaxSize := phpConfig.Key("upload_max_filesize").Value() + if uploadMaxSize != "" { + res.UploadMaxSize = uploadMaxSize + } + return res, nil +} + +func (r *RuntimeService) UpdatePHPConfig(req request.PHPConfigUpdate) (err error) { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return err + } + phpConfigPath := path.Join(runtime.GetPath(), "conf", "php.ini") + fileOp := files.NewFileOp() + if !fileOp.Stat(phpConfigPath) { + return buserr.WithMap("ErrFileNotFound", map[string]interface{}{"name": "php.ini"}, nil) + } + configFile, err := fileOp.OpenFile(phpConfigPath) + if err != nil { + return err + } + defer configFile.Close() + + contentBytes, err := fileOp.GetContent(phpConfigPath) + if err != nil { + return err + } + + content := string(contentBytes) + lines := strings.Split(content, "\n") + for i, line := range lines { + if strings.HasPrefix(line, ";") { + continue + } + switch req.Scope { + case "params": + for key, value := range req.Params { + pattern := "^" + regexp.QuoteMeta(key) + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(pattern, line); matched { + lines[i] = key + " = " + value + } + } + case "disable_functions": + pattern := "^" + regexp.QuoteMeta("disable_functions") + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(pattern, line); matched { + lines[i] = "disable_functions" + " = " + strings.Join(req.DisableFunctions, ",") + break + } + case "upload_max_filesize": + pattern := "^" + regexp.QuoteMeta("post_max_size") + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(pattern, line); matched { + lines[i] = "post_max_size" + " = " + req.UploadMaxSize + } + patternUpload := "^" + regexp.QuoteMeta("upload_max_filesize") + "\\s*=\\s*.*$" + if matched, _ := regexp.MatchString(patternUpload, line); matched { + lines[i] = "upload_max_filesize" + " = " + req.UploadMaxSize + } + } + } + updatedContent := strings.Join(lines, "\n") + if err := fileOp.WriteFile(phpConfigPath, strings.NewReader(updatedContent), 0755); err != nil { + return err + } + + err = r.OperateRuntime(request.RuntimeOperate{ + Operate: constant.RuntimeRestart, + ID: req.ID, + }) + if err != nil { + _ = fileOp.WriteFile(phpConfigPath, strings.NewReader(string(contentBytes)), 0755) + return err + } + return +} + +func (r *RuntimeService) GetPHPConfigFile(req request.PHPFileReq) (*response.FileInfo, error) { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return nil, err + } + configPath := "" + switch req.Type { + case constant.ConfigFPM: + configPath = path.Join(runtime.GetPath(), "conf", "php-fpm.conf") + case constant.ConfigPHP: + configPath = path.Join(runtime.GetPath(), "conf", "php.ini") + } + info, err := files.NewFileInfo(files.FileOption{ + Path: configPath, + Expand: true, + }) + if err != nil { + return nil, err + } + return &response.FileInfo{FileInfo: *info}, nil +} + +func (r *RuntimeService) UpdatePHPConfigFile(req request.PHPFileUpdate) error { + runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(req.ID)) + if err != nil { + return err + } + configPath := "" + if req.Type == constant.ConfigFPM { + configPath = path.Join(runtime.GetPath(), "conf", "php-fpm.conf") + } else { + configPath = path.Join(runtime.GetPath(), "conf", "php.ini") + } + if err := files.NewFileOp().WriteFile(configPath, strings.NewReader(req.Content), 0755); err != nil { + return err + } + if _, err := compose.Restart(runtime.GetComposePath()); err != nil { + return err + } + return nil +} diff --git a/agent/app/service/website.go b/agent/app/service/website.go index c24a2da9d..a443259e3 100644 --- a/agent/app/service/website.go +++ b/agent/app/service/website.go @@ -31,23 +31,21 @@ import ( "github.com/1Panel-dev/1Panel/agent/utils/env" "github.com/1Panel-dev/1Panel/agent/app/api/v2/helper" + "github.com/1Panel-dev/1Panel/agent/app/dto" "github.com/1Panel-dev/1Panel/agent/app/dto/request" "github.com/1Panel-dev/1Panel/agent/app/dto/response" + "github.com/1Panel-dev/1Panel/agent/app/model" "github.com/1Panel-dev/1Panel/agent/app/repo" "github.com/1Panel-dev/1Panel/agent/buserr" "github.com/1Panel-dev/1Panel/agent/cmd/server/nginx_conf" + "github.com/1Panel-dev/1Panel/agent/constant" "github.com/1Panel-dev/1Panel/agent/global" "github.com/1Panel-dev/1Panel/agent/utils/cmd" + "github.com/1Panel-dev/1Panel/agent/utils/files" "github.com/1Panel-dev/1Panel/agent/utils/nginx" "github.com/1Panel-dev/1Panel/agent/utils/nginx/components" "github.com/1Panel-dev/1Panel/agent/utils/nginx/parser" "golang.org/x/crypto/bcrypt" - "gopkg.in/ini.v1" - - "github.com/1Panel-dev/1Panel/agent/app/dto" - "github.com/1Panel-dev/1Panel/agent/app/model" - "github.com/1Panel-dev/1Panel/agent/constant" - "github.com/1Panel-dev/1Panel/agent/utils/files" ) type WebsiteService struct { @@ -78,9 +76,6 @@ type IWebsiteService interface { ChangeDefaultServer(id uint) error PreInstallCheck(req request.WebsiteInstallCheckReq) ([]response.WebsitePreInstallCheck, error) - GetPHPConfig(id uint) (*response.PHPConfig, error) - UpdatePHPConfig(req request.WebsitePHPConfigUpdate) error - UpdatePHPConfigFile(req request.WebsitePHPFileUpdate) error ChangePHPVersion(req request.WebsitePHPVersionReq) error GetRewriteConfig(req request.NginxRewriteReq) (*response.NginxRewriteRes, error) @@ -1319,167 +1314,6 @@ func (w WebsiteService) ChangeDefaultServer(id uint) error { return nil } -func (w WebsiteService) GetPHPConfig(id uint) (*response.PHPConfig, error) { - website, err := websiteRepo.GetFirst(commonRepo.WithByID(id)) - if err != nil { - return nil, err - } - appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) - if err != nil { - return nil, err - } - phpConfigPath := path.Join(appInstall.GetPath(), "conf", "php.ini") - fileOp := files.NewFileOp() - if !fileOp.Stat(phpConfigPath) { - return nil, buserr.WithMap("ErrFileNotFound", map[string]interface{}{"name": "php.ini"}, nil) - } - params := make(map[string]string) - configFile, err := fileOp.OpenFile(phpConfigPath) - if err != nil { - return nil, err - } - defer configFile.Close() - scanner := bufio.NewScanner(configFile) - for scanner.Scan() { - line := strings.TrimSpace(scanner.Text()) - if strings.HasPrefix(line, ";") { - continue - } - matches := regexp.MustCompile(`^\s*([a-z_]+)\s*=\s*(.*)$`).FindStringSubmatch(line) - if len(matches) == 3 { - params[matches[1]] = matches[2] - } - } - cfg, err := ini.Load(phpConfigPath) - if err != nil { - return nil, err - } - phpConfig, err := cfg.GetSection("PHP") - if err != nil { - return nil, err - } - disableFunctionStr := phpConfig.Key("disable_functions").Value() - res := &response.PHPConfig{Params: params} - if disableFunctionStr != "" { - disableFunctions := strings.Split(disableFunctionStr, ",") - if len(disableFunctions) > 0 { - res.DisableFunctions = disableFunctions - } - } - uploadMaxSize := phpConfig.Key("upload_max_filesize").Value() - if uploadMaxSize != "" { - res.UploadMaxSize = uploadMaxSize - } - return res, nil -} - -func (w WebsiteService) UpdatePHPConfig(req request.WebsitePHPConfigUpdate) (err error) { - website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID)) - if err != nil { - return err - } - appInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) - if err != nil { - return err - } - phpConfigPath := path.Join(appInstall.GetPath(), "conf", "php.ini") - fileOp := files.NewFileOp() - if !fileOp.Stat(phpConfigPath) { - return buserr.WithMap("ErrFileNotFound", map[string]interface{}{"name": "php.ini"}, nil) - } - configFile, err := fileOp.OpenFile(phpConfigPath) - if err != nil { - return err - } - defer configFile.Close() - - contentBytes, err := fileOp.GetContent(phpConfigPath) - if err != nil { - return err - } - - content := string(contentBytes) - lines := strings.Split(content, "\n") - for i, line := range lines { - if strings.HasPrefix(line, ";") { - continue - } - switch req.Scope { - case "params": - for key, value := range req.Params { - pattern := "^" + regexp.QuoteMeta(key) + "\\s*=\\s*.*$" - if matched, _ := regexp.MatchString(pattern, line); matched { - lines[i] = key + " = " + value - } - } - case "disable_functions": - pattern := "^" + regexp.QuoteMeta("disable_functions") + "\\s*=\\s*.*$" - if matched, _ := regexp.MatchString(pattern, line); matched { - lines[i] = "disable_functions" + " = " + strings.Join(req.DisableFunctions, ",") - break - } - case "upload_max_filesize": - pattern := "^" + regexp.QuoteMeta("post_max_size") + "\\s*=\\s*.*$" - if matched, _ := regexp.MatchString(pattern, line); matched { - lines[i] = "post_max_size" + " = " + req.UploadMaxSize - } - patternUpload := "^" + regexp.QuoteMeta("upload_max_filesize") + "\\s*=\\s*.*$" - if matched, _ := regexp.MatchString(patternUpload, line); matched { - lines[i] = "upload_max_filesize" + " = " + req.UploadMaxSize - } - } - } - updatedContent := strings.Join(lines, "\n") - if err := fileOp.WriteFile(phpConfigPath, strings.NewReader(updatedContent), 0755); err != nil { - return err - } - - appInstallReq := request.AppInstalledOperate{ - InstallId: appInstall.ID, - Operate: constant.Restart, - } - if err = NewIAppInstalledService().Operate(appInstallReq); err != nil { - _ = fileOp.WriteFile(phpConfigPath, strings.NewReader(string(contentBytes)), 0755) - return err - } - - return nil -} - -func (w WebsiteService) UpdatePHPConfigFile(req request.WebsitePHPFileUpdate) error { - website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.ID)) - if err != nil { - return err - } - if website.Type != constant.Runtime { - return nil - } - runtime, err := runtimeRepo.GetFirst(commonRepo.WithByID(website.RuntimeID)) - if err != nil { - return err - } - if runtime.Resource != constant.ResourceAppstore { - return nil - } - runtimeInstall, err := appInstallRepo.GetFirst(commonRepo.WithByID(website.AppInstallID)) - if err != nil { - return err - } - configPath := "" - if req.Type == constant.ConfigFPM { - configPath = path.Join(runtimeInstall.GetPath(), "conf", "php-fpm.conf") - } else { - configPath = path.Join(runtimeInstall.GetPath(), "conf", "php.ini") - } - if err := files.NewFileOp().WriteFile(configPath, strings.NewReader(req.Content), 0755); err != nil { - return err - } - if _, err := compose.Restart(runtimeInstall.GetComposePath()); err != nil { - return err - } - return nil -} - func (w WebsiteService) ChangePHPVersion(req request.WebsitePHPVersionReq) error { website, err := websiteRepo.GetFirst(commonRepo.WithByID(req.WebsiteID)) if err != nil { diff --git a/agent/router/ro_runtime.go b/agent/router/ro_runtime.go index 420b404a1..6bf4e668e 100644 --- a/agent/router/ro_runtime.go +++ b/agent/router/ro_runtime.go @@ -34,6 +34,11 @@ func (r *RuntimeRouter) InitRouter(Router *gin.RouterGroup) { groupRouter.GET("/php/:id/extensions", baseApi.GetRuntimeExtension) groupRouter.POST("/php/extensions/install", baseApi.InstallPHPExtension) groupRouter.POST("/php/extensions/uninstall", baseApi.UnInstallPHPExtension) + + groupRouter.GET("/php/config/:id", baseApi.GetPHPConfig) + groupRouter.POST("/php/config", baseApi.UpdatePHPConfig) + groupRouter.POST("/php/update", baseApi.UpdatePHPFile) + groupRouter.POST("/php/file", baseApi.GetPHPConfigFile) } } diff --git a/agent/router/ro_website.go b/agent/router/ro_website.go index ff7b5af6c..a70a028d1 100644 --- a/agent/router/ro_website.go +++ b/agent/router/ro_website.go @@ -39,11 +39,6 @@ func (a *WebsiteRouter) InitRouter(Router *gin.RouterGroup) { websiteRouter.GET("/:id/https", baseApi.GetHTTPSConfig) websiteRouter.POST("/:id/https", baseApi.UpdateHTTPSConfig) - websiteRouter.GET("/php/config/:id", baseApi.GetWebsitePHPConfig) - websiteRouter.POST("/php/config", baseApi.UpdateWebsitePHPConfig) - websiteRouter.POST("/php/update", baseApi.UpdatePHPFile) - websiteRouter.POST("/php/version", baseApi.ChangePHPVersion) - websiteRouter.POST("/rewrite", baseApi.GetRewriteConfig) websiteRouter.POST("/rewrite/update", baseApi.UpdateRewriteConfig) diff --git a/frontend/src/api/interface/runtime.ts b/frontend/src/api/interface/runtime.ts index a0a0e2b3f..643a29c76 100644 --- a/frontend/src/api/interface/runtime.ts +++ b/frontend/src/api/interface/runtime.ts @@ -141,4 +141,29 @@ export namespace Runtime { id: number; taskID?: string; } + + export interface PHPConfig { + params: any; + disableFunctions: string[]; + uploadMaxSize: string; + } + + export interface PHPConfigUpdate { + id: number; + params?: any; + disableFunctions?: string[]; + scope: string; + uploadMaxSize?: string; + } + + export interface PHPUpdate { + id: number; + content: string; + type: string; + } + + export interface PHPFileReq { + id: number; + type: string; + } } diff --git a/frontend/src/api/interface/website.ts b/frontend/src/api/interface/website.ts index f186d59c2..487ab397e 100644 --- a/frontend/src/api/interface/website.ts +++ b/frontend/src/api/interface/website.ts @@ -331,27 +331,6 @@ export namespace Website { export interface DefaultServerUpdate { id: number; } - - export interface PHPConfig { - params: any; - disableFunctions: string[]; - uploadMaxSize: string; - } - - export interface PHPConfigUpdate { - id: number; - params?: any; - disableFunctions?: string[]; - scope: string; - uploadMaxSize?: string; - } - - export interface PHPUpdate { - id: number; - content: string; - type: string; - } - export interface RewriteReq { websiteID: number; name: string; diff --git a/frontend/src/api/modules/runtime.ts b/frontend/src/api/modules/runtime.ts index 3b7cb3cf8..dcf904052 100644 --- a/frontend/src/api/modules/runtime.ts +++ b/frontend/src/api/modules/runtime.ts @@ -3,6 +3,7 @@ import { ResPage, ReqPage } from '../interface'; import { Runtime } from '../interface/runtime'; import { TimeoutEnum } from '@/enums/http-enum'; import { App } from '@/api/interface/app'; +import { File } from '../interface/file'; export const SearchRuntimes = (req: Runtime.RuntimeReq) => { return http.post>(`/runtimes/search`, req); @@ -79,3 +80,19 @@ export const InstallPHPExtension = (req: Runtime.PHPExtensionInstall) => { export const UnInstallPHPExtension = (req: Runtime.PHPExtensionInstall) => { return http.post(`/runtimes/php/extensions/uninstall`, req); }; + +export const GetPHPConfig = (id: number) => { + return http.get(`/runtimes/php/config/${id}`); +}; + +export const UpdatePHPConfig = (req: Runtime.PHPConfigUpdate) => { + return http.post(`/runtimes/php/config/`, req); +}; + +export const UpdatePHPFile = (req: Runtime.PHPUpdate) => { + return http.post(`/runtimes/php/update`, req); +}; + +export const GetPHPConfigFile = (req: Runtime.PHPFileReq) => { + return http.post(`/runtimes/php/file`, req); +}; diff --git a/frontend/src/api/modules/website.ts b/frontend/src/api/modules/website.ts index 773cd1da1..670d553ba 100644 --- a/frontend/src/api/modules/website.ts +++ b/frontend/src/api/modules/website.ts @@ -162,18 +162,6 @@ export const ChangeDefaultServer = (req: Website.DefaultServerUpdate) => { return http.post(`/websites/default/server`, req); }; -export const GetPHPConfig = (id: number) => { - return http.get(`/websites/php/config/${id}`); -}; - -export const UpdatePHPConfig = (req: Website.PHPConfigUpdate) => { - return http.post(`/websites/php/config/`, req); -}; - -export const UpdatePHPFile = (req: Website.PHPUpdate) => { - return http.post(`/websites/php/update`, req); -}; - export const GetRewriteConfig = (req: Website.RewriteReq) => { return http.post(`/websites/rewrite`, req); }; diff --git a/frontend/src/lang/modules/en.ts b/frontend/src/lang/modules/en.ts index 41f19795a..33120ac13 100644 --- a/frontend/src/lang/modules/en.ts +++ b/frontend/src/lang/modules/en.ts @@ -2440,6 +2440,9 @@ const message = { installExtension: 'Do you confirm to install the extension {0}', loadedExtension: 'Loaded Extension', popularExtension: 'Popular Extension', + uninstallExtension: 'Are you sure you want to uninstall the extension {0}', + phpConfigHelper: + 'Modifying the configuration requires restarting the operating environment, do you want to continue', }, process: { pid: 'Process ID', diff --git a/frontend/src/lang/modules/tw.ts b/frontend/src/lang/modules/tw.ts index 03b6f43dd..cd1a12640 100644 --- a/frontend/src/lang/modules/tw.ts +++ b/frontend/src/lang/modules/tw.ts @@ -2264,6 +2264,8 @@ const message = { installExtension: '是否確認安裝擴充功能 {0}', loadedExtension: '已載入擴充功能', popularExtension: '常用擴充', + uninstallExtension: '是否確認卸載擴充功能 {0}', + phpConfigHelper: '修改配置需要重新啟動運行環境,是否繼續', }, process: { pid: '進程ID', diff --git a/frontend/src/lang/modules/zh.ts b/frontend/src/lang/modules/zh.ts index 8197e8cd2..ccc4b2972 100644 --- a/frontend/src/lang/modules/zh.ts +++ b/frontend/src/lang/modules/zh.ts @@ -2267,6 +2267,7 @@ const message = { loadedExtension: '已加载扩展', popularExtension: '常用扩展', uninstallExtension: '是否确认卸载扩展 {0}', + phpConfigHelper: '修改配置需要重启运行环境,是否继续', }, process: { pid: '进程ID', diff --git a/frontend/src/routers/modules/website.ts b/frontend/src/routers/modules/website.ts index 39b24aa4a..8c046a34f 100644 --- a/frontend/src/routers/modules/website.ts +++ b/frontend/src/routers/modules/website.ts @@ -50,7 +50,7 @@ const webSiteRouter = { }, { path: '/websites/runtimes/node', - name: 'Node', + name: 'node', hidden: true, component: () => import('@/views/website/runtime/node/index.vue'), meta: { diff --git a/frontend/src/views/website/website/config/php/config/index.vue b/frontend/src/views/website/runtime/php/config/config/index.vue similarity index 93% rename from frontend/src/views/website/website/config/php/config/index.vue rename to frontend/src/views/website/runtime/php/config/config/index.vue index 190c7cca8..76ae9ae1b 100644 --- a/frontend/src/views/website/website/config/php/config/index.vue +++ b/frontend/src/views/website/runtime/php/config/config/index.vue @@ -2,8 +2,7 @@
-
- + @@ -48,7 +47,7 @@
- + @@ -81,18 +80,16 @@
-
diff --git a/frontend/src/views/website/website/config/resource/php-fpm/index.vue b/frontend/src/views/website/runtime/php/config/php-fpm/index.vue similarity index 70% rename from frontend/src/views/website/website/config/resource/php-fpm/index.vue rename to frontend/src/views/website/runtime/php/config/php-fpm/index.vue index ed771ab1d..71aadca27 100644 --- a/frontend/src/views/website/website/config/resource/php-fpm/index.vue +++ b/frontend/src/views/website/runtime/php/config/php-fpm/index.vue @@ -4,16 +4,14 @@ {{ $t('nginx.saveAndReload') }} - diff --git a/frontend/src/views/website/website/config/php/version/index.vue b/frontend/src/views/website/website/config/php/version/index.vue deleted file mode 100644 index bc2a11fcf..000000000 --- a/frontend/src/views/website/website/config/php/version/index.vue +++ /dev/null @@ -1,107 +0,0 @@ - - - diff --git a/frontend/src/views/website/website/config/resource/index.vue b/frontend/src/views/website/website/config/resource/index.vue index 843c4e0c0..54b80bd9b 100644 --- a/frontend/src/views/website/website/config/resource/index.vue +++ b/frontend/src/views/website/website/config/resource/index.vue @@ -3,12 +3,7 @@ - - - - - - + @@ -17,7 +12,7 @@ import { GetRuntime } from '@/api/modules/runtime'; import { GetWebsite } from '@/api/modules/website'; import { computed, onMounted, ref } from 'vue'; import Nginx from './nginx/index.vue'; -import PHP from './php-fpm/index.vue'; + const props = defineProps({ id: {