feat: implement Nginx, PHP, and MySQL service management via IPC handlers and dynamic configuration templates

This commit is contained in:
Ümit Tunç
2026-03-28 21:04:48 +03:00
parent f9c9bf117e
commit f5d0c42888
3 changed files with 26 additions and 2 deletions
+2
View File
@@ -20,6 +20,8 @@ http {
try_files $uri $uri/ /index.php?$query_string; try_files $uri $uri/ /index.php?$query_string;
} }
{{PROJECTS}}
location /phpmyadmin { location /phpmyadmin {
alias "{{PHPMYADMIN_DIR}}"; alias "{{PHPMYADMIN_DIR}}";
index index.php; index index.php;
+23 -1
View File
@@ -8,6 +8,7 @@ import { phpManagerService } from '../services/PhpManagerService'
import { mySqlManagerService } from '../services/MySqlManagerService' import { mySqlManagerService } from '../services/MySqlManagerService'
import { nginxManagerService } from '../services/NginxManagerService' import { nginxManagerService } from '../services/NginxManagerService'
import { phpMyAdminService } from '../services/PhpMyAdminService' import { phpMyAdminService } from '../services/PhpMyAdminService'
import { portMappingService } from '../services/PortMappingService'
import path from 'path' import path from 'path'
function findExecutable(dir: string, name: string): string | null { 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', { const configPath = await configService.generateConfig('nginx.conf.template', 'nginx.conf', {
PORT: settings.nginxPort, PORT: settings.nginxPort,
PHP_PORT: settings.phpPort, PHP_PORT: settings.phpPort,
ROOT: rootPath, ROOT: rootPath,
LOG_DIR: logDir.replace(/\\/g, '/'), LOG_DIR: logDir.replace(/\\/g, '/'),
CONF_DIR: confDir.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 // Test config first with prefix
+1 -1
View File
@@ -902,7 +902,7 @@ function App(): JSX.Element {
<Button <Button
size="small" size="small"
endIcon={<LaunchIcon />} endIcon={<LaunchIcon />}
onClick={() => window.open(`http://${project.host}`, '_blank')} onClick={() => window.open(`http://localhost:${settings.nginxPort}/${project.host}/`, '_blank')}
sx={{ sx={{
color: '#39A7FF', color: '#39A7FF',
textTransform: 'none', textTransform: 'none',