Nextcloud安装完成后,管理面板会有一些错误提示,这篇文章就是教大家如何修复这些问题。
不过,我们还是从如何安装Nextcloud教起……如果你已经安装好了,想看怎么修复,直接拉下去就好了orz…
本教程适用于LNMP一键安装包(lnmp.org)搭配Debian/Ubuntu系统,不适用于lamp环境/其他lnmp一键包/CentOS系统等。
本文示范环境:
本机 Windows 10
服务器 Debian 9.5 64bit & LNMP一键安装包 LNMP1.5正式版 & Nextcloud 14.0.0
推荐搬瓦工US$49.99/年服务器 20GB SSD 1GB内存 CN2线路高速上传下载。
使用优惠码 BWH26FXH3HIQ 可优惠6.25%,按此立即购买。
(Debian/Ubuntu)lnmp环境中安装Nextcloud
打开你的服务器控制面板,记住你的服务器IP地址、SSH端口号、以及你的root密码,等会儿我们登入服务器需要用到他们。
打开PuTTY(putty.exe)

输入你的服务器IP地址跟端口,然后Open打开。
按照lnmp.org的官网教程,安装lnmp环境。
wget -c http://soft.vpser.net/lnmp/lnmp1.5.tar.gz && tar zxvf lnmp1.5.tar.gz && rm lnmp1.5.tar.gz && cd lnmp1.5 && ./install.sh lnmp
安装完lnmp环境后,就可以开始装Nextcloud了。
先在服务器上创建Nginx配置文件,可参考lnmp.org官网教程
这里我使用nextcloud.asd.as作为Nextcloud的地址
lnmp vhost add

注:如果不启用SSL,会在Nextcloud后台出现警告(实际上没什么问题)
要开启SSL的话,在那一步选择y
,2
,输入邮箱,确认。
打开Nextcloud官网的下载页面取得下载链接。
然后在服务器上下载Nextcloud(本文撰写时最新版本是14.0.0,这里以该版为例)
首先把目录换到刚才创建的用作Nextcloud网站数据的目录(替换下面nextcloud.asd.as为你的目录名)
cd /home/wwwroot/nextcloud.asd.as
下载Nextcloud并解压(替换下面的14.0.0为你下载时最新的版本号)
wget -c -O nextcloud.zip https://download.nextcloud.com/server/releases/nextcloud-14.0.0.zip && unzip nextcloud.zip && mv nextcloud/* ./ && rm -r nextcloud.zip nextcloud && chown -R www:www ./*
然后打开浏览器,输入你的域名来安装Nextcloud

填写你的资料。请使用MySQL/MariaDB作为数据库以获得更好的体验。
直接用数据库root账户就好,因为Nextcloud会自动生成一个 oc_管理员账户名 的数据库账号使用
点击下面的按钮提交,至此,Nextcloud的安装就大功告成了!

可是,看着上面的一行小字,事情似乎没有那么简单…
There were problems with the code integrity check. More information…
那是什么呢…点进去看看吧?

哇__!这什么呀!!??
(Debian/Ubuntu)lnmp环境中Nextcloud解决各种错误提示
There are some errors regarding your setup.
- Some files have not passed the integrity check. Further information on how to resolve this issue can be found in the documentation. (List of invalid files… / Rescan…)
一些文件没有通过完整性检查。了解如何解决该问题请查看我们的 文档。(无效文件列表… / 重新扫描…) - 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.
您的数据目录和文件可以从互联网直接访问。.htaccess 文件不起作用。强烈建议您配置 Web 服务器,以便数据目录不再可访问,或都你可以将数据目录移出 Web 服务器文档根目录。 - PHP does not seem to be setup properly to query system environment variables. The test with getenv("PATH") only returns an empty response. Please check the installation documentation ↗ for PHP configuration notes and the PHP configuration of your server, especially when using php-fpm.
- /dev/urandom is not readable by PHP which is highly discouraged for security reasons. Further information can be found in the documentation.
PHP 无法访问 /dev/urandom,出于安全原因这是强烈不推荐的。更多信息请参见文档。 - Use of the the built in php mailer is no longer supported. Please update your email server settings ↗.
- The PHP memory limit is below the recommended value of 512MB.
- Accessing site insecurely via HTTP. You are strongly adviced to set up your server to require HTTPS instead, as described in the security tips ↗.
- The PHP module "fileinfo" is missing. It is strongly recommended to enable this module to get the best results with MIME type detection.
- No memory cache has been configured. To enhance performance, please configure a memcache, if available. Further information can be found in the documentation.
内存缓存未配置,为了提升使用体验,请尽量配置内存缓存。更多信息请参见文档。 - The PHP OPcache module is not loaded. For better performance it is recommended to load it into your PHP installation.
- The "Referrer-Policy" HTTP header is not set to "no-referrer", "no-referrer-when-downgrade", "strict-origin" or "strict-origin-when-cross-origin". This can leak referer information. See the W3C Recommendation ↗.
- Your web server is not properly set up to resolve "/.well-known/caldav". Further information can be found in the documentation.
- Your web server is not properly set up to resolve "/.well-known/carddav". Further information can be found in the documentation.
Some files have not passed the integrity check.
点击 List of invalid files…/无效文件列表… 可以看到报错的原因,就是在Nextcloud安装目录下放别的东西,或者修改过一些文件。
LNMP一键安装包会在使用 lnmp vhost add 命令加网站的时候,自动在目录下创建 .user.ini 文件,用作防跨目录功能。
该文件是用chattr命令加了保护的,所以rm命令删不掉。首先cd到Nextcloud的安装目录,然后执行
chattr -i .user.ini
就可以修改,或者删掉这个文件…嘛其他的你们自己看着办毕竟这个是个人性的。
不过似乎就算删了这个文件还是有问题emmm
反正问题就在于.htaccess
跟.user.ini
这2个文件
似乎没法解决,不知道了
Your data directory and files are probably accessible from the Internet
就是说放文件的目录,可以直接被访问,那就禁止访问就好了。
使用WinSCP或者其他SFTP工具或者直接SSH用vi或者nano什么的编辑一下Nextcloud的vhost配置文件。
目录位于 /usr/local/nginx/conf/vhost
找到你的Nextcloud网站Nginx配置文件,编辑,找合适的位置加入以下这段。
location ^~ /data/ {
deny all;
}
(如果你实在不知道哪里是合适的位置,那就在文件最后的 }
前面新建一行插进去好了)
保存后,还需要在putty(或者其他ssh工具)通过命令载入配置
/etc/init.d/nginx reload
getenv("PATH") only returns an empty response
WinSCP(SFTP)/putty(SSH)到 /usr/local/php/etc 目录,编辑 php-fpm.conf 文件,在结尾加入以下内容
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp
然后SSH执行命令重新载入配置
/etc/init.d/php-fpm reload
/dev/urandom is not readable by PHP
编辑 /usr/local/nginx/conf/fastcgi.conf 文件
找到
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/";
修改为
fastcgi_param PHP_ADMIN_VALUE "open_basedir=$document_root/:/tmp/:/proc/:/dev/urandom";
保存,SSH命令重载配置
/etc/init.d/nginx reload
如果你没有删除网站目录下的.user.ini文件,你还需要编辑或者删除该文件。
使用putty/其他ssh工具,cd到Nextcloud网站目录。
解除.user.ini保护
chattr -i .user.ini
然后使用nano或者vi指令编辑,这里用nano示范。
nano .user.ini
在/proc/的后面打上
:/dev/urandom
然后按Ctrl+O, Enter保存,Ctrl+X退出
重新加上保护
chattr +i .user.ini
Use of the the built in php mailer is no longer supported
The PHP memory limit is below the recommended value of 512MB
把php内存限制改为512MB或者更大就好了
建议WinSCP编辑 /usr/local/php/etc/php.ini
Ctrl+F搜索 memory_limit 把 memory_limit = 128M
改为
memory_limit = 512M
保存文件,然后
/etc/init.d/php-fpm reload
可是问题来了,我用的服务器就是512MB小内存服务器,把php内存限制改那么高不是自寻死路么?反正我不改。
Accessing site insecurely via HTTP
就是说http不安全,要你开ssl用https呗。
其实可以不用理会啦,没影响的…
如果是强迫症一定要解决的话,
可以先lnmp vhost del
删除Nextcloud网站的配置文件,然后再lnmp vhost add
重新添加,在最后一步选择添加ssl证书y
,然后2
自动生成ssl证书,输入邮箱,确认。
然后要用https://
你的地址来访问Nextcloud了。
The PHP module "fileinfo" is missing
lnmp一键安装包默认没有安装php的fileinfo模块
putty登入ssh,或者你已经登入操作过什么了那么先回到root目录方便操作(?
cd /root
先看下自己的php版本
php -v
我的是7.2.9,那么现在下载那个版本的php (把下面的7.2.9全部换成你自己的版本号,可以全部先复制到记事本然后Ctrl+H批量替换)
wget -c http://php.net/distributions/php-7.2.9.tar.bz2 && tar jxvf php-7.2.9.tar.bz2 && rm php-7.2.9.tar.bz2 && cd php-7.2.9/ext/fileinfo && /usr/local/php/bin/phpize && ./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
如果看到Build complete. Don't forget to run 'make test'.
就说明成功了
但是,如果你是像我一样穷人,小内存主机,编译的时候出现内存不足的问题:virtual memory exhausted: Cannot allocate memory
,那么就要先增加一下虚拟内存啦。执行
dd if=/dev/zero of=/root/swap bs=1024 count=2048000 && mkswap /root/swap && swapon /root/swap
然后重新编译
./configure --with-php-config=/usr/local/php/bin/php-config && make && make install
如果看到Build complete. Don't forget to run 'make test'.
就说明成功了
然后需要编辑(会vi的vi,会nano的nano,都不会的WinSCP)/usr/local/php/etc/php.ini
在文件结尾处增加
extension="fileinfo.so"
保存文件,重启lnmp
lnmp restart
No memory cache has been configured.
可以使用APCu、Memcached或Redis,我使用Redis。
回到lnmp一键安装包的目录
cd /root/lnmp1.5
安装Redis
./addons.sh install redis
安装完成看到Redis installed successfully, enjoy it!
后,
编辑 /usr/local/redis/etc/redis.conf 文件
在结尾处加入
unixsocket /tmp/redis.sock
unixsocketperm 777
重启redis
/etc/init.d/redis restart
编辑 Nextcloud安装目录/config/config.php
在文件最后的 );
前新增行,加入
'memcache.local' => '\OC\Memcache\Redis',
'redis' => array(
'host' => '/tmp/redis.sock',
'port' => 0,
),
'memcache.locking' => '\OC\Memcache\Redis',
保存文件
The PHP OPcache module is not loaded.
编辑(会vi的vi,会nano的nano,都不会的WinSCP)/usr/local/php/etc/php.ini
在文件结尾处增加
zend_extension="opcache.so"
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
保存文件,重新载入php配置
/etc/init.d/php-fpm reload
The "Referrer-Policy" HTTP header is not set to ……
找到你的Nextcloud网站Nginx配置文件,编辑,找合适的位置加入以下这段。
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header Referrer-Policy "no-referrer";
(如果你实在不知道哪里是合适的位置,那就在文件最后的 }
前面新建一行插进去好了)
保存后,还需要在putty(或者其他ssh工具)通过命令载入配置
/etc/init.d/nginx reload
Your web server is not properly set up to resolve "/.well-known/caldav".
Your web server is not properly set up to resolve "/.well-known/carddav".
找到你的Nextcloud网站Nginx配置文件,编辑,找合适的位置加入以下这段。
rewrite /.well-known/caldav /remote.php/dav permanent;
rewrite /.well-known/carddav /remote.php/dav permanent;
(如果你实在不知道哪里是合适的位置,那就在文件最后的 }
前面新建一行插进去好了)
保存后,还需要在putty(或者其他ssh工具)通过命令载入配置
/etc/init.d/nginx reload
Comments | 3 条评论
萌新路过
很详细,谢谢
@passager 不哦,这篇文章已经过时了,现在的新版本Nextcloud 21会有一些更多的错误,不过按照官方文档来做就可以全部解决。