NextCloud(https://nextcloud.com/)是开源的、可以用来搭建自己的文件同步和共享的私有云服务器,它是ownCloud的一个分支。

我使用LEMP做为NextCloud的运行环境-MariaDB, PHP-FPM 和 Nginx(Ubuntu 16.04)。

1、安装MariaDB

Ubuntu 16.04 安装 MariaDB

首先,更新升级系统:

$ sudo apt update

$ sudo apt upgrade

安装MariaDB:

$ sudo apt install mariadb-server

启动MariaDB服务:

$ sudo systemctl start mysql

查看状态:

$ sudo systemctl status mysql

为例提高MariaDB的安全,我们可以执行初始化安全脚本:

$ sudo mysql_secure_installation

默认root密码为空;然后设置root密码和其他选项:

- Set root password? [Y/n] y

- Remove anonymous users? [Y/n] y

- Disallow root login remotely? [Y/n] y

- Remove test database and access to it? [Y/n] y

- Reload privilege tables now? [Y/n] y

登陆MariaDB命令行:

$ sudo mysql -u root -p

2、为NextCloud创建一个数据库和用户

$ sudo mysql -u root -p

MariaDB [(none)]> CREATE DATABASE nextcloud;

MariaDB [(none)]> GRANT ALL PRIVILEGES ON nextcloud.* TO 'nextcloud'@'localhost' IDENTIFIED BY 'test1234';

MariaDB [(none)]> FLUSH PRIVILEGES;

MariaDB [(none)]> \q

创建数据库nextcloud;用户名nextcloud,密码test1234。

3、安装PHP和相关模块

$ 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-mcrypt php-imagick php-mbstring

配置PHP:

$ sudo sed -i "s/memory_limit = .*/memory_limit = 512M/" /etc/php/7.0/fpm/php.ini

$ sudo sed -i "s/;date.timezone.*/date.timezone = UTC/" /etc/php/7.0/fpm/php.ini

$ sudo sed -i "s/;cgi.fix_pathinfo=1/cgi.fix_pathinfo=1/" /etc/php/7.0/fpm/php.ini

$ sudo sed -i "s/upload_max_filesize = .*/upload_max_filesize = 200M/" /etc/php/7.0/fpm/php.ini

$ sudo sed -i "s/post_max_size = .*/post_max_size = 200M/" /etc/php/7.0/fpm/php.ini

重启PHP-FPM:

$ sudo systemctl restart php7.0-fpm

4、下载NextCloud

下载地址:https://download.nextcloud.com/server/releases/,我安装时最新版本是9.0.52。

$ cd /tmp

$ wget https://download.nextcloud.com/server/releases/nextcloud-9.0.52.zip

解压到/var/www/目录并更改权限:

$ unzip nextcloud-9.0.52.zip

$ sudo mkdir /var/www/

$ sudo mv nextcloud /var/www/

$ sudo chown -R www-data: /var/www/nextcloud

5、安装配置Nginx

$ sudo apt-get install nginx nginx-extras

生成自签名证书:

$ sudo mkdir -p /etc/nginx/ssl

$ cd /etc/nginx/ssl

$ sudo openssl genrsa -des3 -passout pass:x -out nextcloud.pass.key 2048

$ sudo openssl rsa -passin pass:x -in nextcloud.pass.key -out nextcloud.key

$ sudo rm nextcloud.pass.key

$ sudo openssl req -new -key nextcloud.key -out nextcloud.csr

$ sudo openssl x509 -req -days 365 -in nextcloud.csr -signkey nextcloud.key -out nextcloud.crt

也可以使用免费的let encrypt。

创建Nginx server block文件:

$ sudo vim /etc/nginx/sites-available/nextcloud

server {

listen 80;

server_name nextcloud.topspeedsnail.com;

return 301 https://$server_name$request_uri;

}

server {

listen 443 ssl http2;

server_name nextcloud.topspeedsnail.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 64 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;

}

}

注意替换上面的域名。

创建链接:

$ sudo ln -s /etc/nginx/sites-available/nextcloud /etc/nginx/sites-enabled/nextcloud

测试Nginx配置文件:

$ sudo nginx -t

重启nginx:

$ sudo systemctl restart nginx

6、完成安装

使用浏览器访问 https://your_domain_or_IP;

设置管理员账户和数据库:

Linux安装nextcloud教程,Ubuntu安装NextCloud相关推荐

  1. linux安装ncurses教程,Ubuntu 安装 Ncurses

    Ubuntu 下编译Linux内核时,在命令行输入: make menuconfig 后,出现如下错误: *** Unable to find the ncurses libraries or the ...

  2. python3.6.3安装过程_python3.6.3安装图文教程 TensorFlow安装配置方法

    本文主要介绍Python3.6及TensorFlow的安装和配置流程. 一.Python官网下载自己电脑和系统对应的Python安装包. 网址:下载地址 一直往下拉到Files,这里我下载的是Wind ...

  3. linux安装tensorflow教程,Ubuntu 16.04 安装 TensorFlow(GPU支持)

    本文记录Ubuntu 16.04安装Tensorflow步骤,也包括怎么从源码编译安装Tensorflow. 要想安装Tensorflow GPU版本,你需要有一个新一点的Nvidia显卡. Tens ...

  4. 华为linux版本wifi驱动,Ubuntu安装无线网卡驱动 Wifi/BT BCM4330 (AP6383)

    像BCM4330 (AP6383)这样的Wifi/蓝牙一体化芯片常见于一些平板电脑.笔记本和mini pc中.特别是z3735.z8300.core m这些芯片的平板电脑很常见.AP6210也比较常见 ...

  5. 嵌入式linux mongodb,小白在Ubuntu安装mongoDB与mongo-c-driver

    目的: 本人从事嵌入式软件,项目中需要使用MongoDB,最终需要熟悉c-driver的API,小白在搭建环境有些浪费时间,故写这文章让与我同样状态的开发人员学习学习. 在Ubuntu上的安装mong ...

  6. linux mfc驱动下载,Ubuntu 安装 Brother MFC7470D 驱动

    Ubuntu 安装 Brother MFC7470D 驱动 办公室的打印机是 Brother MFC7470D ,在 Ubuntu 中安装打印机驱动时,发现没有这个型号的驱动.只有 MFC7450 的 ...

  7. linux下安装nginx出错,Ubuntu安装Nginx服务器出错解决

    Ubuntu安装Nginx服务器错误信息: ./configure: error: the HTTP rewrite module requires the PCRE library. You can ...

  8. acrobat linux 下载地址,在ubuntu安装Adobe Acrobat7.0

    在ubuntu安装Adobe Acrobat7.0 发布时间:2007-03-17 01:11:11来源:红联作者:Gpoyinsnbo 首先,安装Adobe Reader吧.在"sudo ...

  9. kinect在linux上驱动下载,Ubuntu安装Kinect驱动(openni、NITE、Sensor)及遇到的问题

    一.前言 先说一下博主的运行环境: Ubuntu kylin14.04 kinect第一代 另外还要注意的是openni.NITE.Sensor这三个包的版本必须匹配才能正常运行,我的版本分别是: O ...

最新文章

  1. (转)TabContainer要实现服务器端回传
  2. linux如何添加默认路由表_Linux-如何添加路由表
  3. 怎么看台式计算机是几位的,怎么查看自己电脑型号
  4. JAVA POI 应用系列(2)--读取Excel
  5. ps 替换文字_Python操作PPT实现自动查找替换
  6. 在学习C语言和C++初期的疑惑有哪些?
  7. 计算机文化基础清华大学PPT,数据库基础知识清华大学计算机文化基础.ppt
  8. (1)C# 创建控制台应用程序
  9. 国庆促销海报模板素材
  10. 从零开始制作小车TB6612控制电机
  11. php将ppt转jpg图片的具体步骤代码
  12. AppCompatActivity设置透明背景
  13. 企业邮箱手机怎么设置服务器,如何设置手机企业邮箱
  14. .wim .GHO 类型的镜像文件如何恢复系统
  15. 如何构建故障与危机的处理能力?《高可用及容灾架构体系化建设》下篇
  16. PUSH消息是什么?
  17. C语言:弗洛伊德算法
  18. 飞桨赋能润建股份打造智能化路网系统,实现精度速度全面提升
  19. 在Windows XP系统中如何利用IIS发布FTP资源?
  20. Sun携手希赛教育 共推国内Java认证在线教育

热门文章

  1. 构造函数的特点和作用
  2. MediaInfo库的编译 使用
  3. 数字云栖,与您共享极致计算与创新进化的科技盛宴
  4. VS性能诊断器-时间耗时诊断
  5. ASP.NET WebForm--简介
  6. Unity Layout相关组件的使用,LayoutElement为主
  7. android 4k拍摄,五款专业安卓手机摄影App,立即提高手机生产力(全部免费)
  8. 2021新版彩虹易支付系统源码/运营版/支持当面付/通道轮询/16支付插件/免签约支付系统
  9. B 站 18 岁高中生火了:历时 200 天,成功造了个机器人!
  10. 带缩略图的js相册轮播切换js特效