1. Update the system to install the necessary dependency packages
[user]$ sudo apt-get update && sudo apt-get-y upgrade[user]$ sudo apt-get install Software-properties-common Nano Wget
2. Install MariaDB10 above, if it is not clear whether the installed version meets the Nextcloud requirements, you can check the official website
Nextcloud Official website: https://nextcloud.com/install/#
MARIADB Installation and configuration:
[user]$ sudo apt-get install-y mariadb-server
After the installation is complete, run:
[User]$ mysql_secure_installation
The main purpose of this is to update and configure the database, at the same time set the corresponding root password, I encountered a problem in the installation of the normal user can not successfully connect to the database, need to switch to root, there is no solution to this problem, if any big guy can solve, please leave me a message.
Restart the MARIADB service:
[user]$ sudo service MySQL restart
Log in to the database and create the appropriate database
[User]$ mysql-uroot-p
* Note This step if login failed, please switch root user to execute
To create a database:
MariaDB [(None)]> CREATE DATABASE Nextcloud; MariaDB [(None)]> GRANT all privileges on nextcloud.* to ' nextcloud ' @ ' localhost ' identified by ' Strong_password '; MariaDB [(None)]> FLUSH privileges; MariaDB [(none)]> \q
3. Install PHP
[user]$ sudo apt-get -y install php-fpm php-cli php-json php-curl php-imap php-gd php-mysql php-xml php-zip php-intl php-m Crypt Php-imagick php-mbstring
The PHP memory set here is 512mb,upload_max_filesize and post_max_size for 200M
[user]$ sed-i "s/memory_limit =. */memory_limit = 512m/"/etc/php/7.0/fpm/php.ini[user]$ sed-i "s/;d ate.timezone.*/date . TimeZone = utc/"/etc/php/7.0/fpm/php.ini[user]$ sed-i" s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/"/etc/php/7.0/fpm /php.ini[user]$ sed-i "s/upload_max_filesize =. */upload_max_filesize = 200m/"/etc/php/7.0/fpm/php.ini[user]$ sed-i "s /post_max_size =. */post_max_size = 200m/"/etc/php/7.0/fpm/php.ini
* Location of the configuration file:
Php:/etc/php/7.0/fpm/php.ini
Configure PHP-FPM
Configuration file using the default is good, if there is a problem, please refer to the following about environment variable configuration
[user]$ sudo nano/etc/php/7.0/fpm/pool.d/www.conf
Environment variables:
Env[hostname] = $HOSTNAMEenv [PATH] =/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/binenv[tmp] =/tmpenv[ TMPDIR] =/tmpenv[temp] =/tmp
Restart the PHP-FRM service:
[user]$ sudo service php7.0-fpm restart
4. Download and install NextCloud12
This installs the Nextcloud to the/var/www/nextcloud/directory, installs the directory according to the personal hobby to be OK
[user]$ wget https://download.nextcloud.com/server/releases/nextcloud-12.0.0.zip[user]$ Unzip Nextcloud-12.0.0.zip [user]$ sudo mkdir/var/www/[user]$ sudo mv nextcloud/var/www/[user]$ rm-f nextcloud-12.0.0.zip[user]$ sudo chown-r www -data:/var/www/nextcloud
5. Installing and configuring Nginx
[user]$ sudo apt-get install Nginx-extras nginx
6. Here to create the corresponding SSL certificate, convenient for everyone to access, if there is a corresponding certificate, the certificate will be placed in the/etc/nginx/ssl directory, if it is novice, please note the name of the certificate
[user]$ sudo mkdir-p/etc/nginx/ssl[user]$ cd/etc/nginx/ssl[user]$ sudo openssl genrsa-des3-passout pass:x-out NEXTCL Oud.pass.key 2048[user]$ sudo openssl rsa-passin pass:x-in nextcloud.pass.key-out nextcloud.key[user]$ sudo rm nextclou d.pass.key[user]$ sudo openssl req-new-key nextcloud.key-out nextcloud.csr[user]$ sudo openssl x509-req-days 365-in Nextcloud.csr-signkey Nextcloud.key-out NEXTCLOUD.CRT
7.
Create the appropriate configuration file for the Nginx server:
[user]$ sudo nano/etc/nginx/sites-available/nextcloud
File contents:
server {Listen 80; server_name my.nextcloud.com; Return 301 https://$server _name$request_uri;} server {Listen 443 SSL http2; server_name my.nextcloud.com; Root/var/www/nextcloud; SSL on; SSL_CERTIFICATE/ETC/NGINX/SSL/NEXTCLOUD.CRT; Ssl_certificate_key/etc/nginx/ssl/nextcloud.key; Ssl_session_timeout 5m; Ssl_ciphers ' Aes128+eecdh:aes128+edh:!anull '; Ssl_protocols TLSv1 TLSv1.1 TLSv1.2; Ssl_prefer_server_ciphers on; Add_header x-content-type-options Nosniff; Add_header x-frame-options "Sameorigin"; 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; Access_log/var/log/nginx/nextcloud.access.log; Error_log/var/log/nginx/nextcloud.error.log; Location =/robots.txt {Allow all; Log_not_found off; Access_log off; } location =/.well-known/carddav { Return 301 $scheme://$host/remote.php/dav; } location =/.well-known/caldav {return 301 $scheme://$host/remote.php/dav; } client_max_body_size 512M; Fastcgi_buffers 4K; gzip off; Error_page 403/core/templates/403.php; Error_page 404/core/templates/404.php; 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/.+|core/ TEMPLATES/40[34]) \.php (?: $|/) {include fastcgi_params; Fastcgi_split_path_info ^ (. +\.php) (/.+) $; 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 Unix:/var/run/php/php7.0-fpm.sock; Fastcgi_intercept_errors on; Fastcgi_request_buffering off; } location ~ ^/(?: Updater|ocs-provider) (?: $|/) {try_files $uri/= 404; Index index.php; } location ~* \. (?: Css|js) $ {try_files $uri/index.php$uri$is_args$args; Add_header Cache-control "public, max-age=7200"; Add_header x-content-type-options Nosniff; Add_header x-frame-options "Sameorigin"; 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 ~* \. (?: Svg|gif|png|html|ttf|woff|ico|jpg|jpeg) $ {try_files $uri/index.php$uri$is_args$args; Access_log off; } location-/\.ht {deny all; }}
Note: You need to change the corresponding domain name here, do not copy directly
Link the appropriate configuration file:
[user]$ sudo ln-s/etc/nginx/sites-available/nextcloud/etc/nginx/sites-enabled/nextcloud
Restart Nginx Service:
[user]$ sudo nginx-t[user]$ sudo service nginx restart
8. To this, the installation is complete, next you need to log in to Nextcloud and configure the appropriate file storage location:
Open Browser Input:
8.https://my.nextcloud.com/install.php
Note that the domain name set here, if not set the domain name, the same network segment under the use of IP access, I here in the same route access Nextcloud, Host IP is 192.168.1.105, how to view their host IP method has a lot, command also line, Route also line, how convenient how to come.
https://192.168.1.105/install.php
After opening the Web page, set the appropriate administrator user name and password and the corresponding file storage location, this location can be arbitrarily set, but need to change the location of the group and owner is Www-data,
Note: Uploading and downloading large files may prompt the file to be too large to change the maximum limit for uploading and downloading files:
The configuration file needs to be modified: (1)./etc/php/7.0/fpm/php.ini
PHP memory,upload_max_filesize and Post_max_size
(2)./etc/nginx/sites-available/nextcloud
Client_max_body_size 1024M;
(3)/var/www/nextcloud/.htaccess
Php_value upload_max_filesize
Php_value post_max_size
Php_value Memory_limit
Specific size according to personal circumstances set
After the configuration is complete, restart the appropriate service:
sudo systemctl restart Nginx
Ubuntu Server Installation Nextcloud12