diff --git a/web-cake/Makefile b/web-cake/Makefile index 9693cb7..fd6e8fa 100644 --- a/web-cake/Makefile +++ b/web-cake/Makefile @@ -1,6 +1,7 @@ ROOT ?= $(PWD) HTTP_PORT ?= 49438 +HTTP_HOST ?= localhost PHP_FCGI_PORT ?= 49439 @@ -13,14 +14,19 @@ serve-php: php.ini nginx.conf: nginx.conf.in + chmod 644 $@ ; cat $< | \ sed -e 's@__ROOT__@$(ROOT)@g' \ -e 's@__HTTP_PORT__@$(HTTP_PORT)@g' \ - -e 's@__PHP_FCGI_PORT__@$(PHP_FCGI_PORT)@g' > $@ + -e 's@__HTTP_HOST__@$(HTTP_HOST)@g' \ + -e 's@__PHP_FCGI_PORT__@$(PHP_FCGI_PORT)@g' > $@ ; + chmod 444 $@ php.ini: php.ini.in - cat $< | sed -e 's@__ROOT__@$(ROOT)@g' > $@ + chmod 644 $@ ; + cat $< | sed -e 's@__ROOT__@$(ROOT)@g' > $@ ; + chmod 444 $@ .PHONY: serve diff --git a/web-cake/nginx.conf.in b/web-cake/nginx.conf.in index 0f22267..cf83687 100644 --- a/web-cake/nginx.conf.in +++ b/web-cake/nginx.conf.in @@ -1,5 +1,6 @@ worker_processes 1; error_log __ROOT__/error.log; +# error_log error.log; pid __ROOT__/server.pid; daemon off; @@ -14,41 +15,63 @@ http { default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] $status ' - '"$request" $body_bytes_sent "$http_referer" ' - '"$http_user_agent" "$http_x_forwarded_for"'; + '"$request" $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; sendfile on; tcp_nopush on; autoindex on; server { listen __HTTP_PORT__; - server_name localhost; - access_log access.log main; + server_name www.__HTTP_HOST__; + rewrite ^(.*) http://__HTTP_HOST__:__HTTP_PORT__$1 permanent; + } + + server { + listen __HTTP_PORT__; + server_name __HTTP_HOST__; + access_log __ROOT__/access.log main; + # access_log access.log main; + root __ROOT__/html; - location / { - index index.html index.txt index.php; - rewrite (.*) /app/webroot$1 last; - rewrite ^$ /app/webroot last; - } +# location / { +# index index.html index.txt index.php; +# rewrite (.*) /app/webroot$1 last; +# rewrite ^$ /app/webroot last; +# } +# +# location /app/webroot { +# index index.html index.txt index.php; +# } +# +# location ~ \.php$ { +# include __ROOT__/fastcgi_params; +# fastcgi_pass 127.0.0.1:__PHP_FCGI_PORT__; +# } - location /app/webroot { - index index.html index.txt index.php; + location / { + root __ROOT__/html/app/webroot/; + index index.php index.html index.htm; + if (-f $request_filename) { + break; + } + if (-d $request_filename) { + break; + } + rewrite ^(.+)$ /index.php?q=$1 last; } - location ~ \.php$ { - include fastcgi_params; + location ~ .*\.php[345]?$ { + include __ROOT__/fastcgi_params; fastcgi_pass 127.0.0.1:__PHP_FCGI_PORT__; + fastcgi_index index.php; + fastcgi_param SCRIPT_FILENAME __ROOT__/html/app/webroot$fastcgi_script_name; } - } -} + } -# -# RewriteEngine on -# RewriteRule ^$ app/webroot/ [L] -# RewriteRule (.*) app/webroot/$1 [L] -# +} # vim:filetype=nginx \ No newline at end of file