摘要:下载以及相关模块下载以及模块并解压。接着执行,即可完成编译安装。运行需要的配置首先需要在的上下文里增加一条这条是表示每上传就更新进度信息。
这篇文章的目的是在编译安装Nginx的同时,安装upload和uploadprogress模块,以及运行Drupal 8所需要的配置。
由于使用的是Raspberry pi 3B,所以系统用的Raspbian,Debian/Ubuntu应该也是差不多的。
下载Nginx以及相关模块
下载Nginx以及PCRE模块并解压。
进入解压后的Nginx目录,执行命令:
./configure --prefix=/etc/nginx --with-pcre=/tmp/pcre-8.39 --sbin-path=/usr/sbin/nginx --with-http_ssl_module --add-module=/mnt/sources/nginx-upload-module --add-module=/mnt/sources/nginx-upload-progress-module
第一个参数是Nginx安装位置,第二个参数是PCRE源文件位置,第三个参数是Nginx启动的位置。
接着执行 make && make install,即可完成编译安装。
Drupal 8运行需要的配置
首先需要在nginx.conf的http上下文里增加一条:
upload_progress proxied 1m;
这条是表示每上传1M就更新进度信息。
接下来就是Drupal网站的配置:
server {
server_name d8.local.dev;
root /mnt/apps/d8;
client_max_body_size 1024m;
client_body_buffer_size 2048k;
# 这个地址是用来获取进度信息,proxied是http里配置的信息。
location ^~ /progress {
report_uploads proxied;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Very rarely should these ever be accessed outside of your lan
location ~* .(txt|log)$ {
allow 192.168.0.0/16;
deny all;
}
location ~ ..*/.*.php$ {
return 403;
}
location ~ ^/sites/.*/private/ {
return 403;
}
# Allow "Well-Known URIs" as per RFC 5785
location ~* ^/.well-known/ {
allow all;
}
location ~ (^|/). {
return 403;
}
location / {
# 如果是自定义字段上传的文件,就交由下面的代码处理
if ($query_string ~ "X-Progress-ID=d+"){
rewrite ^(.*)$ /upload;
}
try_files $uri /index.php?$query_string; # For Drupal >= 7
}
location /upload {
# 文件上传成功后,处理文件的页面。index.php是Drupal的入口文件
upload_pass /index.php;
# 是否附带QueryString参数
upload_pass_args on;
# 临时存放文件的目录
upload_store /tmp/nginx_upload;
# 存放上传状态的目录,用于断点续传
upload_state_store /tmp/nginx_state;
# 临时目录的权限
upload_store_access user:rw group:rw all:rw;
# 提交到后台的字段名
set $upload_field_name "tmp_file";
# 文件名
upload_set_form_field $upload_field_name.name "$upload_file_name";
# 文件类型
upload_set_form_field $upload_field_name.content_type "$upload_content_type";
# 临时路径
upload_set_form_field $upload_field_name.path "$upload_tmp_path";
# 文件MD5信息
upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
# 文件大小
upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";
# 原样提交到后台的表单字段,这里表示所有字段都提交给PHP
upload_pass_form_field "^.*$";
upload_cleanup 400 404 499 500-505;
}
# Don"t allow direct access to PHP files in the vendor directory.
location ~ /vendor/.*.php$ {
deny all;
return 404;
}
location ~ ".php$|^/update.php" {
fastcgi_split_path_info ^(.+?.php)(|/.*)$;
include fastcgi_params;
fastcgi_param HTTP_PROXY "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param QUERY_STRING $query_string;
fastcgi_intercept_errors on;
# PHP 7 socket location.
fastcgi_pass 127.0.0.1:9090;
track_uploads proxied 60s;
}
location ~ ^/sites/.*/files/styles/ { # For Drupal >= 7
try_files $uri @rewrite;
}
# Handle private files through Drupal. Private file"s path can come
# with a language prefix.
location ~ ^(/[a-z-]+)?/system/files/ { # For Drupal >= 7
try_files $uri /index.php?$query_string;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
在Drupal 8里的具体应用,请看我的另一篇文章:Drupal 8 结合Nginx实现文件上传进度,提高上传文件性能
程序员客栈,汇集各路码农,找到你的靠谱技术小伙伴 http://t.cn/RXz4ONT
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/39468.html
摘要:自带的上传进度功能,需要扩展支持。于是想到利用的模块来实现上传进度。接下来使用模块替代的文件上传功能,目的是提高文件上传的性能。而且可以避免上传大文件时执行超时引起错误。新建一个对象,把设置成刚上传的文件。 Drupal 8 自带的上传进度功能,需要PECL uploadprogress library扩展支持。安装后发现效果还是不太好,不知道什么原因,进度条不能正常显示,而且上传较大...
摘要:自带的上传进度功能,需要扩展支持。于是想到利用的模块来实现上传进度。接下来使用模块替代的文件上传功能,目的是提高文件上传的性能。而且可以避免上传大文件时执行超时引起错误。新建一个对象,把设置成刚上传的文件。 Drupal 8 自带的上传进度功能,需要PECL uploadprogress library扩展支持。安装后发现效果还是不太好,不知道什么原因,进度条不能正常显示,而且上传较大...
摘要:测试运行多次并取平均值。文章数量测试的基准测试基准测试结果基准测试结果基准测试结果基准测试结果基准测试结果基准测试结果不支持再次成为冠军请注意的运行环境需要或以上。同时,再次不能正常工作并抛出错误。 showImg(https://segmentfault.com/img/remote/1460000013690286); 我们每年都会尝试深入了解不同版本的 PHP 和 HHVM 在各...
摘要:前言近期在准备搭建一个全栈开发的社区,之前由于没有云服务器搭建经验,这篇文章做一下相关的记录,后续再深入学习研究。或用户登录云服务器,直接使用命令进行连接,如云服务器公网,然后输入用户的初始密码,即可完成登录。云服务器的端口,必须填。 前言 近期在准备搭建一个vue.js+node.js全栈开发的社区,之前由于没有云服务器搭建经验,这篇文章做一下相关的记录,后续再深入学习研究。本文不局...
阅读 2943·2021-10-11 10:58
阅读 1488·2021-09-29 09:34
阅读 1920·2021-09-26 09:46
阅读 4137·2021-09-22 15:31
阅读 957·2019-08-30 15:54
阅读 1682·2019-08-30 13:20
阅读 1480·2019-08-30 13:13
阅读 1770·2019-08-26 13:52