mirror of
https://github.com/1Panel-dev/1Panel.git
synced 2025-11-06 09:45:59 +08:00
perf: optimization php config (#9321)
This commit is contained in:
parent
315f99a03a
commit
64fd715973
5 changed files with 48 additions and 3 deletions
|
|
@ -1003,3 +1003,23 @@ func handlePHPDir(runtime model.Runtime) {
|
|||
_ = fileOp.ChownR(dir, strconv.Itoa(1000), strconv.Itoa(1000), true)
|
||||
}
|
||||
}
|
||||
|
||||
func HandleOldPHPRuntime() {
|
||||
runtimes, _ := runtimeRepo.List(repo.WithByType(constant.RuntimePHP))
|
||||
if len(runtimes) == 0 {
|
||||
return
|
||||
}
|
||||
fileOp := files.NewFileOp()
|
||||
for _, runtime := range runtimes {
|
||||
composePtah := runtime.GetComposePath()
|
||||
composeBytes, _ := fileOp.GetContent(composePtah)
|
||||
composeContent := strings.ReplaceAll(string(composeBytes), "./conf:/usr/local/etc/php", "./conf/php.ini:/usr/local/etc/php/php.ini")
|
||||
composeContent = strings.ReplaceAll(composeContent, "./conf/php-fpm.conf:/usr/local/etc/php-fpm.d/www.conf", "./conf/php-fpm.conf:/usr/local/etc/php-fpm.conf")
|
||||
composeContent = strings.ReplaceAll(composeContent, "./extensions:${EXTENSION_DIR}", "./extensions:/usr/local/lib/php/extensions")
|
||||
_ = fileOp.WriteFile(composePtah, strings.NewReader(composeContent), constant.DirPerm)
|
||||
_ = fileOp.WriteFile(runtime.GetFPMPath(), bytes.NewReader(nginx_conf.GetWebsiteFile("php-fpm.conf")), constant.DirPerm)
|
||||
go func() {
|
||||
_ = restartRuntime(&runtime)
|
||||
}()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
16
agent/cmd/server/nginx_conf/php-fpm.conf
Normal file
16
agent/cmd/server/nginx_conf/php-fpm.conf
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
[global]
|
||||
error_log = /var/log/php/fpm.error.log
|
||||
log_level = notice
|
||||
[www]
|
||||
user = www-data
|
||||
group = www-data
|
||||
listen = 127.0.0.1:9000
|
||||
pm = dynamic
|
||||
pm.max_children = 10
|
||||
pm.start_servers = 2
|
||||
pm.min_spare_servers = 1
|
||||
pm.max_spare_servers = 3
|
||||
pm.status_path = /status
|
||||
slowlog = /var/log/php/fpm.slow.log
|
||||
request_slowlog_timeout = 3
|
||||
catch_workers_output = yes
|
||||
|
|
@ -41,11 +41,11 @@ var RuntimeDefaultVolumes = map[string]string{
|
|||
|
||||
var PHPDefaultVolumes = map[string]string{
|
||||
"${PANEL_WEBSITE_DIR}": "/www/",
|
||||
"./conf": "/usr/local/etc/php",
|
||||
"./conf/php.ini": "/usr/local/etc/php/php.ini",
|
||||
"./conf/conf.d": "/usr/local/etc/php/conf.d",
|
||||
"./conf/php-fpm.conf": "/usr/local/etc/php-fpm.d/www.conf",
|
||||
"./conf/php-fpm.conf": "/usr/local/etc/php-fpm.conf",
|
||||
"./log": "/var/log/php",
|
||||
"./extensions": "${EXTENSION_DIR}",
|
||||
"./extensions": "/usr/local/lib/php/extensions",
|
||||
"./supervisor/supervisord.conf": "/etc/supervisord.conf",
|
||||
"./supervisor/supervisor.d/php-fpm.ini": "/etc/supervisor.d/php-fpm.ini",
|
||||
"./supervisor/supervisor.d": "/etc/supervisor.d",
|
||||
|
|
|
|||
|
|
@ -26,6 +26,7 @@ func InitAgentDB() {
|
|||
migrations.UpdateWebsiteExpireDate,
|
||||
migrations.UpdateRuntime,
|
||||
migrations.AddSnapshotRule,
|
||||
migrations.UpdatePHPRuntime,
|
||||
})
|
||||
if err := m.Migrate(); err != nil {
|
||||
global.LOG.Error(err)
|
||||
|
|
|
|||
|
|
@ -332,3 +332,11 @@ var AddSnapshotRule = &gormigrate.Migration{
|
|||
)
|
||||
},
|
||||
}
|
||||
|
||||
var UpdatePHPRuntime = &gormigrate.Migration{
|
||||
ID: "20250624-update-php-runtime",
|
||||
Migrate: func(tx *gorm.DB) error {
|
||||
service.HandleOldPHPRuntime()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue