Installing OwnCloud 9 on Debian 8

原文:https://www.howtoforge.com/tutorial/owncloud_9-installation-on-debian_8/?utm_source=tuicool&utm_medium=referral

关于mysql操作的命令参考:

http://www.cnblogs.com/xionghui/archive/2012/03/13/2392736.html

http://www.cnblogs.com/xusir/p/3334217.html

OwnCloud offers you the ability to run a cloud storage service that you administer and control yourself. The latest version, ownCloud 9.0, was released on March 8.

//OwnCloud为您提供了运行您管理和控制自己云存储服务的能力。最新版本,ownCloud 9.0,发布于3月8日。

Installing ownCloud

Let's look at the process of installing ownCloud 9.0 on a system running Debian Jessie.

//让我们来看看运行Debian Jessie的系统上安装ownCloud 9.0的过程。

1. Install required and recommended packages (安装必要的和推荐的软件包)

Begin by installing the supporting software packages. OwnCloud uses PHP and recommends MariaDB as its database. As root, install the following packages with apt-get:

//通过安装配套的软件包开始。OwnCloud使用PHP和推荐的MariaDB作为它的数据库。在root权限下使用apt-get命令安装以下软件包:

apt-get install mariadb-server mariadb-client apache2 libapache2-mod-php5 php5-json php5-gd php5-mysql php5-curl php5-intl php5-mcrypt php5-imagick
2. Download

Next, download the ownCloud 9.0 package. In this step we will also download the SHA256 hash, ownCloud's public PGP signature, and the PGP signature for the softare package. We'll use these in the following steps to verify and authenticate the software before installing it. SHA256 is the recommended verification algorithm, but if you'd prefer to verify using MD5, that hash is also available for download on ownCloud's website.

//接下来,下载ownCloud 9.0包。在这一步中,我们也将下载SHA256哈希,ownCloud的公共PGP签名、软件包PGP签名。我们将在下面的步骤中使用这些验证,并在安装之前验证软件。SHA256是推荐的验证算法,但如果你更喜欢使用MD5验证,那么ownCloud官网也可以提供哈希值的下载。

These commands use wget to download the files, but you could just as easily download them by entering the URLs into your web browser.

//使用wget命令下载以上文件,你也可以很容易地通过输入网址到浏览器下载。

wget https://download.owncloud.org/community/owncloud-9.0.2.tar.bz2
wget https://download.owncloud.org/community/owncloud-9.0.2.tar.bz2.sha256
wget https://owncloud.org/owncloud.asc
wget https://download.owncloud.org/community/owncloud-9.0.2.tar.bz2.asc
3. Verify the integrity of the downloaded package(验证下载包的完整性)

Check that the SHA256 hash of the downloaded software archive matches the sum provided by ownCloud:

//检查下载的软件压缩包的SHA256哈希值是否与ownCloud提供的匹配:

sha256sum -c owncloud-9.0.
2
.tar.bz2.sha256

Successful output:

owncloud-9.0.0.tar.bz2: OK

If the sums do not match, you should not proceed! Make sure that your download is verified before performing the remaining steps.

//如果不匹配,则不应进行!

4. Import ownCloud PGP public key to GnuPG keyring(导入ownCloud PGP公钥到密钥库)

Next, we'll use GnuPG to verify authenticity of the software package. To do this, first import ownCloud's public PGP key into your GnuPG keyring.

//接下来,我们将使用GnuPG来验证软件包的真实性。要做这一点,首先导入ownCloud的公共PGP密钥到你的GnuPG密钥库。

gpg --import owncloud.asc

Successful output:

[...]
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)

5. Verify authenticity of package signature(验证软件包签名的真实性)

Next, use GnuPG to verify the signature of the software package. It will check the signature against the archive, using the key you imported in the previous step.

//接下来,使用GnuPG来验证软件程序包的签名。它会检查压缩文件的签名,与上一步导入的Key进行匹配。

gpg --verify owncloud-9.0.2.tar.bz2.asc

Successful output:

[...]
gpg: Good signature from "ownCloud <info@owncloud.com>"
[...]

You will receive a warning that ownCloud's signature is not yet trusted. Trusting the signature is an optional step for you to perform yourself. For more information about trusting public keys, refer to the GNU Privacy Handbook, Chapter 3.

//您将收到ownCloud的签名尚未信任的警告。信任签名是你自己执行可选步骤。有关信任公钥的详细信息,请参阅GNU隐私手册,第3章

6. Extract software package

After the download is verified and authenticated, extract it.

//下载进行验证,验证后,将其解压缩。

tar xjvf owncloud-9.0.2.tar.bz2
7. Copy ownCloud directory into Apache2 document root(复制ownCloud目录到Apache2的web根目录)

Next, copy the newly-created owncloud directory and its contents into your web document root. In Debian 8, Apache2 uses /var/www/htmlas its default document root; you can customize this location if you wish. In this tutorial, we will place owncloud directly into /var/www.

//接下来,复制新创建的owncloud目录及其内容到您的网页文档根目录。在Debian8中,Apache2 使用/ var / www / html等作为其默认文档根目录; 如果你愿意,你可以自定义这个位置。在本教程中,我们将会把owncloud直接进入的/ var / WWW

cp -r owncloud /var/www
8. Add owncloud to Apache2 available sites(owncloud添加到现有的Apache2网站)

Now we can begin configuring Apache2. Create a copy of the default site configuration file, /etc/apache2/sites-available/000-default.conf, naming it owncloud.conf.

//现在我们可以开始配置Apache2。创建默认的站点配置文件的副本,拷贝/etc/apache2/sites-available/000-default.conf,将其重命名为owncloud.conf。

cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/owncloud.conf
9. Edit ownCoud site configuration(编辑ownCoud站点配置)

As root, open /etc/apache2/sites-available/owncloud.conf in a text editor. Make the following modifications:

  1. Locate the ServerName line and uncomment it by removing the leading#
  2. Change the ServerName value to match the hostname that will appear in the URL you use to access the server: for instance,www.mypersonaldomain.com or myhostname
  3. Add the following lines to the end of the file, modifying the directory name as necessary to conform to the location where you placed owncloud:

//使用root用户,在文本编辑器中打开/etc/apache2/sites-available/owncloud.conf 。做如下修改:

  1. 找到服务器名称行,并除去它的注释 “#”
  2. 更改服务器名称值,使用主机名或者网站域名:例如,www.mypersonaldomain.comMYHOSTNAME
  3. 添加下列行到文件的末尾,必要时修改目录路径 ,以符合您放置owncloud的位置:
Alias /owncloud "/var/www/owncloud/"

<Directory /var/www/owncloud/>
  Options +FollowSymlinks
  AllowOverride All

 <IfModule mod_dav.c>
  Dav off
 </IfModule>

 SetEnv HOME /var/www/owncloud
 SetEnv HTTP_HOME /var/www/owncloud

</Directory>
10. Symlink configuration file into /etc/apache2/sites-enabled(符号链接配置文件到/ etc / apache2的/网站启用)

Create a symbolic link to your site configuration in the directory/etc/apache2/sites-enabled:

//在目录中创建一个符号链接到您的网站配置的/ etc / apache2所启用的站点

ln -s /etc/apache2/sites-available/owncloud.conf /etc/apache2/sites-enabled/owncloud.conf
11. Enable Apache2 modules(启用apache2相关模块)

OwnCloud requires mod_rewrite. Enable it:

//OwnCloud需要mod_rewrite。启用它:

a2enmod rewrite

The headers module is recommended. Enable it:

//头部推荐模块。启用它:

a2enmod headers

The env, dir, and mime modules are also recommended. These are usually enabled by default, but you can manually enable them to be safe:
//也建议启用ENVDIRMIME这些模块。这些通常是默认启用的,但为了以防万一,最好还是手动再启用一次:

a2enmod env
a2enmod dir
a2enmod mime
12. Enable the ownCloud site configuration and restart Apache2(启用ownCloud站点配置、重启apache2)

Enable your site configuration:

//启用站点配置

a2ensite owncloud

Restart the Apache2 service so your changes take effect:

//重启apache2服务,以便使更改生效

service apache2 restart
13. Set permissions for ownCloud files(设置owncloud各文件权限)

Before you can begin configuring ownCloud, you'll need to make sure the HTTP user/group have permission to make changes to ownCloud's files. In Debian, this user and group are named www-data. Make them the owner of the owncloud directory and all its contents.

//在开始配置ownCloud前,你需要确保HTTP用户/组有权更改ownCloud的文件。在Debian中,该用户和组被命名为www-data。让它有权更改owncloud目录及其所有内容。

chown -R www-data:www-data /var/www/owncloud/

Next, refine these permissions. The exact permissions for the owncloud installation are:

  • All files should be read-write for the file owner, read-only for the group owner, and not accessible to others
  • All directories should be executable, read-write for the directory owner, and read-only for the group owner
  • The apps/ directory should be owned by [HTTP user]:[HTTP group]
  • The config/ directory should be owned by [HTTP user]:[HTTP group]
  • The themes/ directory should be owned by [HTTP user]:[HTTP group]
  • The assets/ directory should be owned by [HTTP user]:[HTTP group]
  • The data/ directory should be owned by [HTTP user]:[HTTP group]
  • The [ocpath]/.htaccess file should be owned by root:[HTTP group]
  • The data/.htaccess file should be owned by root:[HTTP group]
  • Both .htaccess files should be read-write for the file owner, read-only for the group owner, and not accessible to others

To conform to this permissions structure, copy and paste the following script into a new file. In this example, the script filename will be/root/oc-perms.sh. Modify the ocpath value if you are using a custom location.

//其次,细化这些权限。对于owncloud安装的确切权限是:

  • 所有文件应该是可读写的文件所有者,只读该组的所有者,他人无法访问
  • 所有的目录应该是可执行的,可读写的目录的拥有者,和只读的组所有者
  • apps/ 目录应该由[HTTP user]:[HTTP group]拥有
  • config/目录应该由[HTTP user]:[HTTP group]拥有
  • theme/目录应该由[HTTP user]:[HTTP group]拥有
  • assets/目录应该由[HTTP user]:[HTTP group]拥有
  • data/目录应该由[HTTP user]:[HTTP group]拥有
  • [ocpath] / htaccess文件,应该由root:[HTTP group]拥有
  • data/.htaccess文件应该由root:[HTTP group]拥有
  • 两个.htaccess文件应该由文件所有者读写,只读该组的所有者,他人无法访问

为了顺应这种权限结构,复制以下脚本粘贴到一个新的文件。在本实施例中,脚本文件名 是/root/oc-perms.sh。如果您使用的是自定义位置,请修改ocpath的值。

#!/bin/bash
ocpath='/var/www/owncloud'
htuser='www-data'
htgroup='www-data'
rootuser='root'

printf "Creating possible missing Directories
"
mkdir -p $ocpath/data
mkdir -p $ocpath/assets

printf "chmod Files and Directories
"
find ${ocpath}/ -type f -print0 | xargs -0 chmod 0640
find ${ocpath}/ -type d -print0 | xargs -0 chmod 0750

printf "chown Directories
"
chown -R ${rootuser}:${htgroup} ${ocpath}/
chown -R ${htuser}:${htgroup} ${ocpath}/apps/
chown -R ${htuser}:${htgroup} ${ocpath}/config/
chown -R ${htuser}:${htgroup} ${ocpath}/data/
chown -R ${htuser}:${htgroup} ${ocpath}/themes/
chown -R ${htuser}:${htgroup} ${ocpath}/assets/

chmod +x ${ocpath}/occ

printf "chmod/chown .htaccess
"
if [ -f ${ocpath}/.htaccess ]
 then
  chmod 0644 ${ocpath}/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/.htaccess
fi
if [ -f ${ocpath}/data/.htaccess ]
 then
  chmod 0644 ${ocpath}/data/.htaccess
  chown ${rootuser}:${htgroup} ${ocpath}/data/.htaccess
fi

Make the script executable:

//使脚本可执行

chmod u+x /root/oc-perms.sh

Execute it:

//执行它!

/root/oc-perms.sh
14. Create ownCloud database and database user

Next, prepare a database for ownCloud to use. Log in to the MariaDB client as the database root user:

//接下来,为ownCloud准备一个数据库。使用数据库的root用户登录到MariaDB:

mysql -u root -p

You will be prompted for the database root user's password. If you installed MariaDB for the first time in step 1, you were prompted to create this password. Enter it now. You will be placed at the MariaDB client prompt.

//你会被提​​示输入root用户的​​密码。如果您在步骤1中第一次安装MariaDB的,系统会提示您创建此密码。

Choose a name for your owncloud database (ocdbname), the owncloud database user (ocuser), and the password for that user (ocuserpw). Then run the following two commands at the MariaDB prompt, replacing the bracketed values with your own:

//为你的owncloud创建一个新的数据库(ocdbname),和owncloud数据库用户(ocuser)以及该用户的密码(ocuserpw)。在MariaDB的提示符下键入以下两个命令,用自己的值来替换括号内的值:

CREATE DATABASE [ocdbname];
GRANT ALL ON [ocdbname].* TO [ocuser]@localhost IDENTIFIED BY '[ocuserpw]';

Exit the database client:

quit

15. Configure ownCloud client

Navigate a web browser to your ownCloud installation, e.g.http://myhostname/owncloud. You will be presented with fields where you can create an ownCloud administrator account, and enter the database configuration values.

//打开浏览器安装ownCloud,例如HTTP:// MYHOSTNAME / owncloud。在这里你可以创建一个ownCloud管理员账号,并输入数据库配置值。

OwnCloud settings.

Username and Password are values for the user who will administer the installation; set these to whatever you like.

Database user, Database password, and Database name should conform to the [ocuser], [ocuserpw], and [ocdbname] values you created in the previous step.

Click Finish setup.

Congratulations! You're ready to start using ownCloud.

//用户名密码设置为任何你喜欢的。

数据库用户数据库密码数据库名称 对应你在上一步创建的[ocuser] [ocuserpw][ocdbname]值。

点击完成设置。

恭喜!你准备好开始使用ownCloud。

OwnCloud has been installed.

Optional: Using SSL(可选:使用SSL)

It's advisable to encrypt the network traffic that will pass in and out of ownCloud. Here are a few steps to get HTTPS up and running with your installation.

//在使用owncloud期间,最好使用加密网络通信。这里有几个步骤获得HTTPS。

1. Enable SSL in Apache2

//打开Apache的SSL功能

a2enmod ssl
a2ensite default-ssl
2. Add SSL Virtualhost configuration to owncloud.conf

//在owncloud.conf内添加SSL虚拟主机的配置

Apache2 comes with a default SSL site configuration, located in/etc/apache2/sites-available/default-ssl.conf. Copy the contents of this file and paste them into the top of owncloud.conf. Within the<VirtualHost _default_:443> section, make the following modifications:

//Apache2中带有一个默认的SSL站点配置,位于/etc/apache2/sites-available/default-ssl.conf。复制此文件中的内容并粘贴到owncloud.conf配置文件顶部然后将其中的<VirtualHost _default_:443>部分,进行以下修改:

Add a ServerName line with your hostname as the value, e.g.:

//使用你的主机名添加一个服务器名,例如:

ServerName myhostname

Edit the DocumentRoot line to reflect the parent directory of the owncloud installation, e.g.:

//编辑DocumentRoot,使用owncloud的安装路径:

DocumentRoot /var/www/
3. Generate a new certificate/key pair, if necessary

//生成新的证书/密钥对,如果有必要

The <VirtualHost _default_:443> section already contains three important lines for enabling SSL when the site is accessed by HTTPS:

// <VirtualHost_default_:443>部分已经包含了三条重要命令来开启SSL:

SSLEngine on
SSLCertificateFile /etc/ssl/certs/ssl-cert-snakeoil.pem
SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

The SSLCertificateFile and SSLCertificateKeyFile values point to files that should already exist on your system, installed as part of the defaultopenssl and ssl-cert packages. However, you may need to regenerate these files under certain circumstances -- if you make changes to the configuration in /etc/hosts, for instance.

//该SSLCertificateFileSSLCertificateKeyFile值指向您的系统,OpenSSLSSL证书包作为安装的一部分。但是在某些情况下您可能需要重新生成这些文件--如果您更改了/ etc / hosts文件的配置

If you need to regenerate these files, use the command:

//如果您需要重新生成这些文件,使用下面的命令:

make-ssl-cert generate-default-snakeoil --force-overwrite

For more information, and for troubleshooting certificate errors, refer to the notes in /usr/share/doc/apache2/README.Debian.gz.

//有关详细信息,以及证书错误故障排除,请参考笔记/usr/share/doc/apache2/README.Debian.gz

4. Reload Apache2 configuration
service apache2 reload

You should now be able to access your ownCloud installation using anhttps:// URL. Note that you will receive a warning in your web browser because your certificate is self-signed. You will need to manually add your site as an exception before establishing the secure connection.

//现在,您应该可以使用https://开头的URL访问您的ownCloud。请注意,Web浏览器将收到一条警告,因为你的证书是自签名的。您将需要建立安全连接之前,手动添加您的网站作为受信站点。

Ubuntu16.04 ownCloud 9.0 安装参考
http://zzy.my/blog/post/ubuntu16-owncloud9

#########################命令补充参考###########################

修改文件夹所属
1.先改所属用户/组
chown -R user:user-group /var
把目录/var及其下的所有文件和子目录的属主改成user,属组改成user-group
 
2.再改目录文件权限
chmod -R 777 /var
更改var目录及子目录权限为777
 
原文地址:https://www.cnblogs.com/airoot/p/5482151.html