宝塔面板部署NextCloud逐一解决后台安全及设置警

nextcloud能看作是一款基于owncloud的私有云搞定计划。如果只需要简单的使用nextcloud,最基本的安装环境只需要nginx(apache)+php便可。


 

记载一下在宝塔面板环境下搭建nextcloud的途中中出现的一些问题及搞定。


 

=======更新========


 

Nextcloud 14.x版本后会出现一些新的警告,能参照:


 

宝塔面板安装NextCloud(14.0.3)一一搞定后台safe及设置警告


 

1、安装

安装的途中不再详述,总结一下就是:


 

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.
内存缓存未配置,为了提拔使用体会,请放量配置内存缓存。more信息请拜见文档。
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个逼迫症,不详决这些问题怎地行呢


 

3、一一搞定

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

从宝塔文件管理,open /www/server/php/72/etc/php-fpm.conf,在其尾部增加一行


 

env[PATH] = /usr/local/bin:/usr/bin:/bin:/usr/local/php/bin

 

save并列启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)能通过Internet访问,为了safe起见需要取缔访问。因而搞定方式是修正nextcloud绑定的站点配置文件,增加nextcloud常用目录取缔访问便可


 

location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {

    deny all;

}



 

增加终了save便可生效


 

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;";



 

save便可生效


 

5.内存缓存未配置,为了提拔使用体会,请放量配置内存缓存

这个问题是指php的缓存模块没有部署,nextcloud支持APCu、Memcached、Redis等模块,挑选就中1个部署。伏笔VPS之前写过1个宝塔面板PHP 7.x 编译部署APCu


 

编译部署终了以后,从宝塔面板open/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的引荐配置,save并列启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出现的safe及设置警告均以一一搞定,看一下最终结果

 

=======以下为NextCloud 14.0.x版本中新增的一些告警======


 

Use of the the built in php mailer is no longer supported. Please update your email server settings
您的网页服务器未准确设置以解析“/.well-known/caldav”
您的网页服务器未准确设置以解析“/.well-known/carddav”
The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.
在数据表 “oc_share” 中没法找到索引 “parent_index” .
在数据表 “oc_filecache” 中没法找到索引 “fs_mtime” .
HTTP的请求头 “Referrer-Policy” 未设置为 “no-referrer”, “no-referrer-when-downgrade”, “strict-origin” or “strict-origin-when-cross-origin”. 这会导致信息泄露. 请查阅 W3C 提议


 

1.Use of the the built in php mailer is no longer supported. Please update your email server settings

粗心就是php自带的mail组件不再被nextcloud支持,需要使用smtp方法发送邮件。


 

实则就是让你设置1个smtp服务器信息,便于发送邮件,关于SMTP这里不再详述。

 

2.您的网页服务器未准确设置以解析“/.well-known/caldav”及您的网页服务器未准确设置以解析“/.well-known/carddav”

这两个警告能一齐搞定,出现该提示一般是由于这两个路径的伪静态设置有问题,导致没法一般访问。


 

搞定方式就是增加两行重定向配置


 

rewrite /.well-known/carddav /remote.php/dav permanent;

rewrite /.well-known/caldav /remote.php/dav permanent;



 

3.The database is missing some indexes. Due to the fact that adding indexes on big tables could take some time they were not added automatically. By running “occ db:add-missing-indices” those missing indexes could be added manually while the instance keeps running. Once the indexes are added queries to those tables are usually much faster.

在数据表”oc_share” 中没法找到索引”parent_index”
在数据表”oc_filecache” 中没法找到索引”fs_mtime”


 

粗心是说,数据库的一些索引丧失了,需要使用OCC修复一下。OCC是owncloud的command行,而nextcloud又是基于owncloud开拓的,因而需要用到OCC来修复丧失的数据库索引。


 

修复command为:


 

php occ db:add-missing-indices

 

SSH进入服务器nextcloud的根目录,并执行修复command

 

出现如下错误


 

Console has to be executed with the user that owns the file config/config.php
Current user: root
Owner of config.php: www
Try adding ‘sudo -u www ‘ to the beginning of the command (without the single quotes)


 

好吧,需要使用www使用者权限来修正,再次执行


 

sudo -u www php occ db:add-missing-indices



 

修复成功!


 

4.HTTP的请求头 “Referrer-Policy” 未设置为 “no-referrer”, “no-referrer-when-downgrade”, “strict-origin” or “strict-origin-when-cross-origin”. 这会导致信息泄露

粗心是,需要设置1个Referrer-Policy请求头来提升safe性。Nginx配置文件里增加:


 

add_header Referrer-Policy "no-referrer";



 

======================================================


 

至此,Nextcloudupgrade到14.0.3后出现的一些新的警告提示已全部覆灭彻底

 

 

 

 

原文链接:https://host.fubi.hk/foreshadowinghost/zhishiku/20181025/8384.html

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
宝塔面板部署Java项目的步骤如下所示: 1. 首先,登录到服务器实例并获取密码。 2. 使用获取的密码登录到宝塔面板的官方网站。 3. 在宝塔官方网站下载并安装宝塔面板。 4. 安装完成后,使用宝塔面板提供的地址和账号密码登录到宝塔面板的主界面。 5. 在宝塔面板中,点击软件商店进行安装所需的数据库和Tomcat。 6. 在安全设置中放行所需的端口。 7. 安装数据库可视化工具,方便管理数据库。 8. 创建一个与项目所需数据库相同的数据库。 9. 导入项目所需的SQL文件。 10. 将项目打包成JAR文件,并上传到服务器。 11. 在终端中运行JAR文件,可以使用命令nohup java -jar myblog-0.0.1-SNAPSHOT.jar来实现在终端关闭后仍然运行。 12. 如果需要停止运行项目,可以使用命令killall java。 13. 完成以上步骤后,项目就成功部署宝塔面板上了。 希望以上步骤能够帮助您成功部署Java项目在宝塔面板上。<span class="em">1</span><span class="em">2</span><span class="em">3</span> #### 引用[.reference_title] - *1* *2* *3* [史上最详细的宝塔部署java项目流程](https://blog.csdn.net/m0_46719152/article/details/121304233)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 100%"] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值