feat: implement project management system with Nginx configuration templates and automated host file updates
This commit is contained in:
@@ -1,38 +1,33 @@
|
||||
# Apache Project Configuration (CGI Mode)
|
||||
# Accessed via: http://localhost:{{PORT}}/{{HOST}}/
|
||||
<VirtualHost *:{{PORT}}>
|
||||
ServerName {{HOST}}
|
||||
DocumentRoot "{{PATH}}"
|
||||
|
||||
# 1. Alias definition (restores localhost/projectname access)
|
||||
Alias /{{HOST}} "{{PATH}}"
|
||||
<Directory "{{PATH}}">
|
||||
Options Indexes FollowSymLinks ExecCGI
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
|
||||
# Passing Authorization header to PHP
|
||||
CGIPassAuth On
|
||||
|
||||
# Directory index handling
|
||||
DirectoryIndex index.php index.html
|
||||
|
||||
# PHP Handling via mod_actions and CGI
|
||||
<FilesMatch "\.php$">
|
||||
SetHandler application/x-httpd-php-{{HOST}}
|
||||
</FilesMatch>
|
||||
|
||||
# Action maps the handler to the binary via the ScriptAlias URL
|
||||
Action application/x-httpd-php-{{HOST}} "{{PHP_BIN_URL}}/php-cgi.exe"
|
||||
</Directory>
|
||||
|
||||
# 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 ExecCGI
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
# ScriptAlias definition for the project's PHP CGI binary
|
||||
ScriptAlias {{PHP_BIN_URL}}/ "{{PHP_DIR}}/"
|
||||
|
||||
# Passing Authorization header to PHP
|
||||
CGIPassAuth On
|
||||
|
||||
# Directory index handling
|
||||
DirectoryIndex index.php index.html
|
||||
|
||||
# PHP Handling via mod_actions and CGI
|
||||
<FilesMatch "\.php$">
|
||||
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>
|
||||
<Directory "{{PHP_DIR}}">
|
||||
AllowOverride None
|
||||
Options None
|
||||
Require all granted
|
||||
</Directory>
|
||||
</VirtualHost>
|
||||
@@ -0,0 +1,32 @@
|
||||
# Subdirectory Alias for {{HOST}}
|
||||
Alias /{{HOST}} "{{PATH}}"
|
||||
|
||||
<Directory "{{PATH}}">
|
||||
Options Indexes FollowSymLinks ExecCGI
|
||||
AllowOverride All
|
||||
Require all granted
|
||||
|
||||
# Passing Authorization header to PHP
|
||||
CGIPassAuth On
|
||||
|
||||
# Directory index handling
|
||||
DirectoryIndex index.php index.html
|
||||
|
||||
# PHP Handling via mod_actions and CGI
|
||||
<FilesMatch "\.php$">
|
||||
SetHandler application/x-httpd-php-alias-{{HOST}}
|
||||
</FilesMatch>
|
||||
|
||||
# Action maps the handler to the binary via the ScriptAlias URL
|
||||
# We use a unique handler name to avoid conflict with VirtualHost config
|
||||
Action application/x-httpd-php-alias-{{HOST}} "{{PHP_BIN_URL}}/php-cgi.exe"
|
||||
</Directory>
|
||||
|
||||
# ScriptAlias definition for the project's PHP CGI binary
|
||||
ScriptAlias {{PHP_BIN_URL}}/ "{{PHP_DIR}}/"
|
||||
|
||||
<Directory "{{PHP_DIR}}">
|
||||
AllowOverride None
|
||||
Options None
|
||||
Require all granted
|
||||
</Directory>
|
||||
@@ -83,7 +83,10 @@ Alias /phpmyadmin "{{PHPMYADMIN_DIR}}"
|
||||
CGIPassAuth On
|
||||
</Directory>
|
||||
|
||||
# Project configurations
|
||||
# Project configurations (Subdirectory Access)
|
||||
{{PROJECT_ALIASES}}
|
||||
|
||||
# Project configurations (Virtual Host Access)
|
||||
{{PROJECTS}}
|
||||
|
||||
# Global PHP handler (Manual Nginx-Style SCRIPT_FILENAME)
|
||||
|
||||
@@ -9,12 +9,14 @@ http {
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
server_names_hash_bucket_size 64;
|
||||
|
||||
server {
|
||||
listen {{LISTEN_ADDRESS}}:{{PORT}};
|
||||
server_name localhost;
|
||||
root "{{ROOT}}";
|
||||
index index.php index.html index.htm;
|
||||
autoindex on;
|
||||
|
||||
location / {
|
||||
# Try global root first, fallback to @project_fallback if not found
|
||||
@@ -35,8 +37,10 @@ http {
|
||||
}
|
||||
return 404;
|
||||
}
|
||||
|
||||
# Subdirectory access for projects (legacy support)
|
||||
{{PROJECT_LOCATIONS}}
|
||||
|
||||
{{PROJECTS}}
|
||||
|
||||
location /phpmyadmin {
|
||||
alias "{{PHPMYADMIN_DIR}}";
|
||||
@@ -58,4 +62,6 @@ http {
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
}
|
||||
|
||||
{{PROJECTS}}
|
||||
}
|
||||
|
||||
@@ -1,31 +1,24 @@
|
||||
location ^~ /{{HOST}}/ {
|
||||
alias "{{PATH}}";
|
||||
server {
|
||||
listen {{PORT}};
|
||||
server_name {{HOST}};
|
||||
root "{{PATH}}";
|
||||
index index.php index.html;
|
||||
autoindex on;
|
||||
|
||||
# Use a named location for reliable alias fallback
|
||||
try_files $uri $uri/ @{{HOST}};
|
||||
|
||||
# PHP handling nested INSIDE the alias location to maintain context
|
||||
# Support for clean URLs
|
||||
location / {
|
||||
try_files $uri $uri/ /index.php?$query_string;
|
||||
}
|
||||
|
||||
# PHP handling
|
||||
location ~ \.php$ {
|
||||
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||
fastcgi_index index.php;
|
||||
|
||||
include "{{CONF_DIR}}/fastcgi_params";
|
||||
|
||||
# Normal files matched correctly by URI don't suffer the try_files bug
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
}
|
||||
}
|
||||
|
||||
# The named location handles requests that don't match physical files
|
||||
location @{{HOST}} {
|
||||
# Directly execute PHP without URI mutation to preserve framework routing paths
|
||||
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||
include "{{CONF_DIR}}/fastcgi_params";
|
||||
|
||||
# Hardcode the essential execution parameters
|
||||
fastcgi_param SCRIPT_FILENAME "{{PATH}}index.php";
|
||||
fastcgi_param SCRIPT_NAME "/{{HOST}}/index.php";
|
||||
fastcgi_param DOCUMENT_ROOT "{{PATH}}";
|
||||
# Custom log files for the project
|
||||
# access_log "{{LOG_DIR}}/{{HOST}}_access.log";
|
||||
# error_log "{{LOG_DIR}}/{{HOST}}_error.log";
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
location ^~ /{{HOST}}/ {
|
||||
alias "{{PATH}}";
|
||||
index index.php index.html;
|
||||
autoindex on;
|
||||
|
||||
if (!-e $request_filename) {
|
||||
rewrite ^/{{HOST}}/(.*)$ /{{HOST}}/index.php?$1 last;
|
||||
}
|
||||
|
||||
location ~ \.php$ {
|
||||
# Using $request_filename to match the alias path correctly
|
||||
fastcgi_pass 127.0.0.1:{{PHP_PORT}};
|
||||
fastcgi_index index.php;
|
||||
include "{{CONF_DIR}}/fastcgi_params";
|
||||
fastcgi_param SCRIPT_FILENAME $request_filename;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user