feat: add Apache server support with configuration templates and IPC integration
This commit is contained in:
@@ -12,6 +12,11 @@ LoadModule rewrite_module modules/mod_rewrite.so
|
|||||||
LoadModule proxy_module modules/mod_proxy.so
|
LoadModule proxy_module modules/mod_proxy.so
|
||||||
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
|
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
|
||||||
|
|
||||||
|
# Required for PHP-FPM on Windows to avoid "No input file specified"
|
||||||
|
<IfModule proxy_fcgi_module>
|
||||||
|
ProxyFCGIBackendType GENERIC
|
||||||
|
</IfModule>
|
||||||
|
|
||||||
ServerAdmin admin@localhost
|
ServerAdmin admin@localhost
|
||||||
ServerName localhost:{{PORT}}
|
ServerName localhost:{{PORT}}
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
{
|
{
|
||||||
"nginxPort": "80",
|
"nginxPort": "80",
|
||||||
|
"apachePort": "8081",
|
||||||
|
"serverType": "nginx",
|
||||||
"phpPort": "9001",
|
"phpPort": "9001",
|
||||||
"mariaDbPort": "3306",
|
"mariaDbPort": "3306",
|
||||||
"mariaDbPorts": {},
|
"mariaDbPorts": {},
|
||||||
|
|||||||
+18
-2
@@ -159,6 +159,17 @@ async function rebuildApacheConfig(forceProjects: boolean = false): Promise<{ bi
|
|||||||
const rootPath = path.join(configService.getBasePath(), 'www')
|
const rootPath = path.join(configService.getBasePath(), 'www')
|
||||||
if (!fs.existsSync(rootPath)) fs.mkdirSync(rootPath, { recursive: true })
|
if (!fs.existsSync(rootPath)) fs.mkdirSync(rootPath, { recursive: true })
|
||||||
|
|
||||||
|
const configPath = path.join(configService.getBasePath(), 'generated_configs', 'httpd.conf')
|
||||||
|
|
||||||
|
// Check if manual edit exists
|
||||||
|
if (fs.existsSync(configPath) && !forceProjects) {
|
||||||
|
const content = fs.readFileSync(configPath, 'utf8')
|
||||||
|
if (content.includes('# MANUAL_EDIT')) {
|
||||||
|
console.log('Skipping Apache config generation (Manual Edit detected)')
|
||||||
|
return { binPath, apacheDir, configPath }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Ensure directories exist
|
// Ensure directories exist
|
||||||
const projectsConfDir = path.join(configService.getBasePath(), 'generated_configs', 'projects_apache')
|
const projectsConfDir = path.join(configService.getBasePath(), 'generated_configs', 'projects_apache')
|
||||||
if (!fs.existsSync(projectsConfDir)) fs.mkdirSync(projectsConfDir, { recursive: true })
|
if (!fs.existsSync(projectsConfDir)) fs.mkdirSync(projectsConfDir, { recursive: true })
|
||||||
@@ -187,7 +198,7 @@ async function rebuildApacheConfig(forceProjects: boolean = false): Promise<{ bi
|
|||||||
? `Include "${projectsConfDir.replace(/\\/g, '/')}/*.conf"`
|
? `Include "${projectsConfDir.replace(/\\/g, '/')}/*.conf"`
|
||||||
: ''
|
: ''
|
||||||
|
|
||||||
const configPath = await configService.generateConfig('httpd.conf.template', 'httpd.conf', {
|
await configService.generateConfig('httpd.conf.template', 'httpd.conf', {
|
||||||
PORT: settings.apachePort || '8080',
|
PORT: settings.apachePort || '8080',
|
||||||
LISTEN_ADDRESS: settings.allowRemoteAccess ? '0.0.0.0' : '127.0.0.1',
|
LISTEN_ADDRESS: settings.allowRemoteAccess ? '0.0.0.0' : '127.0.0.1',
|
||||||
PHP_PORT: settings.phpPort,
|
PHP_PORT: settings.phpPort,
|
||||||
@@ -778,7 +789,12 @@ export function registerIpcHandlers(): void {
|
|||||||
|
|
||||||
ipcMain.handle('apache:config:save', async (_event, content) => {
|
ipcMain.handle('apache:config:save', async (_event, content) => {
|
||||||
const configPath = path.join(configService.getBasePath(), 'generated_configs', 'httpd.conf')
|
const configPath = path.join(configService.getBasePath(), 'generated_configs', 'httpd.conf')
|
||||||
fs.writeFileSync(configPath, content)
|
// Ensure manual edit marker is present
|
||||||
|
let finalContent = content
|
||||||
|
if (!finalContent.includes('# MANUAL_EDIT')) {
|
||||||
|
finalContent = `# MANUAL_EDIT\n${finalContent}`
|
||||||
|
}
|
||||||
|
fs.writeFileSync(configPath, finalContent)
|
||||||
return await restartApache()
|
return await restartApache()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ export class ConfigService {
|
|||||||
|
|
||||||
for (const [key, value] of Object.entries(variables)) {
|
for (const [key, value] of Object.entries(variables)) {
|
||||||
const escapedValue = value.replace(/\\/g, '/') // Use forward slashes for cross-platform compatibility in configs
|
const escapedValue = value.replace(/\\/g, '/') // Use forward slashes for cross-platform compatibility in configs
|
||||||
content = content.replace(new RegExp(`{{${key}}}`, 'g'), escapedValue)
|
content = content.replace(new RegExp(`{{${key}}}`, 'g'), () => escapedValue)
|
||||||
}
|
}
|
||||||
|
|
||||||
fs.writeFileSync(targetPath, content)
|
fs.writeFileSync(targetPath, content)
|
||||||
|
|||||||
Reference in New Issue
Block a user