在 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 vpn.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/vpn.biyongyao.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/vpn.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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章