在 Centos7 安装私有云 owncloud

在 centos7 安装私有云 owncloud

Step1. 在 centos 上安装 Nginx

  1. yum install epel-release -y
  2. yum install nginx -y
  3. systemctl enable nginx //设置开机启动
  4. 打开 localhost观察 nginx 是否安装成功

Step2. 安装 Mysql (MariaDB)

  1. yum install mariadb-server mariadb -y
  2. systemctl start mariadb//启动MariaDB
  3. systemctl enable mariadb//设置开机启动
  4. mysql_secure_installation对 MariaDB 进行设置

Step3. 安装 PHP V7.1

  1. wget http://rpms.remirepo.net/enterprise/remi-release-7.rpm
  2. rpm -Uvh remi-release-7.rpm
  3. yum install yum-utils -y
  4. yum-config-manager --enable remi-php71
  5. yum --enablerepo=remi,remi-php71 install php-fpm php-common
  6. yum --enablerepo=remi,remi-php71 install php-opcache php-pecl-apcu php-cli php-pear php-pdo php-mysqlnd php-pgsql php-pecl-mongodb php-pecl-redis php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml//安装PHP 拓展。若还有其他拓展可以另外执行安装

STEP4. 配置 SSL(Https 证书)

  1. sudo apt-get install git
  2. git clone https://github.com/letsencrypt/letsencrypt
  3. cd letsencrypt/
  4. sudo systemctl stop nginx//停止 nginx
  5. ./letsencrypt-auto certonly --standalone --email 你的邮箱地址 --agree-tos -d 你的域名
  6. 你的SSL证书会保存在/etc/letsencrypt/live/<你的域名>目录下.

STEP5. 配置 Nginx

新建一个配置文件vi /etc/nginx/conf.d/owncloud.conf

server {
        listen 80;
        server_name .biyongyao.com; #YourIP or domain
        return 301 https://$server_name$request_uri;  # redirect all to use ssl
}


server {
        listen 443 ssl;
        server_name biyongyao.com; #YourIP or domain

    #SSL Certificate you created
    ssl_certificate /etc/letsencrypt/live/.biyongyao.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/.biyongyao.com/privkey.pem;

    # owncloud path
    root /usr/share/nginx/html/owncloud/;

    client_max_body_size 10G; # set max upload size
    fastcgi_buffers 64 4K;

    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 ~ ^/(data|config|\.ht|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)(/.*)?$ {
            try_files $1 = 404;

            include fastcgi_params;
            fastcgi_param SCRIPT_FILENAME $document_root$1;
            fastcgi_param PATH_INFO $2;
            fastcgi_param HTTPS on;
            #fastcgi_pass php-handler;
            fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            fastcgi_index index.php;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }

    # 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;
    }

}

vi /etc/nginx/nginx.conf 在最后一个花括号前面增加一句 include /etc/nginx/conf.d/*.conf;

参考的文章

  1. Debian8+Nginx+MariaDB+PHP7环境搭建ownCloud云存储
  2. 一步步教您在 CentOS 7 上搭建 ownCloud 私有云
  3. 基于CentOS7.3搭建owncloud私有云
  4. How to Install Nginx, MySQL, PHP v7 (LEMP) stack on CentOS 7
  5. 如何在CentOS 7上使用Nginx和MariaDB安装OwnCloud 8

你可能感兴趣的:(Linux/Unix服务器)