mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-03-01 11:34:13 +08:00
fix: 解决使用本地 PHP 环境停止启动网站之后配置错误的问题 (#5198)
Refs https://github.com/1Panel-dev/1Panel/issues/5163
This commit is contained in:
parent
fe00cb8015
commit
3aa62f91bf
@ -726,15 +726,15 @@ func opWebsite(website *model.Website, operate string) error {
|
|||||||
website.Status = constant.WebStopped
|
website.Status = constant.WebStopped
|
||||||
}
|
}
|
||||||
if operate == constant.StartWeb {
|
if operate == constant.StartWeb {
|
||||||
proxyInclude := fmt.Sprintf("/www/sites/%s/proxy/*.conf", website.Alias)
|
|
||||||
absoluteIncludeDir := path.Join(nginxInstall.Install.GetPath(), fmt.Sprintf("/www/sites/%s/proxy", website.Alias))
|
absoluteIncludeDir := path.Join(nginxInstall.Install.GetPath(), fmt.Sprintf("/www/sites/%s/proxy", website.Alias))
|
||||||
if files.NewFileOp().Stat(absoluteIncludeDir) {
|
fileOp := files.NewFileOp()
|
||||||
|
if fileOp.Stat(absoluteIncludeDir) && !files.IsEmptyDir(absoluteIncludeDir) {
|
||||||
|
proxyInclude := fmt.Sprintf("/www/sites/%s/proxy/*.conf", website.Alias)
|
||||||
server.UpdateDirective("include", []string{proxyInclude})
|
server.UpdateDirective("include", []string{proxyInclude})
|
||||||
}
|
}
|
||||||
server.UpdateDirective("include", []string{proxyInclude})
|
|
||||||
rewriteInclude := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.Alias)
|
rewriteInclude := fmt.Sprintf("/www/sites/%s/rewrite/%s.conf", website.Alias, website.Alias)
|
||||||
absoluteRewritePath := path.Join(nginxInstall.Install.GetPath(), rewriteInclude)
|
absoluteRewritePath := path.Join(nginxInstall.Install.GetPath(), rewriteInclude)
|
||||||
if files.NewFileOp().Stat(absoluteRewritePath) {
|
if fileOp.Stat(absoluteRewritePath) {
|
||||||
server.UpdateDirective("include", []string{rewriteInclude})
|
server.UpdateDirective("include", []string{rewriteInclude})
|
||||||
}
|
}
|
||||||
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
rootIndex := path.Join("/www/sites", website.Alias, "index")
|
||||||
@ -763,7 +763,7 @@ func opWebsite(website *model.Website, operate string) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
if runtime.Type == constant.RuntimePHP {
|
if runtime.Type == constant.RuntimePHP {
|
||||||
if website.ProxyType == constant.RuntimeProxyUnix {
|
if website.ProxyType == constant.RuntimeProxyUnix || website.ProxyType == constant.RuntimeProxyTcp {
|
||||||
localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php")
|
localPath = path.Join(nginxInstall.Install.GetPath(), rootIndex, "index.php")
|
||||||
}
|
}
|
||||||
server.UpdatePHPProxy([]string{website.Proxy}, localPath)
|
server.UpdatePHPProxy([]string{website.Proxy}, localPath)
|
||||||
|
@ -128,3 +128,13 @@ func GetParentMode(path string) (os.FileMode, error) {
|
|||||||
func IsInvalidChar(name string) bool {
|
func IsInvalidChar(name string) bool {
|
||||||
return strings.Contains(name, "&")
|
return strings.Contains(name, "&")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func IsEmptyDir(dir string) bool {
|
||||||
|
f, err := os.Open(dir)
|
||||||
|
if err != nil {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
defer f.Close()
|
||||||
|
_, err = f.Readdirnames(1)
|
||||||
|
return err == io.EOF
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user