我正在我们已经使用的域的子目录下部署Lumen(Laravel)站点,因为我们希望保留当前的遗留支持而不创建新的子域。
我已经在互联网上搜索过,试图弄清楚如何做到这一点,因为它不仅仅是设置root
参数(多么不幸),最终想出了这个,感觉如此接近,虽然还不完全,因为我的路线都没有工作(给出NotFoundHttpException):
location ^~ /v2 {
alias /var/www/ver2/public;
try_files $uri $uri/ /v2/v2/index.php?$query_string;
location ~* \.php$ {
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $request_filename;
include fastcgi_params;
}
}
当var_dump
引导程序中的$_SERVER
信息是query_string
没有被发送到php-fpm时,它看起来是什么样的:
array(31) {
["USER"]=>
string(8) "www-data"
["HOME"]=>
string(8) "/var/www"
["FCGI_ROLE"]=>
string(9) "RESPONDER"
["SCRIPT_FILENAME"]=>
string(34) "/var/www/ver2/public/index.php"
["QUERY_STRING"]=>
string(0) ""
["REQUEST_METHOD"]=>
string(3) "GET"
["CONTENT_TYPE"]=>
string(0) ""
["CONTENT_LENGTH"]=>
string(0) ""
["SCRIPT_NAME"]=>
string(13) "/v2/index.php"
["REQUEST_URI"]=>
string(4) "/v2/"
["DOCUMENT_URI"]=>
string(13) "/v2/index.php"
["DOCUMENT_ROOT"]=>
string(24) "/var/www/ver2/public"
["SERVER_PROTOCOL"]=>
string(8) "HTTP/1.1"
["HTTPS"]=>
string(2) "on"
["GATEWAY_INTERFACE"]=>
string(7) "CGI/1.1"
["SERVER_SOFTWARE"]=>
string(11) "nginx/1.6.2"
["REMOTE_ADDR"]=>
string(14) "139.182.18.248"
["REMOTE_PORT"]=>
string(5) "49352"
["SERVER_ADDR"]=>
string(13) "139.182.74.19"
["SERVER_PORT"]=>
string(3) "443"
["SERVER_NAME"]=>
string(13) "139.182.74.19"
["REDIRECT_STATUS"]=>
string(3) "200"
["HTTP_HOST"]=>
string(13) "139.182.74.19"
["HTTP_USER_AGENT"]=>
string(82) "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:40.0) Gecko/20100101 Firefox/40.0"
["HTTP_ACCEPT"]=>
string(63) "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8"
["HTTP_ACCEPT_LANGUAGE"]=>
string(14) "en-US,en;q=0.5"
["HTTP_ACCEPT_ENCODING"]=>
string(13) "gzip, deflate"
["HTTP_CONNECTION"]=>
string(10) "keep-alive"
["PHP_SELF"]=>
string(13) "/v2/index.php"
["REQUEST_TIME_FLOAT"]=>
float(1440429882.5512)
["REQUEST_TIME"]=>
int(1440429882)
}
结果,我的路线似乎都没有解决,我很难从这里开始。
答案 0 :(得分:0)
目录one
是我wwwroot
目录中的子目录。
location /one {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /one/public/index.php?$query_string;
# Uncomment to enable naxsi on this location
}
location ~ /one.*\.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
# NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
# With php5-cgi alone:
#fastcgi_pass 127.0.0.1:9000;
# With php5-fpm:
fastcgi_pass unix:/home/jamlee/etc/fpm/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
if ($request_uri ~ ^/one(.*)$ ) {
set $request_lumen $1;
}
fastcgi_param REQUEST_URI $request_lumen;
}