diff --git a/config/nginx.conf.template b/config/nginx.conf.template index 4f3a2f4..fb0b5ef 100644 --- a/config/nginx.conf.template +++ b/config/nginx.conf.template @@ -20,6 +20,8 @@ http { try_files $uri $uri/ /index.php?$query_string; } + {{PROJECTS}} + location /phpmyadmin { alias "{{PHPMYADMIN_DIR}}"; index index.php; diff --git a/src/main/ipc/index.ts b/src/main/ipc/index.ts index d533894..bf9cece 100644 --- a/src/main/ipc/index.ts +++ b/src/main/ipc/index.ts @@ -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 diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx index a6423e5..880d0e7 100644 --- a/src/renderer/src/App.tsx +++ b/src/renderer/src/App.tsx @@ -902,7 +902,7 @@ function App(): JSX.Element {