nginx部署owncloud记录

写在前面

此次ownCloud的安装基于LNMP环境,LNMP配置不再展开说明。

ownCloud包下载

owncloud官网下载包并解压:

 wget https://download.owncloud.org/community/owncloud-complete-yyyymmdd.tar.bz2
 
 tar -xjf owncloud-complete-yyyymmdd.tar.bz2

ownCloud根目录一般为/var/www/html,本次移动到以下目录

cp -r owncloud /home/wwwroot/default/html

目录权限调整

将ownCloud目录所有者修改为www,避免出现读写权限问题

chown -R www:www /home/wwwroot/default/html/owncloud

Nginx配置

本次使用二级域名cloud.eatcabbage.com作为ownCloud的地址,因此在Nginx目录下的vhost文件夹下新增对应的配置文件:
新建 cloud.eatcabbage.com.conf如下,若直接使用nginx.conf视实际情况调整:

upstream php-handler {
  server unix:/tmp/php-cgi.sock;//php-cgi或者php-fpm解析
  }
server {
  listen 80;//端口
  server_name cloud.eatcabbage.com;//修改为要使用的域名或ip
  # Path to the root of your installation
  root /home/wwwroot/default/html/owncloud;//修改为owncloud项目存放的根目录
  # set max upload size
  client_max_body_size 10G;
  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;
  rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
  rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
  rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
  index index.php;
  error_page 403 /core/templates/403.php;
  error_page 404 /core/templates/404.php;

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;
    }
location ~ ^/(?:\.htaccess|data|config|db_structure\.xml|README){
    deny all;
    }
  location / {
  # The following 2 rules are only needed with webfinger
  rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
  rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
  rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
  rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
  rewrite ^(/core/doc/[^\/]+/)$ $1/index.html;
  try_files $uri $uri/ /index.php;
  }
  location ~ \.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_pass php-handler;
  }
  # Optional: set long EXPIRES header on static assets
  location ~* \.(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
      expires 30d;
      # Optional: Don't log access to assets
        access_log off;
  }
  }

重启nginx服务

service nginx restart

创建数据库

ownCloud建议使用mysql/MariaDB,配置数据库如下:

mysql -u root -p

mysql>  CREATE DATABASE owncloud;
   >  create user 'owncloud'@'localhost' identified by '123';
   >  GRANT ALL ON owncloud.* to 'owncloud'@'localhost' IDENTIFIED BY 'set_database_password';
   >  FLUSH PRIVILEGES;
   >  exit

首次访问ownCloud

浏览器访问owncloud地址,创建owncloud的管理员用户,配置数据库连接信息,不出意外就没问题了~

首次向导界面
如有问题,请在评论区指正

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值