php - nginx 作为 PHP 服务入口点
问题描述
问题
这里的主要问题 - 如何在具有单独配置位置的 URL 中提供包含/vendor/
前缀的静态资产?nginx
期望的行为是 -nginx
作为应用证书的根入口点SSL
,然后它为静态资产提供服务,所有其他请求都由php
解释器处理。
解决方案
你可以通过一个简单的配置来实现你想要的,比如:
location / {
# This is cool because no PHP is touched for static content.
# include the "?$args" part so non-default permalinks doesn't break when using query string
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
include fastcgi_params;
fastcgi_pass unix:/var/run/php-fpm/example.com.sock;
}
但如果你想获得终极性能,请参阅这篇关于try_files
缺点以及如何在没有它的情况下配置 NGINX 的文章。
推荐阅读
- html - 在 html 输入中保留初始空格
- python - 矩阵操作:在 numpy 中减去 2D 矩阵和 3D 矩阵
- soap - 创建在生成的请求中显示的评论?WSDL SOAP xml
- python - 在 python 中使用路由器的最佳实践是什么?
- jsf-1.2 - 将 JSF1.2 应用程序从 Jboss 4.2 迁移到 Wildfly 13
- java - IntelliJ IDEA 中的逗号优先 Java 格式
- yii - 获取模块配置参数
- tensorflow - 如何在 Jetson TX1 上更新 Protocol Buffer 运行时库?
- c# - 生成文件路径并修剪“.aspx”
- google-chrome - 要备份的最小用户配置文件?