从入门到入坟搭建FeeNAS服务器并配置NexCloud( 六 )


# `try_files $uri $uri/ /index.php$request_uri`
# always provides the desired behaviour.
index index.php index.html /index.php$request_uri;
# Default Cache-Control policy
expires 1m;
# Rule borrowed from `.htaccess` to handle Microsoft DAV clients
location=/ {
if ( $http_user_agent ~ ^DavClnt ) {
return 302 /remote.php/webdav/$is_args$args;
}
}
location=/robots.txt {
allow all;
log_not_found off;
access_log off;
}
# Make a regex exception for `/.well-known` so that clients can still
# access it despite the existence of the regex rule
# `location ~ /(.|autotest|...)` which would otherwise handle requests
# for `/.well-known`.
location ^~ /.well-known {
# The following 6 rules are borrowed from `.htaccess`
rewrite ^/.well-known/host-meta.json/public.php?service=host-meta-jsonlast;
rewrite ^/.well-known/host-meta/public.php?service=host-metalast;
rewrite ^/.well-known/webfinger/public.php?service=webfingerlast;
rewrite ^/.well-known/nodeinfo/public.php?service=nodeinfolast;
location=/.well-known/carddav{ return 301 /remote.php/dav/; }
location=/.well-known/caldav{ return 301 /remote.php/dav/; }
try_files $uri $uri/=404;
}
# Rules borrowed from `.htaccess` to hide certain paths from clients
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/){ return 404; }
location ~ ^/(?:.|autotest|occ|issue|indie|db_|console){ return 404; }
# Ensure this block, which passes PHP files to the PHP process, is above the blocks
# which handle static assets (as seen below). If this block is not declared first,
# then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
# to the URI, resulting in a HTTP 500 error response.
location ~ .php(?:$|/) {
fastcgi_split_path_info ^(.+?.php)(/.*)$;
set $path_info $fastcgi_path_info;
try_files $fastcgi_script_name=404;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $path_info;
fastcgi_param HTTPS on;
fastcgi_param modHeadersAvailable true;# Avoid sending the security headers twice
fastcgi_param front_controller_active true;# Enable pretty urls
fastcgi_pass php-handler;
fastcgi_intercept_errors on;
fastcgi_request_buffering off;
}
location ~ .(?:css|js|svg|gif)$ {
try_files $uri /index.php$request_uri;
expires 6M;# Cache-Control policy borrowed from `.htaccess`
access_log off;# Optional: Don't log access to assets
}
location ~ .woff2?$ {
try_files $uri /index.php$request_uri;
expires 7d;# Cache-Control policy borrowed from `.htaccess`
access_log off;# Optional: Don't log access to assets
}
location / {
try_files $uri $uri/ /index.php$request_uri;
}
}
再打开相同目录下的nginx.conf文件,如下图进行编辑:
保存并重启Nginx:
service nginx restart
如果输入地址后,网络界面如图所示:
打开/usr/local/www/nextcloud/config路径下的config.php文件,对trusted_domains进行如下设置:
成功安装后,输入地址之后网页会显示类似界面:
成功安装并完成初始化设置之后的登录界面
初始化设置主要是创建管理员账号,设置数据目录等:
数据目录:
/mnt/data
配备数据库:
nextcloud_admin
之前数据库设置的密码
nextcloud
localhost:/tmp/mysql.sock
5.7 配置缓存REDIS
将REDIS设置为本地监听:
nano /usr/local/etc/redis.conf
将port改为0
取消“#”注释并修改对应值:
unixsocket /var/run/redis/redis.sock
unixsocketperm 770
重启redis:
service redis restart
5.8 确认Redis配置正确