Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

It's time to build your own private cloud disk-nextcloud 12

2025-02-23 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

I. background

Recently, a number of cloud disks have been shut down one after another, it took a lot of time to download the above things to the local, Baidu cloud disk has already begun the speed limit, how can the technical house tolerate it? It's time to build your own private cloud disk!

1. What are the benefits of building your own private cloud?

First of all, there are no capacity, download speed restrictions, and local access speed is very fast. Then you can use it with the local ftp to share files on multiple devices: for example, you can mount files in the cloud disk on TVs, mobile phones and other smart devices to play movies, watch photos, listen to songs and other needs. Finally, it can prevent leaks and harmony.

When it comes to private clouds, there are actually many off-the-shelf products that can be used, such as Qunhui, Tieweima, Xisu and so on. Buy it, plug in a hard drive and use it, which is very suitable for rookies. But the cost is slightly higher, only the host needs more than 1000 yuan, plus a hard disk, the cost of this solution is generally more than 2000 yuan. If you build your own private cloud, not only the cost is very low, but also you can customize many functions, such as online notes, e-mail and so on. But need to be able to mess with linux Oh!

2. What is the difficulty of building?

Building your own private cloud is actually very simple. You need a host first, and then you need to choose a private cloud software (such as ownCloud, Nextcloud, seafile). Here I still use my Linux server as the host, probably uploaded and downloaded as 2MB/s, after comparing several different private cloud software, finally adopted Nextcloud 12, I feel that this feature is more powerful.

II. Overview of Nextcloud 12

Nextcloud is a free (open source) Dropbox-like software evolved from the ownCloud branch. It is written in PHP and JavaScript and supports a variety of database systems, such as MySQL/MariaDB, PostgreSQL, Oracle databases, and SQLite. It synchronizes your desktop system with files on your cloud server, and Nextcloud provides client support for Windows, Linux, Mac, Android and iPhone. Nextcloud is not just a clone of Dropbox, it also provides many additional features, such as calendar, contacts, scheduled tasks, and streaming Ampache.

In this article, I will show you how to install and configure the latest version of Nextcloud 12 on the CentOS 7.3server. I will run Nextcloud through Nginx and PHP7-FPM, while using MariaDB as the database system.

1. System requirements

The official recommended parameters are as follows:

Minimum memory 512MB system Red Hat Enterprise Linux 7 / Ubuntu 16.04 LTS database

MySQL/MariaDBPHP version PHP 7.0 + WEB Server Apache 2.4 with mod_php

2. Minimum version and supporting platform are required for installation.

Server: Linux (Debian 7, SUSE Linux Enterprise Server 11 SP3 & 12, Red Hat Enterprise Linux/CentOS 6.5 and 7 (7 is 64-bit only), Ubuntu 14.04 LTS, 16.04 LTS)

Web server: Apache 2 (mod_php, php-fpm) or Nginx (php-fpm)

Databases: MySQL/MariaDB 5.5mm; PostgreSQL; Oracle 11g (currently only possible if you contact us as part of a subscription)

PHP 5.6 + required

Hypervisors: Hyper-V, VMware ESX, Xen, KVM

Desktop: Windows XP SP3 (EoL Q2 2015), Windows 7, Mac OS X 10.7 + (64-bit only), Linux (CentOS 6.5,7 (7 is 64-bit only), Ubuntu 12.04 LTS, 14.04 LTS, 14.10, Fedora 20,21, openSUSE 12.3,13, Debian 7 & 8).

Mobile apps: iOS 7, Android 4 +

Web browser: IE11+, Microsoft Edge, Firefox 14, Chrome 18, Safari 7 +

III. Nextcloud 12 environment preparation

1. Install nginx and PHP7

First of all, install the latest package warehouse of epel and webtatic, refer to my blog post at the top.

# install nginxyum install nginx-y # install the package yum-y install php70w-fpm php70w-cli php70w-opcache php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel required by php7 and its nextcloud

2. Verify the installed version of php

[root@pan] # php-vPHP 7.0.20 (cli) (built: Jun 10 2017 06:34:07) (NTS) Copyright (c) 1997-2017 The PHP GroupZend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies

3. Configure PHP7-FPM

In this step, we will configure php-fpm to run in conjunction with Nginx. Php7-fpm will run with the nginx user and listen on port 9000.

Use vim to edit the default php7-fpm configuration file.

# vim / etc/php-fpm.d/www.conf user = nginx group = nginx # in lines 8 and 10, user and group are assigned nginx. Listen = 127.0.0.1 9000 # on line 22, make sure php-fpm is running on the designated port. Env [HOSTNAME] = $HOSTNAMEenv [path] = / usr/local/bin:/usr/bin:/binenv [TMP] = / tmpenv [TMPDIR] = / tmpenv [TEMP] = / tmp # uncomment lines 366-370 and enable the system environment variable for php-fpm.

The next step is to create a new folder session under the / var/lib/ directory and change its owner to the nginx user.

Mkdir-p / var/lib/php/session chown nginx:nginx-R / var/lib/php/session/

Then start php-fpm and Nginx and set them to services that start with boot.

Systemctl start php-fpm systemctl start nginx systemctl enable php-fpm systemctl enable nginx

4. Install and configure MariaDB

I use MariaDB as the database of Nextcloud here. You can use the yum command directly to install the mariadb-server package from the CentOS default remote repository.

Yum-y install mariadb mariadb-server

Add the following lines of configuration to the configuration file / etc/my.cnf

[mysqld] innodb_file_per_table=1default-storage-engine = INNODB

Start MariaDB and add it to the service that starts with the system.

Systemctl start mariadbsystemctl enable mariadb

Now start configuring the root password for MariaDB, type Y, and then set the root password for MariaDB.

Mysql_secure_installation

Now that the password is set, log in to mysql shell and create a new database and user for Nextcloud. Here I create a database named nextcloud and a user named nextcloud with a password of nextcloud. Of course, choose a more secure password for your own system.

Mysql-u root-p

Enter the root password of MariaDB to log in to mysql shell.

Mysql > create database nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci; mysql > grant all privileges on nextcloud.* to nextcloud@localhost identified by 'nextcloud'; mysql > flush privileges

5. Generate a self-signed SSL certificate for Nextcloud

I will have the client run Nextcloud over a https connection, and here I use OpenSSL to create my own self-signed SSL certificate.

Mkdir-p / etc/nginx/cert/

As follows, use openssl to generate a new SSL certificate.

Openssl req-new-x509-days 365-nodes-out / etc/nginx/cert/nextcloud.crt-keyout / etc/nginx/cert/nextcloud.key

Finally, use the chmod command to set the permissions for all certificate files to 600.

Chmod 700 / etc/nginx/certchmod 600 / etc/nginx/cert/*

IV. Nextcloud 12 installation and configuration

1. Download and install Nextcloud

I use the wget command directly to download Nextcloud to the server.

Wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip

Extract the Nextcloud and move it to the / usr/share/nginx/html/ directory.

Unzip nextcloud-12.0.0.zipmv nextcloud/ / usr/share/nginx/html/

Next, go to the web root directory of Nginx to create a data folder for Nextcloud. It is recommended to select a larger partition to place the data directory, because all the uploaded data will be placed in it.

Cd / usr/share/nginx/html/mkdir-p nextcloud/data/

Change the owner of the nextcloud directory to nginx users and groups.

Chown nginx:nginx-R nextcloud/

2. Configure a virtual host for Nextcloud in Nginx

We have downloaded the Nextcloud source code and configured it to run on the Nginx server, but we also need to configure a virtual host for it. Create a new virtual host profile, nextcloud.conf, under the conf.d directory of Nginx.

Vim / etc/nginx/conf.d/nextcloud.conf

Paste the following into the virtual host configuration file:

Upstream php-handler {server 127.0.0.1 server 9000; # server unix:/var/run/php5-fpm.sock;} server {listen 80; server_name pan.wzlinux.com; # enforce https return 301 https://$server_name$request_uri;}server {listen 443 ssl http2; server_name pan.wzlinux.com; ssl_certificate / etc/nginx/cert/nextcloud.crt; ssl_certificate_key / etc/nginx/cert/nextcloud.key # Add headers to serve security related headers # Before enabling Strict-Transport-Security headers please read into this # topic first. Add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; # # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. Add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; # Path to the root of your installation root / usr/share/nginx/html/nextcloud/; location = / robots.txt {allow all; log_not_found off; access_log off } # The following 2 rules are only needed for the user_webfinger app. # Uncomment it if you're planning to use this app. # rewrite ^ / .well-known/host-meta / public.php?service=host-meta last; # rewrite ^ / .well-known/host-meta.json / public.php?service=host-meta-json # last; location = / .well-known/carddav {return 301$ scheme://$host/remote.php/dav;} location = / .well-known/caldav {return 301$ scheme://$host/remote.php/dav } # set max upload size client_max_body_size 512M; fastcgi_buffers 64 4K; # Enable gzip but do not remove ETag headers gzip on; gzip_vary on; gzip_comp_level 4; gzip_min_length 256; gzip_proxied expired no-cache no-store private no_last_modified no_etag auth Gzip_types application/atom+xml application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/x-font-ttf application/x-web-app-manifest+json application/xhtml+xml application/xml font/opentype image/bmp image/svg+xml image/x-icon text/cache-manifest text/css text/plain text/vcard text/vnd.rim.location.xloc text/vtt text/x-component text/x-cross-domain-policy # Uncomment if your server is build with the ngx_pagespeed module # This module is currently not supported. # pagespeed off; location / {rewrite ^ / index.php$uri;} location ~ ^ / (?: build | tests | config | lib | 3rdparty | templates | data) / {deny all;} location ~ ^ / (?:\. | autotest | occ | issue | indie | db_ | console) {deny all } location ~ ^ / (?: index | remote | public | cron | core/ajax/update | status | ocs/v [12] | updater/.+ | ocs-provider/.+)\ .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_param HTTPS on # Avoid sending the security headers twice fastcgi_param modHeadersAvailable true; fastcgi_param front_controller_active true; fastcgi_pass php-handler; fastcgi_intercept_errors on; fastcgi_request_buffering off;} location ~ ^ / (?: updater | ocs-provider) (?: $| /) {try_files $uri/ = 404; index index.php } # Adding the cache control header for js and css files # Make sure it is BELOW the PHP block location ~\. (?: css | js | woff | svg | gif) ${try_files $uri / index.php$uri$is_args$args; add_header Cache-Control "public, max-age=15778463"; # Add headers to serve security related headers (It is intended to # have those duplicated to the ones above) # Before enabling Strict-Transport-Security headers please read into # this topic first. Add_header Strict-Transport-Security "max-age=15768000; includeSubDomains; preload;"; # # WARNING: Only add the preload option once you read about # the consequences in https://hstspreload.org/. This option # will add the domain to a hardcoded list that is shipped # in all major browsers and getting removed from this list # could take several months. Add_header X-Content-Type-Options nosniff; add_header X-XSS-Protection "1; mode=block"; add_header X-Robots-Tag none; add_header X-Download-Options noopen; add_header X-Permitted-Cross-Domain-Policies none; # Optional: Don't log access to assets access_log off;} location ~\. (?: png | html | ttf | ico | jpg | jpeg) ${try_files $uri / index.php$uri$is_args$args # Optional: Don't log access to other assets access_log off;}}

Let's test if there are any errors in the Nginx configuration file, and if not, you can restart the service.

# nginx-tnginx: the configuration file / etc/nginx/nginx.conf syntax is oknginx: configuration file / etc/nginx/nginx.conf test is successful# systemctl restart nginx.service

3. Nextcloud installation

Open your Web browser, enter the domain name you set for Nextcloud, I set it to pan.wzlinux.com here, and then redirect to a more secure https connection.

Set your administrator username and password, then enter the data validation information, and click 'finish installation (Finish Setup)'.

Reference document: https://docs.nextcloud.com/server/12/admin_manual/installation/index.html

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report