1. 程式人生 > >動手實驗:部署私有雲盤“NextCloud”

動手實驗:部署私有雲盤“NextCloud”

NextCloud OwnCloud

上篇《Linux部署Nginx+Mysql+PHP+PHPMyAdmin4環境》中,我們通過文章已經學會基本的LNMP環境的部署,本次開始部署一套私有雲盤來來驗證環境,並提升對Linux認識與興趣。

首先介紹一下此次任務主角NextCloud:

技術分享圖片

NextCloud的前身叫Owncloud,Owncloud的老大被投資後不滿產品商業化氣息太重,Owncloud GmbH(德國)和 Owncloud Inc(美國)之間逐漸形成了無法逾越的鴻溝。公司開始通過提供技術支持賺錢,並向其他領域擴張,抱怨的聲音開始在開源社區久久回蕩。於是決定憤然離職重新開發了NextCloud。事實證明確實要比 OwnCloud 更體貼好用



一、開始安裝-下載

NextCloud官網:https://www.nextcloud.com

網站上有各種平臺的部署包,有ovf、docker、tar等等,我們采取TAR包的形式部署。

[root@VM-01 /]# cd /tmp
[root@VM-01 tmp]# wget https://download.nextcloud.com/server/releases/nextcloud-13.0.2.tar.bz2
[root@VM-01 tmp]# tar -jxvf nextcloud-13.0.2.tar.bz2
[root@VM-01 tmp]# mv nextcloud /www
[root@VM-01 tmp]# chown -R apache:apache /www/nextcloud
[root@VM-01 tmp]# chmod 777 /www/nextcloud/config
[root@VM-01 tmp]# mkdir /data
[root@VM-01 tmp]# chown -R apache:apache /data



二、開始安裝-配置數據庫


修改默認字符集:uft8mb4

[root@VM-01 /]# vim /etc/my.cnf


添加utf8mb4配置如圖


技術分享圖片


[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect='SET NAMES utf8mb4'
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
[root@VM-01 /]# service mysqld restart
[root@VM-01 /]# mysql -u root -p
Enter password: 
       Welcome to the MySQL monitor.  Commands end with ; or \g.
       Your MySQL connection id is 3
       Server version: 5.7.22 MySQL Community Server (GPL)
       Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
       Oracle is a registered trademark of Oracle Corporation and/or its
       affiliates. Other names may be trademarks of their respective
       owners.
       Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
       mysql> show variables like "%character%";show variables like                          "%collation%";
      +--------------------------+----------------------------+
      | Variable_name            | Value                      |
      +--------------------------+----------------------------+
      | character_set_client     | utf8mb4                    |
      | character_set_connection | utf8mb4                    |
      | character_set_database   | utf8mb4                    |
      | character_set_filesystem | binary                     |
      | character_set_results    | utf8mb4                    |
      | character_set_server     | utf8mb4                    |
      | character_set_system     | utf8                       |
      | character_sets_dir       | /usr/share/mysql/charsets/ |
      +--------------------------+----------------------------+
      8 rows in set (0.01 sec)
      +----------------------+--------------------+
      | Variable_name        | Value              |
      +----------------------+--------------------+
      | collation_connection | utf8mb4_unicode_ci |
      | collation_database   | utf8mb4_unicode_ci |
      | collation_server     | utf8mb4_unicode_ci |
      +----------------------+--------------------+
      3 rows in set (0.02 sec)
      mysql> create database nextcloud;
      Query OK, 1 row affected (0.02 sec)
      mysql> show databases;
      +--------------------+
      | Database           |
      +--------------------+
      | information_schema |
      | mysql              |
      | nextcloud          |
      | performance_schema |
      | phpmyadmin         |
      | sys                |
      +--------------------+
      6 rows in set (0.00 sec)

坑一:SQLSTATE[HY000] [2019] Can't initialize character set utf8mb4 (path: /usr/share/mysql/charsets/)

[root@VM-01 /]# yum remove php56w-mysql
[root@VM-01 /]# yum install php56w-mysqlnd


三、開始安裝-配置Nginx,開啟pathinfo。


[root@VM-01 /]# cd /etc/nginx/conf.d
[root@VM-01 conf.d]# cp default.conf nextcloud.conf
[root@VM-01 conf.d]# vim nextcloud.conf
server {
    listen       8082;
    server_name  localhost;
    client_max_body_size 1000m;
    #charset koi8-r;
    access_log  /var/log/nginx/nextcloud.log  main;
    location / {
        root   /www/nextcloud;
        index  index.html index.htm index.php;
    }
    #error_page  404              /404.html;
    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    location ~ [^/]\.php(/|$)
       {
        root           /www/nextcloud;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
            fastcgi_split_path_info ^(.+?\.php)(/.*)$;
            set $path_info $fastcgi_path_info;
            fastcgi_param PATH_INFO $path_info;
            try_files $fastcgi_script_name =404;
    }
    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
                   }
}


四、Web安裝-NextCloud


訪問:http://192.168.18.232:8082


技術分享圖片

技術分享圖片


當你看到最後的頁面說明已經安裝成功了,快享受技術帶來的愉悅感吧!:)


技術分享圖片


我在公網上也部署了這套系統,有興趣的同學要是著急體驗對比可以直接訪問:

NextCloud

http://111.231.86.247:8084
Name: Guest
Password: www.richcan

OwnCloud

http://111.231.86.247:8082
Name: Guest
Password: www.richcan

全文完!


動手實驗:部署私有雲盤“NextCloud”