目前,owncloud(https://owncloud.org/)已经被收购,之前的团队又出来创建了一个nextcloud项目(https://nextcloud.com/);如果对团队信任,可以直接搭建nextcloud,不过owncloud依然在维护;nextcloud安装方法一样
第一步:搭建php的运行环境[owncloud运行环境为php环境,支持mysql]:
这是基础,不赘述,以LNMP环境为例,可以下如下脚本跑一下即可:http://download.zhoufengjie.cn/scripts/tools/scripts/lnmp.tyumen.v7.tar.gz
tar zxvf lnmp.tyumen.v7.tar.gz
cd lnmp
./lnmp.sh
选择A,安装所有环境,跑完之后环境就有了;
第二步:证书申请:
owncloud-10.0.1建议使用https,因此大家自己申请一个域名证书,可以直接申请一个免费的:https://www.sslforfree.com,如果没有域名只是自己玩,可以自己签一个,这里不做赘述;
第三步:nginx配置:
根据自己的虚拟主机调整一下php的并发数,也可以不做调整(这里默认我的脚本配置的比较低,为了vps可以用);
为了减少后续给大家讲太多关于权限的问题,这里尽量一劳永逸:
A、更改nginx配置,将用户改成root;
vi /usr/local/nginx/conf/nginx.conf;将第一行改成:user root root;
B、把申请的证书放到/usr/local/nginx/conf/ssl/下,便于使用
C、删掉/usr/local/nginx/conf/vhosts中的所有文件,然后vi /usr/local/nginx/conf/vhosts/owncloud.conf输入如下内容:
| 
					 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114  | 
						server {     listen 80;     server_name cloud.zhoufengjie.cn;     # enforce https     return 301 https://$server_name$request_uri; } server 	{     listen 443 ssl;     server_name cloud.zhoufengjie.cn;      ssl_certificate /usr/local/nginx/conf/ssl/cloud.zhoufengjie.cn.certificate.crt;     ssl_certificate_key /usr/local/nginx/conf/ssl/cloud.zhoufengjie.cn.private.key;             index index.php index.html index.htm;             root /data/www/wwwroot/owncloud;             access_log /data/logs/access_owncloud.cn.log custom_log;             error_log  /data/logs/error_owncloud.cn.log;              location /webstatus {         		stub_status on;                 access_log off;             }     add_header X-Content-Type-Options nosniff;     add_header X-Frame-Options "SAMEORIGIN";     add_header X-XSS-Protection "1; mode=block";     add_header X-Robots-Tag none;     add_header X-Download-Options noopen;     add_header X-Permitted-Cross-Domain-Policies none;     location = /robots.txt {         allow all;         log_not_found off;         access_log off;     }     location = /.well-known/carddav {         return 301 $scheme://$host/remote.php/dav;     }     location = /.well-known/caldav {         return 301 $scheme://$host/remote.php/dav;     }     location ^~ /.well-known/acme-challenge { }     # set max upload size     client_max_body_size 512M;     fastcgi_buffers 64 4K;     # Disable gzip to avoid the removal of the ETag header     gzip off;     # Uncomment if your server is build with the ngx_pagespeed module     # This module is currently not supported.     #pagespeed off;     error_page 403 /core/templates/403.php;     error_page 404 /core/templates/404.php;     location / {         rewrite ^ /index.php$uri;     }     location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {         return 404;     }     location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {         return 404;     }     location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {         fastcgi_split_path_info ^(.+\.php)(/.*)$;         include fastcgi_params;         fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;         fastcgi_param PATH_INFO $fastcgi_path_info;         fastcgi_param HTTPS on;         fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice         fastcgi_param front_controller_active true;         fastcgi_pass 127.0.0.1:9000;         fastcgi_intercept_errors on;         fastcgi_request_buffering off; #Available since NGINX 1.7.11     }     location ~ ^/(?:updater|ocs-provider)(?:$|/) {         try_files $uri $uri/ =404;         index index.php;     }     # Adding the cache control header for js and css files     # Make sure it is BELOW the PHP block     location ~* \.(?:css|js)$ {         try_files $uri /index.php$uri$is_args$args;         add_header Cache-Control "max-age=15778463";         # Add headers to serve security related headers (It is intended to have those duplicated to the ones above)         # Before enabling Strict-Transport-Security headers please read into this topic first.         #add_header Strict-Transport-Security "max-age=15552000; includeSubDomains";         add_header X-Content-Type-Options nosniff;         add_header X-Frame-Options "SAMEORIGIN";         add_header X-XSS-Protection "1; mode=block";         add_header X-Robots-Tag none;         add_header X-Download-Options noopen;         add_header X-Permitted-Cross-Domain-Policies none;         # Optional: Don't log access to assets         access_log off;     }     location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {         try_files $uri /index.php$uri$is_args$args;         # Optional: Don't log access to other assets         access_log off;     } }  | 
					
第四步:创建数据库[root密码一定要自己改一下]
mysql -uroot
CREATE DATABASE owncloud charset utf8;
GRANT ALL ON owncloud.*TO ownclouduser@localhost IDENTIFIED BY ‘owncloudpasswd';
flush privileges;
第五步:安装owncloud
cd /data/www/wwwroot;然后下载owncloud,https://download.owncloud.org/community/owncloud-10.0.2.zip,建议直接到官网找最新的;
unzip owncloud-10.0.2.zip #没有这个命令直接yum install unzip即可
chmod +w owncloud,如果测试,直接chmod 777 owncloud,不过后续建议数据放到别的目录,这里以测试放到本目录下为例;
访问:http://cloud.zhoufengjie.cn,根据web界面提示输入管理员的用户名、管理员密码、数据库的用户名(上面配置的)、数据库的密码,点击安装完成就ok了(路径不改的话,默认是在owncloud的目录下新建了一个data>文件夹);