feat: implement Nginx, PHP, and MySQL service management via IPC handlers and dynamic configuration templates
This commit is contained in:
+23
-1
@@ -8,6 +8,7 @@ import { phpManagerService } from '../services/PhpManagerService'
|
||||
import { mySqlManagerService } from '../services/MySqlManagerService'
|
||||
import { nginxManagerService } from '../services/NginxManagerService'
|
||||
import { phpMyAdminService } from '../services/PhpMyAdminService'
|
||||
import { portMappingService } from '../services/PortMappingService'
|
||||
import path from 'path'
|
||||
|
||||
function findExecutable(dir: string, name: string): string | null {
|
||||
@@ -54,13 +55,34 @@ export function registerIpcHandlers(): void {
|
||||
}
|
||||
}
|
||||
|
||||
const projects = await projectService.getProjects()
|
||||
const projectLocations = projects.map(p => {
|
||||
const phpPort = portMappingService.getPhpPort(p.phpVersion)
|
||||
const normalizedPath = p.path.replace(/\\/g, '/')
|
||||
return `
|
||||
location /${p.host} {
|
||||
alias "${normalizedPath}";
|
||||
index index.php index.html;
|
||||
try_files $uri $uri/ /${p.host}/index.php?$query_string;
|
||||
|
||||
location ~ ^/${p.host}/(.+\\.php)$ {
|
||||
alias "${normalizedPath}/$1";
|
||||
fastcgi_pass 127.0.0.1:${phpPort};
|
||||
fastcgi_index index.php;
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
include "${confDir.replace(/\\/g, '/')}/fastcgi_params";
|
||||
}
|
||||
}`
|
||||
}).join('\n')
|
||||
|
||||
const configPath = await configService.generateConfig('nginx.conf.template', 'nginx.conf', {
|
||||
PORT: settings.nginxPort,
|
||||
PHP_PORT: settings.phpPort,
|
||||
ROOT: rootPath,
|
||||
LOG_DIR: logDir.replace(/\\/g, '/'),
|
||||
CONF_DIR: confDir.replace(/\\/g, '/'),
|
||||
PHPMYADMIN_DIR: phpMyAdminService.getPath().replace(/\\/g, '/')
|
||||
PHPMYADMIN_DIR: phpMyAdminService.getPath().replace(/\\/g, '/'),
|
||||
PROJECTS: projectLocations
|
||||
})
|
||||
|
||||
// Test config first with prefix
|
||||
|
||||
Reference in New Issue
Block a user