杨庆荣的博客

工作之余接单:公司产品展示网站建设、电商网站建设、小程序、app开发。+86 13714715608

[solved] Let caddy support php's open_basedir

点击 0    创建时间 2023-06-02 18:33:49

the main idear of mine is add tow enviroment variables to the fastcgi.go

/L/src/caddy-2.7.0-beta.1/modules/caddyhttp/reverseproxy/fastcgi/fastcgi.go Line:289

+   base_path := root
+   if strings.HasSuffix(base_path, "/public") {
+        base_path = strings.Replace(base_path,"/public","",1)
+   }
...
    env = envVars{
...
+       "PHP_VALUE" : "open_basedir=" + base_path + ":/tmp",
+       "PHP_ADMIN_VALUE" : "open_basedir=" + base_path + ":/tmp",
    }
cd /L/src/caddy-2.7.0-beta.1/cmd/caddy
go build

you will got a executeable file caddy in the same directory,upload it to your server.

setcap CAP_NET_BIND_SERVICE=+eip /d/www/server/caddy/caddy
# solve the bind:permission denied error
Warning: file_get_contents(): open_basedir restriction in effect. File(/d/web/wudimei.com/index.php) is not within the allowed path(s): (/d/web/d.wudimei.com/p2psale:/tmp) in /d/web/d.wudimei.com/p2psale/i.php on line 4

Warning: file_get_contents(/d/web/wudimei.com/index.php): Failed to open stream: Operation not permitted in /d/web/d.wudimei.com/p2psale/i.php on line 4

上一篇: alpine linux + rust 历史记录
下一篇: curl error 28 while downloading https://packagist.phpcomposer.com/packages.json: Connection timeout after 10014 ms