AMH 5.3 LNMP 环境安装 Nextcloud 伪静态及 Redis 配置

本教程需要完善,目前还有些问题。

Nextcloud 是一个免费专业的私有云存储网盘「开源」项目,可以让你简单快速地在个人/公司电脑、服务器甚至是树莓派等设备上架设一套属于自己或团队专属的云同步网盘,从而实现跨平台跨设备文件同步、共享、版本控制、团队协作等功能。

Nextcloud 跨平台支持 Windows、Mac、Android、iOS、Linux 等平台,而且还提供了「网页版」以及 WebDAV 形式访问,因此你几乎可以在任何电脑、手机设备上都能轻松获取和访问你的文件文档。

一、准备

1.1.安装 AMH 5.3 最新云主机面板(二选一)

极速方式(推荐)

wget http://amh.sh/amh.sh && bash amh.sh acc 4758 2>&1 | tee amh.log

编译方式

wget http://amh.sh/amh.sh && bash amh.sh gcc 4758 2>&1 | tee amh.log

1.2.安装 Nextcloud Server 最新版

https://nextcloud.com/install/#instructions-server

二、配置信息

2.1.伪静态规则

# 不用https可以去掉下面这段

if ($scheme = http) {
 return 301 https://$server_name$request_uri;
 }

#

 add_header Strict-Transport-Security "max-age=15768000"; 
 add_header X-Content-Type-Options nosniff;
 add_header X-XSS-Protection "1; mode=block";
 add_header X-Robots-Tag none;
 add_header X-Download-Options noopen;
 add_header X-Permitted-Cross-Domain-Policies none;



location = /robots.txt {
 allow all;
 log_not_found off;
 access_log off;
 }
 location = /.well-known/carddav {
 return 301 $scheme://$host/remote.php/dav;
 }
 location = /.well-known/caldav {
 return 301 $scheme://$host/remote.php/dav;
 }

client_max_body_size 512M;
 fastcgi_buffers 64 4K;

gzip on;
 gzip_vary on;
 gzip_comp_level 4;
 gzip_min_length 256;
 gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
 gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

location / {
 rewrite ^ /index.php$uri;
 }

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
 deny all;
 }
 location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
 deny all;
 }

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
 fastcgi_split_path_info ^(.+\.php)(/.*)$;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param PATH_INFO $fastcgi_path_info;
 fastcgi_param HTTPS on;
 fastcgi_param modHeadersAvailable true;
 fastcgi_param front_controller_active true;
 fastcgi_pass unix:/tmp/php-cgi-环境名-域名.sock;
 fastcgi_intercept_errors on;
 fastcgi_request_buffering off;
 }

location ~ ^/(?:updater|ocs-provider)(?:$|/) {
 try_files $uri/ =404;
 index index.php;
 }

location ~ \.(?:css|js|woff|svg|gif)$ {
 try_files $uri /index.php$uri$is_args$args;
 add_header Cache-Control "public, max-age=15778463";
 add_header Strict-Transport-Security "max-age=15768000";
 add_header X-Content-Type-Options nosniff;
 add_header X-XSS-Protection "1; mode=block";
 add_header X-Robots-Tag none;
 add_header X-Download-Options noopen;
 add_header X-Permitted-Cross-Domain-Policies none;
 access_log off;
 }

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
 try_files $uri /index.php$uri$is_args$args;
 access_log off;
 }

add_header Strict-Transport-Security "max-age=15768000"; 
 add_header X-Content-Type-Options nosniff;
 add_header X-XSS-Protection "1; mode=block";
 add_header X-Robots-Tag none;
 add_header X-Download-Options noopen;
 add_header X-Permitted-Cross-Domain-Policies none;



location = /robots.txt {
 allow all;
 log_not_found off;
 access_log off;
 }
 location = /.well-known/carddav {
 return 301 $scheme://$host/remote.php/dav;
 }
 location = /.well-known/caldav {
 return 301 $scheme://$host/remote.php/dav;
 }

client_max_body_size 512M;
 fastcgi_buffers 64 4K;

gzip on;
 gzip_vary on;
 gzip_comp_level 4;
 gzip_min_length 256;
 gzip_proxied expired no-cache no-store private no_last_modified no_etag auth;
 gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy;

location / {
 rewrite ^ /index.php$uri;
 }

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
 deny all;
 }
 location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
 deny all;
 }

location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+)\.php(?:$|/) {
 fastcgi_split_path_info ^(.+\.php)(/.*)$;
 include fastcgi_params;
 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
 fastcgi_param PATH_INFO $fastcgi_path_info;
 fastcgi_param HTTPS on;
 fastcgi_param modHeadersAvailable true;
 fastcgi_param front_controller_active true;
 fastcgi_pass unix:/tmp/php-cgi-环境名-域名.sock;
 fastcgi_intercept_errors on;
 fastcgi_request_buffering off;
 }

location ~ ^/(?:updater|ocs-provider)(?:$|/) {
 try_files $uri/ =404;
 index index.php;
 }

location ~ \.(?:css|js|woff|svg|gif)$ {
 try_files $uri /index.php$uri$is_args$args;
 add_header Cache-Control "public, max-age=15778463";
 add_header Strict-Transport-Security "max-age=15768000";
 add_header X-Content-Type-Options nosniff;
 add_header X-XSS-Protection "1; mode=block";
 add_header X-Robots-Tag none;
 add_header X-Download-Options noopen;
 add_header X-Permitted-Cross-Domain-Policies none;
 access_log off;
 }

location ~ \.(?:png|html|ttf|ico|jpg|jpeg)$ {
 try_files $uri /index.php$uri$is_args$args;
 access_log off;
 }

2.2.Redis 缓存配置

先在AMH控制面板安装好 Redis 及 pecl_redis 到指定的虚拟环境中。

通过以下命令验证Redis已经正常运行:

输入:
ps ax | grep redis

结果:
22203 ? Ssl 0:00 /usr/bin/redis-server 127.0.0.1:6379

修改 Nextcloud 配置文件 /config/config.php 在最下方添加

 'memcache.local' => '\\OC\\Memcache\\APCu',
 'memcache.locking' => '\\OC\\Memcache\\Redis',
 'redis' => 
 array (
 'host' => 'localhost',
 'port' => 6379,
 ),

三、大功告成


评论

《 “AMH 5.3 LNMP 环境安装 Nextcloud 伪静态及 Redis 配置” 》 有 2 条评论

  1. 您好,请教一下AMH面板中:域名conf,如何配置?
    谢谢

回复 DearTanker 取消回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注