天天看点

ubuntu 1810上snap安装nextcloud

尝试在ubuntu1810上安装nextcloud。因为服务器配置好了xrdp远程访问,所以直接准备在sofware center进行安装

安装了半天却提示“unable to install nextcloud , snap xxxxx”,当时看着以为是缺少snap,百度了才发现,这是个安装管理器

ubuntu1810上自带了。就此,直接打开terminal,snap install nextcloud,然后发现居然要4h的下载,百度了下,好像国内没有好的snap源,就放置了一晚上。第二天一早,发现安装好了。

利用局域网直接浏览器登陆服务器IP,就可以发现进去了nextcloud。这个时候又想着配个公网ip映射,这样家里也可以登陆。

防火墙内部映射完公网IP之后,直接利用公网IP,提示:

当前域名无法登陆... 然后说啥 参考nextloud/config/config.sample.php,修改trusted_domains

然后又回到服务器,查找了snap,当时傻里傻气的,发现根目录下有个snap,直接进去,搜索到了config.sample.php

ubuntu 1810上snap安装nextcloud

复制了里面的

 'trusted_domains' =>

  array (

    'demo.example.org',

    'otherdomain.example.org',

  ),

准备贴到config.php里面,再修改域名。

发现目录下的config.php,死活无法修改。

想想可能是没有关闭nextcloud,又在terminal,里面输入了 snap stop nextcloud,关闭了nextcloud,发现还是没有用

又想起chmod修改只读属性的时候,冒出了一句提示:

read-only file system

因此又,df -h,看看咋回事,发现如下诡异情况:

ubuntu 1810上snap安装nextcloud

看这个,马上百度,百度的结果基本上教你怎么清理。。。

又打开bing,搜索了下:

https://askubuntu.com/questions/906581/what-is-dev-loopx

这里面也有问这个问题

That is normal. /dev/loopX are virtual devices to mount image files, these are -read only- so do not get larger or smaller than they are when created.

Those mount points are connected to the snapd service. You will see extra loop devices added for every software you install using "snap". It can be removed by uninstalling the app via snapd.

看到这个后,大概猜想了下,安装软件时,snap每个软件单独搞了这个虚拟空间,那肯定有个真正的地方,又找了下,发现在/var/snap/下其实才是真正配置的地方,下面这个回答更加详细:

https://askubuntu.com/questions/1035127/cannot-modify-files-installed-by-snap

Snap's program files are protected against change. This is done by the process of mounting the protected files in their specific space as read only.

The process also has specific space for configuration data which includes the user's specific home space (

/home/user/snap

) for data and configurations and a space for world-wide data (

/var/snap

).

All the world-wide snap files are readable and accessible via symbolic links to the 

/snap

 area.

You can verify the real location and how the spaces are linked with the following commands.

A command to see examples of snap's protected mounts:

$ mount | egrep snap | egrep ro,
/var/lib/snapd/snaps/core_4486.snap on /snap/core/4486 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/communitheme_185.snap on /snap/communitheme/185 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/hello-world_27.snap on /snap/hello-world/27 type squashfs (ro,nodev,relatime)
/var/lib/snapd/snaps/core_4407.snap on /snap/core/4407 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/communitheme_124.snap on /snap/communitheme/124 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/core_4571.snap on /snap/core/4571 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/communitheme_246.snap on /snap/communitheme/246 type squashfs (ro,nodev,relatime,x-gdu.hide)
/var/lib/snapd/snaps/vlc_190.snap on /snap/vlc/190 type squashfs (ro,nodev,relatime,x-gdu.hide)
           
A command to see examples of snap's spaces that are not write protected:
$ mount | egrep snap | egrep -v ro,
tmpfs on /run/snapd/ns type tmpfs (rw,nosuid,noexec,relatime,size=3293156k,mode=755)
nsfs on /run/snapd/ns/hello-world.mnt type nsfs (rw)
nsfs on /run/snapd/ns/vlc.mnt type nsfs (rw)
           
By your error message you are trying to make change on files that have been programmably protected by the programmer. Your question suggests that you are the app's programmer. So you would have to use the features of snap's programming configuration to decide which files will be placed where.

How can I resolve this?

As I suggested in the comments, it would be safer and more common for you to design your program in a development environment as a normal user... normally in your own personal space, then use the snap's development system for installing the new version.

I'm not a snap programmer and can't give exact specifics of how the designing and export for use process works with snap. But I can imagine it might be similar to designing Android, or Java programs, where the developer will use some type of export or publish method to run or to test the new version in an installed configuration.

You could possibly experiment with remounting the protected read-only filesystems to read/write. I wouldn't advise it, because it might be possible to break the integrity of the snap system, or provide unexpected behavior where your application may not behave as intended because of the modification of the snap system itself.

最后找到了/var/snap/nextcloud/14827/nextcloud/config,

打开config.php,在最后粘贴:

 'trusted_domains' =>

  array (

      'xxx.xxx.xxx.xxx:port',

  ),

xxx为输入自己的映射的公网IP,如果不是默认80端口也要带上端口

完成之后,

snap start nextcloud,即可。