标签:mysql apache 企业私有云 owncloud
本文讲单机版Owncloud安装,即所有component都安装在一个server上。Owncloud推荐使用如下环境(详见OwncloudServerAdminManual Chapter2):
* Red Hat Enterprise Linux 7
* MySQL/MariaDB
* PHP 5.4 +
* Apache 2.4
(注意,自从8.0后不再支持windows Server版)
安装方式有两种,一种是RPM包,一种是源码安装。安装之前最好disable selinux和iptables,不然会出现问题,/etc/syslinux/config中设置为disable
1,RPM包
详见 http://software.opensuse.org/download.html?project=isv:ownCloud:community&package=owncloud
例如,
对于 CentOS CentOS-7,请以 根用户 root 运行下面命令:
cd /etc/yum.repos.d/ wget http://download.opensuse.org/repositories/isv:ownCloud:community/CentOS_CentOS-7/isv:ownCloud:community.repo yum install owncloud
对于 CentOS CentOS-6,请以 根用户 root 运行下面命令:
cd /etc/yum.repos.d/ wget http://download.opensuse.org/repositories/isv:ownCloud:community/CentOS_CentOS-6/isv:ownCloud:community.repo yum install owncloud
2,源码安装
安装PHP: yum install -y php-mysql php-json php-xml php-mbstring php-zip php-gd curl php-curl php-pdo
安装Mysql: yum install -y mysql-server mysql mysql-devel
安装Apache: yum install -y httpd
[root@BRO-centos6 owncloud]# tar -jxf owncloud-8.0.2.tar.bz2 –C /var/www/html/
[root@localhost html]# chown -R apache:apache owncloud/
[root@localhost html]# chmod -R 777 owncloud/
2.1 Mysql 配置
登陆Mysql服务器,创建Owncloud需要使用的数据库,以及用户,授予权限
如果第一次登陆mysql Server,需要使用mysqladmin –uroot password ‘’ 设置root密码
mysql>CREATE USER ‘username‘@‘localhost‘ IDENTIFIED BY ‘password‘;
mysql>CREATE DATABASE IF NOT EXISTS owncloud;
mysql>GRANT ALL PRIVILEGES ON owncloud.* TO ‘username‘@‘localhost‘ IDENTIFIED BY ‘password‘;
mysql>flush priveleges;
mysql>quit;
2.2 Apache配置
Apache配置很简单,/etc/httpd/conf/httpd.conf ,修改如下配置
ServerName 10.45.45.6:80
DocumentRoot "/var/www/html/owncloud"
2.3 Owncloud配置
Owncloud的配置文件,/var/www/html/owncloud/config/config.php
在第一次打开Owncloud页面之前,需要在config.php配置如下
<?php
$CONFIG = array (
‘datadirectory‘ => ‘/var/www/html/owncloud/data‘, <--用户数据挂载路径,比如有用户user1,user2,user3,那会在此目录下生成user1,user2,user3三个目录文件,
‘dbtype‘ => ‘mysql‘, <--配置的数据库类型,支持Microsoft SQL Server,Oracle
‘version‘ => ‘8.0.2.0‘,
‘dbname‘ => ‘owncloud2‘, <--Owncloud数据库名字,自己起
‘dbhost‘ => ‘10.45.45.7‘, <-- 数据库的IP
‘dbtableprefix‘ => ‘oc_‘,
‘dbuser‘ => ‘cloudtest2‘, <--数据库的用户名
‘dbpassword‘ => ‘password‘, <--cloudtest2用户的密码
);
打开http://10.45.45.6,第一次会出现如下页面,Admin account是管理此Owncloud Server的用户名,不是数据库的。然后是Storage&Database的配置,数据库就采用之前上面config.php的用户名密码,如果数据库主机是在本机上的,可以填写localhost或者127.0.0.1(如果localhost不行,可以试试127.0.0.1)
配置完成后,点击finish setup,第一次登陆会花费一些时间做initialization。之后就可以enjoy Owncloud了。。。
如果打开Owncloud报错,可以查看/var/www/html/owncloud/data/owncloud.log会看到一些有用的信息,例如
可以看到log中
{"reqId":"319c6484605141dd9cb541c583601187","remoteAddr":"10.0.0.2","app":"index","message":"Exception: {\"Message\":\"An exception occured in driver: SQLSTATE[42000] [1044] Access denied for user ‘cloudtest2‘@‘localhost‘ to database ‘owncloud‘\",\"Code\":0,\"Trace\":\"#0 \\\/var\\\/www\\\/html\\\/owncloud\\\/3rdparty\\\/doctrine\\\/dbal\\\/lib\\\/Doctrine\\\/DBAL\\\/Connection.php(814): OC\\\\DB\\\\Connection->connect()\\n#1 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/db\\\/connection.php(111): Doctrine\\\\DBAL\\\\Connection->executeQuery(‘SELECT `configv...‘, Array, Array, NULL)\\n#2 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/appconfig.php(259): OC\\\\DB\\\\Connection->executeQuery(‘SELECT `configv...‘, Array)\\n#3 \\\/var\\\/www\\\/html\\\/owncloud\\\/lib\\\/private\\\/app.php(219): OC\\\\AppConfig->getValues(false, ‘enabled‘)\\n#4
解决方法就是grant cloudtest2用户权限
mysql>GRANT ALL PRIVILEGES ON owncloud TO ‘cloudtest2‘@‘localhost‘ IDENTIFIED BY ‘password‘ WITH GRANT OPTION;
mysql> show grants for cloudtest2;
---------------------------------------------------------------------
后续:可以登录到mysql上查看多了个owncloud2数据库,有21个表
mysql> use owncloud2;
mysql> show tables;
+------------------------+
| Tables_in_owncloud2 |
+------------------------+
| oc_activity |
| oc_activity_mq |
| oc_appconfig |
| oc_file_map |
| oc_filecache |
| oc_files_trash |
| oc_group_admin |
| oc_group_user |
| oc_groups |
| oc_jobs |
| oc_locks |
| oc_mimetypes |
| oc_preferences |
| oc_privatedata |
| oc_properties |
| oc_share |
| oc_share_external |
| oc_storages |
| oc_users |
| oc_vcategory |
| oc_vcategory_to_object |
+------------------------+
21 rows in set (0.00 sec)
mysql>select * from oc_users;
+-------+-------------+----------------------------------------------------------------+
| uid | displayname | password |
+-------+-------------+----------------------------------------------------------------+
| lbs1 | NULL | 1|$2y$10$4Ife76GeABsUxMahljsjTu4Fg3or.C3hW7XApXIPXE0Grq6ueDGVu |
| root3 | NULL | 1|$2y$10$GGwwchkx4bWzG60vn2uTUuSTgzlTH2mgvaomg.LSMBzs4j9SfV7W6 |
| root | NULL | 1|$2y$10$oy4HyeMwfAcgQ7JJPUnPN.AAe/xqM67tn4CHvD7Zg6cf5.ckRO6ZK |
| pfe1 | NULL | 1|$2y$10$ClkEZDMKV69hzjnZQ2ixRuaYjuftaF8/RGKREz890MQAIF4pLuDsu |
| lbs3 | NULL | 1|$2y$10$GGjensDquLMA13OZi8cIXONaEEwntwacz.3Lyv/cH5DSN//51ozwG |
| pfe3 | NULL | 1|$2y$10$kiab38aQQ9ipU5TAxILs1eifRQI7ps4rD.dNLhIMSz7VP4i0H520a |
| lbs2 | NULL | 1|$2y$10$D2S8iB6F2JG/69MzVShT1upprN8RMETsD/XTdO.dnCf.ecZENnv12 |
| root2 | NULL | 1|$2y$10$ow34DnyuTwAvGiuSXQZxnOYUdP9el3jgd6liljFI84GJMRZYEAuLW |
| pfe2 | NULL | 1|$2y$10$e8FIfsvk6PJ3oUyjoBXlu.Z00VbghbbrRBPRO8IBaf1xB1qXa0E/6 |
+-------+-------------+----------------------------------------------------------------+
9 rows in set (0.02 sec)
进入用户数据挂载路径, ‘datadirectory‘ => ‘/var/www/html/owncloud/data‘ ,可以看到四个目录,而上面oc_users有9个用户,因为其他5个用户我没有登陆过,一旦你登陆后会自动创建一个目录用于存储用户文件。
[root@localhost data]# ll
total 48
-rwxrwx--- 1 apache apache 0 May 11 15:02 index.html
drwxrwx--- 1 apache apache 0 May 11 14:43 lbs1
-rwxrwx--- 1 apache apache 48336 May 11 16:11 owncloud.log
drwxrwx--- 1 apache apache 0 May 11 16:03 root
drwxrwx--- 1 apache apache 0 May 11 14:34 root2
drwxrwx--- 1 apache apache 0 May 11 15:02 root3
---------------------------------------------------------------------------
下一篇会讲述Owncloud Scale-out版,Apache集群+Mysql NDB Cluster+Haproxy组成Owncloud高可用版本~
本文出自 “star&storage” 博客,请务必保留此出处http://taotao1240.blog.51cto.com/731446/1650835
标签:mysql apache 企业私有云 owncloud
原文地址:http://taotao1240.blog.51cto.com/731446/1650835