简体   繁体   English

如何在别名目录中使用 PHP-FPM

[英]How to use PHP-FPM with aliased directories

I am experimenting with upgrading my Centos 7 server from PHP5 to PHP7 , and it appears that it's also advised to use the fpm approach as well (which I'm new to).我正在尝试将我的 Centos 7 服务器从PHP5升级到 PHP7 ,似乎还建议使用 fpm 方法(我是新手)。

On my test server, I've installed PHP7.3 no problem, and PHP-FPM.在我的测试服务器上,我安装了PHP7.3没问题,还有 PHP-FPM。 And adding the line并添加行

ProxyPassMatch ^/(.*\.php(/.*)?)$ fcgi://127.0.0.1:9000/my_doc_root/$1

Works.... sort of.作品......有点。

The problem is that, for reasons historical and beyond my control, I have various paths aliased onto /, but which are not within the document root.问题是,由于历史原因和我无法控制的原因,我有各种路径别名为 /,但不在文档根目录中。 ie IE

Alias /myURL /some/different/path

Obviously the problem is that the ProxyPassMatch command above will redirect "myURL/fish.php" to a non-existent file ("my_doc_root/fish.php") which gives an error.显然问题在于上面的ProxyPassMatch命令会将“myURL/fish.php”重定向到一个不存在的文件(“my_doc_root/fish.php”),这会产生错误。

Is there a simple solution to this problem?这个问题有简单的解决方案吗? eg something I can put in the <Directory> entries for the document root and for some/different/path .例如,我可以在文档根目录和some/different/path<Directory>条目中放入一些东西。 Alternatively, is there a way I can update the /etc/https/conf.d/php.conf (from PHP5) to run PHP7 in the old-style way?或者,有没有办法更新/etc/https/conf.d/php.conf (来自PHP5)以旧式方式运行PHP7 I don't think I can as there was no libphp file in the php73 packages.我不认为我可以,因为php73包中没有 libphp 文件。

Obviously there are solutions (write separate ProxyPassMatch directives for every URL not in the document root or reorganize the entire filesystem in a more intelligent way), but I'd rather avoid these if I can;显然有解决方案(为不在文档根目录中的每个 URL 编写单独的ProxyPassMatch指令或以更智能的方式重新组织整个文件系统),但如果可以的话,我宁愿避免这些; indeed, the latter I simply can't do.的确,后者我根本做不到。

Try putting your aliases before the ProxyPassMatch directive, since if it finds that first then the alias will be ignored.尝试将您的别名放在ProxyPassMatch指令之前,因为如果它首先找到,那么别名将被忽略。

Alias /myURL /some/different/path
<Directory "/some/different/path/">
    AllowOverride All
    require ip 127.0.0.1
</Directory>

UPDATE Possibly this will help you https://serverfault.com/questions/629099/apache-2-4-php-fpm-mod-proxy-fcgi-alias更新可能这会帮助你https://serverfault.com/questions/629099/apache-2-4-php-fpm-mod-proxy-fcgi-alias

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM