一、关于owncloud
ownCloud 是一个开源免费专业的私有云存储项目,它能帮你快速在个人电脑或服务器上架设一套专属的私有云文件同步网盘,可以像Dropbox 那样实现文件跨平台同步、共享、版本控制、团队协作等等。ownCloud能让你将所有的文件掌握在自己的手中,只要你的设备性能和空间充足,那么用其来几乎没有任何限制。
ownCloud 项目使用了 PHP+MySQL 的经典组合,无论在自己的电脑上或是 VPS 服务器上,基本上只要能跑 WordPress 网站的机器都能运行了,安装服务器端就像用 PHP 程序建站一样简单。官方建议在 Linux (如Ubuntu 或 CentOS) 系统下搭建,对于 Windows 作为主机的用户,可以通过WAMP、XAMPP 等工具搭建简单的运行环境。另外ownCloud 还提供了搭建好环境的虚拟机文件,你可以直接在VMWare、VirtualBox、Hyper-V 中运行 ownCloud 服务器端。
二、实验环境:
机器配置(腾讯云服务器CVM)
• 操作系统CentOS 7.3 64位 + 深度学习环境
• CPU1核
• 内存1GB
• 系统盘50 GB(本地硬盘)
• 数据盘30 GB(本地硬盘)
• 公网带宽1Mbps
• 公网IP 123.207.90.29
• 内网IP 172.16.0.14
[root@VM_0_14_redhat ~]# uname -a
Linux VM_0_14_redhat 3.10.0-514.21.1.el7.x86_64 #1 SMP Thu May 25 17:04:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
[root@VM_0_14_redhat ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
三、部署owncloud环境:
我部署owncloud是在LAMP的环境下,先来配置下LAMP
(httpd+php+mariadb)
基于强迫症先改个主机名(服务器刚买)
[root@VM_0_14_redhat ~]# hostnamectl set-hostname owncloud-01.gzhxy
[root@VM_0_14_redhat ~]#reboot
下面开始部署实验环境了
1)安装httpd ,php ,mariadb 软件
[root@owncloud-01 ~]# yum install httpd -y
[root@owncloud-01 ~]# yum install php -y
[root@owncloud-01 ~]# yum install mariadb mariadb-server -y
2)安装完重启一下apache服务
[root@owncloud-01 ~]# systemctl restart httpd
3)关闭防火墙,selinux
[root@owncloud-01 ~]# systemctl stop firewalld
[root@owncloud-01 ~]# setenforce 0
setenforce: SELinux is disabled
[root@owncloud-01 ~]# iptables -F
4)建立一个php探针测试是否能调用PHP
[root@owncloud-01 ~]# vim /var/www/html/phpinfo.php
在phpinfo.php文档中添加如下内容
<?php phpinfo (); ?>
在浏览器中输入:123.207.90.29/phpinfo.php
5)启动mariadb
[root@owncloud-01 html]# systemctl start mariadb
6)初始化数据库服务
[root@owncloud-01 html]# mysql_secure_installation
NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!
In order to log into MariaDB to secure it, we'll need the current
password for the root user. If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.
Enter current password for root (enter for none): #回车
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.
Set root password? [Y/n] y # 选择Y设置密码
New password:
Re-enter new password:
Reloading privilege tables..
... Success!
By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] #选择Y删除匿名账户
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y #选择Y禁止root用户从远程登录
... Success!
By default, MariaDB comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y #选择Y删除test数据库并取消对其的访问权限
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y #选择Y刷新授权表,让初始化的设定立即生效
... Success!
Cleaning up...
All done! If you've completed all of the above steps, your MariaDB
installation should now be secure.
Thanks for using MariaDB!
7)使用root用户登录到数据库中:
[root@owncloud-01 ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 10
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
8)创建数据库和设置密码
MariaDB [(none)]> create database owncloud;
Query OK, 1 row affected (0.01 sec)
MariaDB [(none)]> use owncloud;
Database changed
MariaDB [owncloud]> GRANT ALL ON owncloud.* to 'lszadmin'@'localhost' IDENTIFIED BY 'baidu.com@ip';
Query OK, 0 rows affected (0.00 sec)
MariaDB [owncloud]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [owncloud]> quit
Bye
LAMP环境搭建完成了,接下来是把owncloud软件下载后导入linux服务器
9)下载owncloud安装包并且解压到/var/www/html目录下
[root@owncloud-01 ~]# wget https://download.owncloud.org/community/owncloud-10.0.3.tar.bz2
[root@owncloud-01 ~]# tar -jxvf owncloud-10.0.3.tar.bz2 -C /var/www/html/
10)接下来我们需要为Web服务器上文件目录设置读写权限:
[root@owncloud-01 ~]#chown -R apache.apache /var/www/html/owncloud/
11)然后通过客户端游览器进行配置,
PHP版本过低,要升级PHP5.6才可以,默认安装PHP的版本太低。
[root@owncloud-01 ~]# php -v
PHP 5.4.16 (cli) (built: Nov 15 2017 16:33:54)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
执行下面的命令升级软件仓库
[root@owncloud-01 ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.
[root@owncloud-01 ~]#rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic- release.rpm
删除PHP
[root@owncloud-01 ~]# yum remove php-common
安装PHP5.6
[root@owncloud-01 ~]# yum install -y php56w php56w-opcache php56w-xml php56w-mcrypt php56w-gd php56w-devel php56w-mysql php56w-intl php56w-mbstring
重启httpd服务
[root@owncloud-01 ~]# systemctl restart httpd
查看php版本
[root@owncloud-01 ~]# php -v
PHP 5.6.32 (cli) (built: Oct 29 2017 14:02:30)
Copyright (c) 1997-2016 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.6-dev, Copyright (c) 1999-2016, by Zend Technologies
12)在输入http://123.207.90.29/owncloud浏览器测试,
13)设置管理员账号密码,数据存放目录,数据库。
关于安装目录,最好是不把储存目录放在网页目录里,因为其他人可能会在不登录的情况下直接下载你的文件,要将文件储存到网页目录之外,比如我这里要将文件存储到/var/owncloud_data目录里
[root@owncloud-01 ~]# cd /var
[root@owncloud-01 var]# mkdir owncloud_data
[root@owncloud-01 var]# chown apache owncloud_data -Rf
[root@owncloud-01 var]# chmod 770 owncloud_data -Rf
安装完成就可以使用账号密码登陆使用
配置登陆完成界面
有分享,上传功能
以管理者身份登陆,可以添加组合用户,设置,上传的文件大小,等一些功能
添加一个public组,添加一个匿名登陆账号
以管理员身份上传文件
在服务器的owncloud数据存放目录自动生成该用户目录,能看到上传的文件
以匿名用户账号登陆,上传文件
服务器端生成目录,存放文件
以上基本owncloud功能已经实现,还有很多东西可以优化,如ssl等。
现在修改httpd.conf的配置文件,使其直接用ip就能访问,(比较穷没有域名,学习测试使用)
修改成/var/www/html/owncloud,保存退出,重启服务
[root@owncloud-01 conf]# systemctl restart httpd
测试链接账号密码
http://116.196.118.33/index.php/login
账号Anonymous
密码:admin@123