nextcloud可以看做是一款基于owncloud的私有云解决方案。如果只需要简单的使用nextcloud,最基本的部署环境只需要nginx(apache)+php即可。
记录一下在宝塔面板环境下搭建nextcloud的过程中出现的一些问题及解决。
一、部署
部署的过程不再详述,总结一下就是:
1.宝塔面板安装nginx+php7.2(注意nextcloud从13.0版本开始才支持php 7.2)
2.下载压缩包并上传:https://download.nextcloud.com/server/releases/nextcloud-13.0.1.zip
3.服务端解压并访问
4.填写安装信息(用户名、密码),如果只是简单使用,可直接使用SQLite作为数据库,不需要MySQL
二、发现问题
经过部署,nextcloud已经可以在web端或者客户端使用了,体验上来说,是没有任何影响的。但是从web端进入管理页面,会有如下错误
PHP 的设置似乎有问题, 无法获取系统环境变量. 使用 getenv(\”PATH\”) 测试时仅返回空结果.
Please check the installation documentation ↗ for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.
PHP 模块 ‘fileinfo’ 缺失. 我们强烈建议启用此模块以便在 MIME 类型检测时获得最准确的结果.
Your data directory and files are probably accessible from the Internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.
The “Strict-Transport-Security” HTTP header is not set to at least “15552000” seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.
内存缓存未配置,为了提升使用体验,请尽量配置内存缓存。更多信息请参见文档。
The PHP OPcache is not properly configured. For better performance it is recommended to use the following settings in the php.ini:
opcache.enable=1
opcache.enable_cli=1
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.memory_consumption=128
opcache.save_comments=1
opcache.revalidate_freq=1
请仔细检查安装指南,并检查日志中是否有错误或警告。
作为一个强迫症,不解决这些问题怎么行呢
三、逐一解决
1.PHP 的设置似乎有问题, 无法获取系统环境变量. 使用 getenv(\”PATH\”) 测试时仅返回空结果.
从宝塔文件管理,打开/www/server/php/72/etc/php-fpm.conf,在其尾部添加一行
env[PATH] = /usr/local/bin:/usr/bin:/bin:/usr/local/php/bin
保存并重启PHP即可解决该问题
2.PHP 模块 ‘fileinfo’ 缺失. 我们强烈建议启用此模块以便在 MIME 类型检测时获得最准确的结果
这个也很简单,因为php环境默认是没有安装fileinfo这个扩展模块的,所以手动去宝塔PHP管理选项中安装fileinfo扩展即可解决该问题
3.Your data directory and files are probably accessible from the Internet. The .htaccess file is not working. It is strongly recommended that you configure your web server so that the data directory is no longer accessible, or move the data directory outside the web server document root.
大致意思是用户的数据目录(data)可以通过互联网访问,为了安全起见需要禁止访问。所以解决方法是修改nextcloud绑定的网站配置文件,添加nextcloud常用目录禁止访问即可
location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ { deny all;
}
添加完毕保存即可生效
4.The “Strict-Transport-Security” HTTP header is not set to at least “15552000” seconds. For enhanced security, it is recommended to enable HSTS as described in the security tips.
解决方法还是修改nextcloud绑定的网站配置文件,添加一行header信息
add_header Strict-Transport-Security "max-age=63072000;";
保存即可生效
5.内存缓存未配置,为了提升使用体验,请尽量配置内存缓存
这个问题是指php的缓存模块没有安装,nextcloud支持APCu、Memcached、Redis等模块,选择其中一个安装。我之前写过一个宝塔面板PHP 7.x 编译安装APCu
编译安装完毕之后,从宝塔面板打开/www/wwwroot/你的域名/config/config.php,手动给nextcloud的配置文件中添加一行设置,指定使用APCu作为缓存
'memcache.local' => '\OC\Memcache\APCu'
其他如Memcached、Redis的使用请参照官方文档:https://docs.nextcloud.com/server/13/admin_manual/configuration_server/caching_configuration.html
6.The PHP OPcache is not properly configured. For better performance it is recommended to use the following settings in the php.ini:
意思是php的OPcache模块没有安装配置,依然是从宝塔PHP设置面板中添加安装OPcache模块
安装完成后该提示依然是存在的,因为宝塔在安装OPcache模块后自动加入的配置不符合nextcloud的推荐配置,所以需要修改一下
找到OPcache的配置这一段,替换成nextcloud的推荐配置,保存并重启php即可生效
补充1:Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the documentation
大意是nextcloud目录下有一些不该出现的文件,点击“List of invalid files…”,会列出异常文件列表,删掉其中的文件即可解决。
总结
至此,宝塔面板下安装nextcloud出现的安全及设置警告均以逐一解决,看一下最终效果
其实还是本文一开始提到的,如果忽略这些问题的话,nextcloud也是能够正常使用的,并没有什么影响。
温馨提示:文章内容系作者个人观点,不代表我的技术文章分享对观点赞同或支持。
版权声明:本文为转载文章,来源于 sqsqz ,版权归原作者所有,欢迎分享本文,转载请保留出处!
资料来自网络