宝塔面板部署NextCloud的一些警告处理

in Linux with 0 commentand 4844 read

nextcloud是owncloud团队某一部分人离开后组成的新团队创建的拥有所有owncloud的功能且有更多符合现在使用的优化,最基本的部署环境只需要nginx(apache)+php即可。如果是使用AMH面板或者自己编译的,也一样可能会遇到类似问题,都可以按照这样的步骤试一试。

不过这个NextCloud安装也是有不少坑的,就记录一下我处理这些问题吧。

安装

故障处理

next1.png

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
请仔细检查安装指南,并检查日志中是否有错误或警告。

遇到这个多问题,就像我这种轻微强迫症肯定是受不了的!!:tw-1f639:

解决报错

1.PHP 的设置似乎有问题, 无法获取系统环境变量. 使用 getenv(\”PATH\”) 测试时仅返回空结果.

SSH打开/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的vHost文件位置大概在/www/server/panel/vhost/nginx/*.conf,根据如下添加即可。

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的vHost文件,添加一行header信息

add_header Strict-Transport-Security "max-age=63072000;";
5.内存缓存未配置,为了提升使用体验,请尽量配置内存缓存

php的缓存模块没有安装,nextcloud支持APCu、Memcached、Redis等模块,选择其中一个安装。安装完成后,从宝塔面板打开/www/wwwroot/youname/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的推荐配置,所以需要修改一下。

/www/server/panel/vhost/nginx/*.conf找到OPcache的配置这一段,替换成nextcloud的推荐配置,保存并重启php即可生效

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
如果出现文件扫描不听过就点击查询更多,找到多粗的文件删除即可。到此为止,警告基本都解决了,然后可以安安静静使用了。

评论