其他分享
首页 > 其他分享> > owncloud部署记录

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的管理员用户,配置数据库连接信息,不出意外就没问题了~

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

标签:redirect,ownCloud,rewrite,部署,记录,owncloud,php,fastcgi
来源: https://blog.csdn.net/cabbage1016/article/details/116058483