OwnCloud in OpenSUSE Leap 42.3 配置手记

发布于 2017-12-26  1.74k 次阅读


本教程感谢来自 GitHub iosifidis的英文配置教程!

Special Thanks for iosifidis From GitHub!

NAS的KDE环境崩溃加上一系列的问题让我不得不决定重新配置一遍系统,以恢复系统的正常工作,也给了我重新部署OwnCloud的机会。

官方的OpenSUSE一键安装包意外的很迷……并没有什么用系列,在404网站上看到了这篇教程,跟着部署的过程中也发现了一些问题,一并写下,算是分享吧。(然而国内会有多少人选择OpenSUSE呢

Make sure that [ssh (sshd) is enabled and also the firewall] (https://en.opensuse.org/SuSEfirewall2) either is disabled or make an exception to the apache and ssh services. You can also set a static IP ([check out how] (http://eiosifidis.blogspot.gr/2015/05/set-static-ip-on-your-opensuse-raspberry-pi.html)).

请确保ssh与防火墙启用,有条件也请设置静态IP。

First of all, let's install the required and recommended modules for a typical ownCloud installation, using Apache and MariaDB, by issuing the following commands in a terminal:

首先需要安装需要的软件,此处部署Apache与MairaDB。

zypper in apache2 mariadb apache2-mod_php5 php5-gd php5-json php5-fpm php5-mysql php5-curl php5-intl php5-mcrypt php5-zip php5-mbstring php5-zlib

Create Database

Next step, create a database. First of all start the service.

接下来,创建一个数据库,首先开启MairaDB的服务

systemctl start mysql.service
systemctl enable mysql.service

The root password is empty by default. That means that you can press enter and you can use your root user. That's not safe at all. So you can set a password using the command:

MariaDB的root用户默认密码为空,为了安全请使用以下命令为数据库设置管理员密码!

mysqladmin -u root password newpass

Where newpass is the password you want.

newpass字段就是密码,请按照自己的想法设置。
请牢记你设定的密码!

~~来自一个忘记密码重装三遍MariaDB的傻子的忠告~~

Now you set the root password, create the database.

root密码设置好了,接下来创建数据库。

命令范例如下

mysql -u root -p 
(you'll be asked for your root password/请输入数据库的root密码)

CREATE DATABASE owncloudb;

GRANT ALL ON owncloudb.* TO ocuser@localhost IDENTIFIED BY 'dbpass';

Database user/数据库用户名: ocuser
Database name/数据库名称: owncloudb
Database user password/数据库密码: dbpass

You can change the above information accordingly.

可以根据自己的想法改变以上信息。

PHP changes PHP修改

Now you should edit the php.ini file.

现在需要编辑php.ini文件了。

  • 注释:原作者使用的编辑器即为nano,请自行替换为熟悉的文本编辑器。
nano /etc/php5/apache2/php.ini

change the values

需要修改的值如下:

post_max_size = 50G
upload_max_filesize = 25G
max_file_uploads = 200
max_input_time = 3600
max_execution_time = 3600
session.gc_maxlifetime = 3600
memory_limit = 512M

and finally enable the extensions.
同时开启需要的php扩展。

extension=php_gd2.dll
extension=php_mbstring.dll

Apache Configuration Apache配置

You should enable some modules. Some might be already enabled.

以下是需要启用的模组,有些可能默认被启用了。

a2enmod php5
a2enmod rewrite
a2enmod headers
a2enmod env
a2enmod dir
a2enmod mime

Now start the apache service.

现在开启Apache的服务。

systemctl start apache2.service
systemctl enable apache2.service

Install ownCloud 安装 ownCloud

Before the installation, create the data folder and give the right permissions (preferably outside the server directory for security reasons). I created a directory in the /mnt directory. You can mount a USB disk, add it to fstab and save your data there. The commands are:

开始安装之前,创建一个数据文件夹并给予正确的权限(为了安全与服务文件夹相独立开来。)这里以在/mnt 下创建文件夹为例,你可以插个移动硬盘啥的作为你的数据仓库。

~~虽然你的数据随时都可能报销~~

mkdir /mnt/owncloud_data
chmod -R 0770 /mnt/owncloud_data
chown wwwrun /mnt/owncloud_data
  • 注:关键是你应该将文件夹所属设置给wwwrun,并正确设置权限为0770,否则后续安装会提示修正。

Now download [ownCloud] (https://owncloud.org/install/). Then unzip and move the folder to the server directory.

该下载owncloud了,顺带把它解压到服务器文件夹位置。

wget https://download.owncloud.org/community/owncloud-9.1.1.zip
unzip owncloud-9.1.1.zip
cp -r owncloud /srv/www/htdocs
chown -R wwwrun /srv/www/htdocs/owncloud/

Make sure that everything is OK and then delete the folder owncloud and owncloud-9.1.1.zip from the root (user) directory.

确保全部ok之后,删掉下载的压缩包和解压的文件夹。

Now open your browser to the server IP/owncloud

现在打开你的浏览器,输入服务器Ip/owncloud(比如127.0.0.1/owncloud)。

Set your administrator username and password.
Your data directory is: /mnt/owncloud_data
Use MariaDB.
Regarding database, use the following.
Database user: ocuser
Database name: owncloudb
Database user password: dbpass
  • 注:此处的配置需要与你之前的配置完全相同,否则无法继续操作!如果目录未正确设置权限也会报错!

接下来是本人自己踩的坑,仅供参考。

  • apache无法正常启动,报“invalid command 'order'”

Apache cannot start ,shows "invalid command 'order'".

这是由于apache版本升级造成的,2.4版本的apache以Require代替了2.2版本的Order delay,allow模式,按2.4版本的格式修正即可。

After upgraded to 2.4,Apache now use Require instead of Order,here are some examples about 2 kids of configuration.

2.2 configuration:

Order deny,allow
Deny from all

2.4 configuration:

Require all denied

2.2 configuration:

Order allow,deny
Allow from all

2.4 configuration:

Require all granted

  • 无法正确读写目录
    Access denined to the folder,or noticed folder should set in 0770.

请确认目录的所属正确(属于wwwrun用户而非其他),权限正确配置为0770。

  • PHP"文件信息"插件未正确安装

OpenSUSE默认会使用5.5.14版本的php,其不会自带fileinfo插件,自行升级即可。


只是一些无聊的闲话罢了。