feat: implement Nginx configuration management and update default Apache port in settings

This commit is contained in:
Ümit Tunç
2026-04-01 23:19:41 +03:00
parent 6d14569ec6
commit 3722942ea0
5 changed files with 50 additions and 61 deletions
+28 -16
View File
@@ -1,26 +1,38 @@
# 1. PHP-FPM bağlantısını temiz ve stabil bir Proxy bloğu olarak tanımlayın
<Proxy "fcgi://127.0.0.1:{{PHP_PORT}}">
ProxySet timeout=600 connectiontimeout=600
</Proxy>
# Apache Project Configuration (CGI Mode)
# Accessed via: http://localhost:{{PORT}}/{{HOST}}/
# 2. Alias tanımı (Sonunda ASLA eğik çizgi '/' olmamalı)
# 1. Alias definition (restores localhost/projectname access)
Alias /{{HOST}} "{{PATH}}"
# 2. ScriptAlias definition for the project's PHP CGI binary
# This maps a virtual URL path to the actual PHP folder.
ScriptAlias {{PHP_BIN_URL}}/ "{{PHP_DIR}}/"
# 3. Directory settings for the project
<Directory "{{PATH}}">
Options Indexes FollowSymLinks
Options Indexes FollowSymLinks ExecCGI
AllowOverride All
Require all granted
# 3. Windows Path Sorununu Çözen Komut (Sadece bu klasöre özel zorluyoruz)
<IfModule proxy_fcgi_module>
ProxyFCGIBackendType GENERIC
</IfModule>
# 4. Klasör direkt çağrıldığında index.php'yi bulmasını garanti edin
# Passing Authorization header to PHP
CGIPassAuth On
# Directory index handling
DirectoryIndex index.php index.html
# 5. PHP Dosyalarını Yönlendirme
# PHP Handling via mod_actions and CGI
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:{{PHP_PORT}}/"
SetHandler application/x-httpd-php-{{HOST}}
</FilesMatch>
# Action maps the handler to the binary via the ScriptAlias URL
# This is more robust on Windows than using absolute local paths.
Action application/x-httpd-php-{{HOST}} "{{PHP_BIN_URL}}/php-cgi.exe"
</Directory>
# 4. Permissions for the PHP binary directory
<Directory "{{PHP_DIR}}">
AllowOverride None
Options None
Require all granted
</Directory>
+14 -30
View File
@@ -17,6 +17,8 @@ LoadModule log_config_module modules/mod_log_config.so
LoadModule rewrite_module modules/mod_rewrite.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
LoadModule actions_module modules/mod_actions.so
LoadModule cgi_module modules/mod_cgi.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule setenvif_module modules/mod_setenvif.so
@@ -53,6 +55,7 @@ DocumentRoot "{{ROOT}}"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
CGIPassAuth On
</Directory>
ErrorLog "{{LOG_DIR}}/apache_error.log"
@@ -77,39 +80,20 @@ Alias /phpmyadmin "{{PHPMYADMIN_DIR}}"
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:{{PHP_PORT}}/"
</FilesMatch>
</Directory>
# Global PHP handler
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:{{PHP_PORT}}/"
CGIPassAuth On
</FilesMatch>
</Directory>
# Project configurations
{{PROJECTS}}
# Custom Server Assets (Logos, CSS, Error Pages)
Alias /server-assets "D:/Works/2026/multiphp/public/server-assets"
<Directory "D:/Works/2026/multiphp/public/server-assets">
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
# Global PHP handler (Manual Nginx-Style SCRIPT_FILENAME)
# Inspired by Nginx's fastcgi_param SCRIPT_FILENAME $request_filename.
<FilesMatch "\.php$">
SetHandler "proxy:fcgi://127.0.0.1:{{PHP_PORT}}/"
<IfModule rewrite_module>
RewriteEngine On
# Explicitly set the physical path to avoid broken automatic mapping on Windows
RewriteRule . - [E=proxy-fcgi-pathinfo:%{REQUEST_FILENAME}]
</IfModule>
</FilesMatch>
# Error Pages
ErrorDocument 404 /server-assets/404.html
ErrorDocument 500 /server-assets/500.html
ErrorDocument 403 /server-assets/404.html
ErrorDocument 502 /server-assets/500.html
ErrorDocument 503 /server-assets/500.html
ErrorDocument 504 /server-assets/500.html
# Custom Directory Listing (Index of)
IndexOptions +HTMLTable +IconHeight=16 +IconWidth=16 +SuppressRules +SuppressDescription +NameWidth=* +FoldersFirst +ScanHTMLTitles +CharSet=UTF-8
IndexStyleSheet "/server-assets/style.css"
HeaderName "/server-assets/header.html"
ReadmeName "/server-assets/footer.html"
-13
View File
@@ -36,19 +36,6 @@ http {
return 404;
}
# Custom Server Assets (Logos, CSS, Error Pages)
location /server-assets/ {
alias "D:/Works/2026/multiphp/public/server-assets/";
access_log off;
allow all;
}
# Error Pages
error_page 404 /server-assets/404.html;
error_page 500 502 503 504 /server-assets/500.html;
location = /server-assets/404.html { internal; }
location = /server-assets/500.html { internal; }
{{PROJECTS}}
location /phpmyadmin {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"nginxPort": "80",
"apachePort": "8081",
"apachePort": "8080",
"serverType": "nginx",
"phpPort": "9001",
"mariaDbPort": "3306",
+7 -1
View File
@@ -195,10 +195,16 @@ async function rebuildApacheConfig(forceProjects: boolean = false): Promise<{ bi
let normalizedPath = p.path.replace(/\\/g, '/')
if (!normalizedPath.endsWith('/')) normalizedPath += '/'
const phpDir = path.join(configService.getBasePath(), 'bin', `php-${p.phpVersion}`)
const phpCgiBinary = findExecutable(phpDir, process.platform === 'win32' ? 'php-cgi.exe' : 'php-cgi') || ''
await configService.generateConfig('apache_project.conf.template', `projects_apache/${p.host}.conf`, {
HOST: p.host,
PATH: normalizedPath,
PHP_PORT: phpPort.toString()
PHP_PORT: phpPort.toString(),
PHP_DIR: phpDir.replace(/\\/g, '/'),
PHP_CGI_PATH: phpCgiBinary.replace(/\\/g, '/'),
PHP_BIN_URL: `/php-bin-${p.host}`
})
}
}