nextcloud 安装部署

news2025/6/7 12:59:32

php版本不对

ubuntu nginx 配置php 网站-CSDN博客

抄自chatgpt ubuntu完全卸载干净某个包-CSDN博客

以及设置基本的php nginx环境参照上面两篇博文

然后参照官方文档 Example installation on Ubuntu 22.04 LTS — Nextcloud latest Administration Manual latest documentation

安装依赖

sudo apt update && sudo apt upgrade
sudo apt install apache2 mariadb-server libapache2-mod-php php-gd php-mysql \
php-curl php-mbstring php-intl php-gmp php-bcmath php-xml php-imagick php-zip

 安装数据库

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'username'@'localhost';
FLUSH PRIVILEGES;


//实际使用将username改为你的登录用户名 password改为你要设置的密码
CREATE USER 'admin'@'localhost' IDENTIFIED BY '123456';
CREATE DATABASE IF NOT EXISTS nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
GRANT ALL PRIVILEGES ON nextcloud.* TO 'admin'@'localhost';
FLUSH PRIVILEGES;

参照官方文档设置

Development environment — Nextcloud latest Developer Manual latest documentation

3. 将nextcloud源码下载到/var/www/nextcloud 下 将3rdpart单独下载到/var/www/nextcloud下

3.1)创建data文件夹这个用来存数据库文件的

3.2)配置data config 

sudo chmod o+rw /var/www

cd 到/var/www/nextcloud 目录下
sudo chown -R www-data:www-data config data apps

4.配置nginx-fpm 修改 路径如下 /etc/php/8.3/fpm/pool.d 这里php的版本根据你在nginx.conf里配置的php-fpm版本来

到这里基本环境部署没有问题了

然后 把nextcloud 加载到nginx上

首先copy NGINX configuration — Nextcloud latest Administration Manual latest documentation

上关于nginx的配置

需要修改 这里好像只能支持https访问 用http不行 

1.生成证书

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

最终的nginx配置文件如下

upstream php-handler {
    server 127.0.0.1:9000;
    #server unix:/run/php/php8.2-fpm.sock;
}

# Set the `immutable` cache control options only for assets with a cache busting `v` argument
map $arg_v $asset_immutable {
    "" "";
    default ", immutable";
}

server {
    listen 80;
    listen [::]:80;
    server_name cloud.example.com;

    # Prevent nginx HTTP Server Detection
    server_tokens off;

    # Enforce HTTPS
    return 301 https://$server_name$request_uri;
}

server {
    listen 443      ssl http2;
    listen [::]:443 ssl http2;
    server_name cloud.example.com;

    # Path to the root of your installation
    root /var/www/nextcloud-28.0.0; #修改点1

    # Use Mozilla's guidelines for SSL/TLS settings
    # https://mozilla.github.io/server-side-tls/ssl-config-generator/
    ssl_certificate     /etc/nginx/cert/nextcloud.crt; #修改点2
    ssl_certificate_key /etc/nginx/cert/nextcloud.key; #修改点3

    # Prevent nginx HTTP Server Detection
    server_tokens off;

    # HSTS settings
    # 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 Strict-Transport-Security "max-age=15768000; includeSubDomains; preload" always;

    # set max upload size and increase upload timeout:
    client_max_body_size 512M;
    client_body_timeout 300s;
    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 text/javascript application/javascript application/json application/ld+json application/manifest+json application/rss+xml application/vnd.geo+json application/vnd.ms-fontobject application/wasm 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;

    # Pagespeed is not supported by Nextcloud, so if your server is built
    # with the `ngx_pagespeed` module, uncomment this line to disable it.
    #pagespeed off;

    # The settings allows you to optimize the HTTP2 bandwidth.
    # See https://blog.cloudflare.com/delivering-http-2-upload-speed-improvements/
    # for tuning hints
    client_body_buffer_size 512k;

    # HTTP response headers borrowed from Nextcloud `.htaccess`
    add_header Referrer-Policy                   "no-referrer"       always;
    add_header X-Content-Type-Options            "nosniff"           always;
    add_header X-Frame-Options                   "SAMEORIGIN"        always;
    add_header X-Permitted-Cross-Domain-Policies "none"              always;
    add_header X-Robots-Tag                      "noindex, nofollow" always;
    add_header X-XSS-Protection                  "1; mode=block"     always;

    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;

    # Set .mjs and .wasm MIME types
    # Either include it in the default mime.types list
    # and include that list explicitly or add the file extension
    # only for Nextcloud like below:
    include mime.types;
    types {
        text/javascript js mjs;
	application/wasm wasm;
    }

    # Specify how to handle directories -- specifying `/index.php$request_uri`
    # here as the fallback means that Nginx always exhibits the desired behaviour
    # when a client requests a path that corresponds to a directory that exists
    # on the server. In particular, if that directory contains an index.php file,
    # that file is correctly served; if it doesn't, then the request is passed to
    # the front-end controller. This consistent behaviour means that we don't need
    # to specify custom rules for certain paths (e.g. images and other assets,
    # `/updater`, `/ocs-provider`), and thus
    # `try_files $uri $uri/ /index.php$request_uri`
    # always provides the desired behaviour.
    index index.php index.html /index.php$request_uri;

    # Rule borrowed from `.htaccess` to handle Microsoft DAV clients
    location = / {
        if ( $http_user_agent ~ ^DavClnt ) {
            return 302 /remote.php/webdav/$is_args$args;
        }
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }

    # Make a regex exception for `/.well-known` so that clients can still
    # access it despite the existence of the regex rule
    # `location ~ /(\.|autotest|...)` which would otherwise handle requests
    # for `/.well-known`.
    location ^~ /.well-known {
        # The rules in this block are an adaptation of the rules
        # in `.htaccess` that concern `/.well-known`.

        location = /.well-known/carddav { return 301 /remote.php/dav/; }
        location = /.well-known/caldav  { return 301 /remote.php/dav/; }

        location /.well-known/acme-challenge    { try_files $uri $uri/ =404; }
        location /.well-known/pki-validation    { try_files $uri $uri/ =404; }

        # Let Nextcloud's API for `/.well-known` URIs handle all other
        # requests by passing them to the front-end controller.
        return 301 /index.php$request_uri;
    }

    # Rules borrowed from `.htaccess` to hide certain paths from clients
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)(?:$|/)  { return 404; }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console)                { return 404; }

    # Ensure this block, which passes PHP files to the PHP process, is above the blocks
    # which handle static assets (as seen below). If this block is not declared first,
    # then Nginx will encounter an infinite rewriting loop when it prepends `/index.php`
    # to the URI, resulting in a HTTP 500 error response.
    location ~ \.php(?:$|/) {
        # Required for legacy support
        rewrite ^/(?!index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|ocs-provider\/.+|.+\/richdocumentscode(_arm64)?\/proxy) /index.php$request_uri;

        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        set $path_info $fastcgi_path_info;

        try_files $fastcgi_script_name =404;

        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param PATH_INFO $path_info;
        fastcgi_param HTTPS on;

        fastcgi_param modHeadersAvailable true;         # Avoid sending the security headers twice
        fastcgi_param front_controller_active true;     # Enable pretty urls
      #  fastcgi_pass php-handler;  #修改点4

        fastcgi_intercept_errors on;
        fastcgi_request_buffering off;
        fastcgi_pass unix:/run/php/php8.3-fpm.sock; #修改点5
        fastcgi_max_temp_file_size 0;
    }

    # Serve static files
    location ~ \.(?:css|js|mjs|svg|gif|png|jpg|ico|wasm|tflite|map|ogg|flac)$ {
        try_files $uri /index.php$request_uri;
        # HTTP response headers borrowed from Nextcloud `.htaccess`
        add_header Cache-Control                     "public, max-age=15778463$asset_immutable";
        add_header Referrer-Policy                   "no-referrer"       always;
        add_header X-Content-Type-Options            "nosniff"           always;
        add_header X-Frame-Options                   "SAMEORIGIN"        always;
        add_header X-Permitted-Cross-Domain-Policies "none"              always;
        add_header X-Robots-Tag                      "noindex, nofollow" always;
        add_header X-XSS-Protection                  "1; mode=block"     always;
        access_log off;     # Optional: Don't log access to assets
    }

    location ~ \.woff2?$ {
        try_files $uri /index.php$request_uri;
        expires 7d;         # Cache-Control policy borrowed from `.htaccess`
        access_log off;     # Optional: Don't log access to assets
    }

    # Rule borrowed from `.htaccess`
    location /remote {
        return 301 /remote.php$request_uri;
    }

    location / {
        try_files $uri $uri/ /index.php$request_uri;
    }
}

这个文件名字叫php 放在/etc/nginx/sites-availbale 下

然后根据我这里环境/etc/nginx/nginx.conf的配置会读取 /etc/nginx/sites-enabled/*

注意这个目录下只能有一个配置文件多了会报nginx版本不唯一的错误

重启nginx

sudo systemctl reload nginx
然后用
sudo nginx -t 检验nginx.conf配置有没有错

到这里打开浏览器https://127.0.0.1:443  应该可以看到界面了

如果要配置域名访问 需要修改/var/www/nextcloud-28.0.0/config/config.php

在下面的array下加个1 修改后 如后面

最终的配置文件如下 

<?php
$CONFIG = array (
  'instanceid' => 'ocs16cx1zwae',
  'passwordsalt' => 'ne5De7H2pGPJ6zVqN+8wdsc7aEVJ/H',
  'secret' => 'mVKj7Imqr/npL0NDU5/A27U9ftpvJBBiXZD8LwqeerXJd973',
  'trusted_domains' =>
  array (
          0 => '192.168.124.41',
          1 => '127.0.0.1',
          2 => 'localhost',
          3 => 'cloud.example.com',
  ),
  'datadirectory' => '/var/www/nextcloud-28.0.0/data',
  'dbtype' => 'mysql',
  'version' => '29.0.0.19',
  'overwrite.cli.url' => 'https://192.168.124.41',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'admin',
  'dbpassword' => '123456',
  'updater.release.channel' => 'git',
  'installed' => true,
);

至此localhost 跟127.0.0.1可以访问了但是域名不行

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1686402.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

靶机hackNos Os-Bytesec练习报告

hackNos: Os-Bytesec靶机练习实践报告 下载地址*&#x1f617; https://drive.google.com/open?id1yBuih2CsBx45oTUDpFr4JldrzkaOTTeZ https://download.vulnhub.com/hacknos/Os-ByteSec.ova https://download.vulnhub.com/hacknos/Os-ByteSec.ova.torrent ( Magnet) …

# 分布式链路追踪_skywalking_学习(1)

分布式链路追踪_skywalking_学习&#xff08;1&#xff09; 一、APM 系统概述 1、什么是 APM 系统&#xff1f; APM &#xff1a;全称 Application Performance Management 即应用性能管理系统。是对企业系统即时监控以实现对应用程序性能管理和故障管理的系统化的解决方案。…

基于Django的美团药品数据分析与可视化系统,有多用户功能,可增删改查数据

背景 随着电子商务和健康产业的迅速发展&#xff0c;药品行业数据的分析和可视化变得愈发重要。基于Django的美团药品数据分析与可视化系统的研究背景凸显了对药品数据的深入挖掘和分析的需求。该系统不仅具备多用户功能&#xff0c;允许不同角色的用户进行数据管理和分析&…

【3DMAX教程插件】3DMAX泰森破碎插件使用方法

3DMAX泰森破碎插件&#xff0c;一键破碎物体&#xff0c;在保留体积的同时破碎网格对象。 【适用版本】 3dMax2009及更高版本 【安装方法】 3DMAX泰森破碎插件无需安装&#xff0c;使用时直接拖动插件脚本文件到3dMax视口中打开即可&#xff01; 【主要功能】 v1.0&#…

气膜建筑的工作原理与优势解析—轻空间

近年来&#xff0c;气膜建筑凭借其独特的结构设计和诸多优点&#xff0c;迅速成为建筑领域的热门选择。本文将详细介绍气膜建筑的工作原理、机械系统、智能控制、索网控制和空气净化等方面&#xff0c;为您提供全面了解气膜建筑的基础知识。 气膜建筑的工作原理 气膜建筑是一种…

翻译《The Old New Thing》- Which windows appear in the Alt+Tab list?

Which windows appear in the AltTab list? - The Old New Thing (microsoft.com)https://devblogs.microsoft.com/oldnewthing/20071008-00/?p24863 Raymond Chen 2007年10月08日 有读者Phil Quirk询问&#xff0c;AltTab切换列表中显示哪些窗口的规则是什么。 规则其实相当…

WT2003HX-16S新能源电动汽车低速报警器方案

一&#xff1a;低速报警器应用场景&#xff1a; 为在工业化发展中对外实现弯道超车&#xff0c;其中新能源汽车行业就为国家战略布局方向之一&#xff0c;前景比较广阔。随之配套的各类警报系统方案也蓬勃发展&#xff0c;其中低速报警器&#xff08;AVAS&#xff09;作为关键安…

数字孪生时代来临,实景三维千亿级别市场爆发在即

想象一下&#xff0c;当我们将整座城市搬到虚拟世界&#xff0c;点点鼠标就能实时掌握城市运行情况&#xff0c;可以实现数字空间与现实空间的实时互联互通、在线治理&#xff0c;是不是听起来像科幻电影一样不可思议&#xff1f; 现在&#xff0c;通过运用遥感测绘、大数据、云…

前端项目使用docker编译发版和gitlab-cicd发版方式

项目目录 app/ ├── container/ │ ├── init.sh │ ├── nginx.conf.template ├── src/ ├── .gitlab-ci.yml └── deploy.sh └── Dockerfile └── Makefilecontainer目录是放nginx的配置文件&#xff0c;给nginx镜像使用 .gitlab-ci.yml和Makefile是c…

JetLinks物联网平台初步使用——TCP接入

基于上一篇&#xff0c;完整的搭建了前后端整个系统&#xff0c;可以在windows 7完美的运行使用。 目录 1、创建网络组件 2、创建协议管理 3、创建网关 ​4、创建产品 ​5、创建设备 6、模拟对接 1、创建网络组件 进入平台后&#xff08;用户名密码都是admin&#xff…

【代码随想录】【算法训练营】【第17天】 [110]平衡二叉树 [257]二叉树的所有路径 [404]左叶子之和

前言 思路及算法思维&#xff0c;指路 代码随想录。 题目来自 LeetCode。 day 17&#xff0c;又是一个令人愉快的周五~ 题目详情 [110] 平衡二叉树 题目描述 110 平衡二叉树 解题思路 前提&#xff1a;平衡二叉树&#xff1a;左右子树高度差不超过1, 思路&#xff1a;…

高性能推理框架漫谈

传统模型分布式推理框架 Tensorflow servingPytorch ServingTriton Server 大语言模型的推理框架 其中&#xff0c; VLLM 后端接入了Ray 框架&#xff0c; 作为调度请求的分发处理&#xff1b;除此之外&#xff0c;还包括Nvidia 最新推出的TensorRT-LLM&#xff0c; 增加了对…

开放式耳机怎么选择!教你几招!2024开放式蓝牙耳机推荐

在面对市场上琳琅满目的开放式耳机时&#xff0c;许多用户可能会感到难以抉择。作为一名开放式耳机的爱好者&#xff0c;我根据自己的实际使用体验&#xff0c;整理了一些我认为值得推荐的开放式耳机&#xff0c;希望能为正在寻找合适耳机的朋友们提供一些参考和帮助。我将为大…

【真实项目中收获的提升】- 前后端联调

场景 小型项目前后端联调&#xff0c;不需要部署到sit或uat环境下。 解决方法 后端部署frp服务 下载frp软件 配置frpc.ini文件&#xff0c;先把文件设置可编辑(可同时配置多个 例如下面的chz 上面打码的是frp服务器地址) 然后起start.bat 其实就是执行frpc -c frpc.ini命令…

前端 CSS 经典:元素倒影

前言&#xff1a;好看的元素倒影&#xff0c;可以通过-webkit-box-reflect 实现。但有兼容问题&#xff0c;必须是 webkit 内核的浏览器&#xff0c;不然没效果。但是好看啊。 效果图&#xff1a; 代码实现&#xff1a; <!DOCTYPE html> <html lang"en"&g…

使用第三方的PyCharm开发工具

目录 PyCharm下载 PyCharm安装 运行PyCharm 创建工程目录 编写“hello world”程序 在同一个工程下创建多个程序文件 运行程序的多种方法 保存程序 关闭程序或工程 删除程序 打开最近的工程 调试断点 熟悉PyCharm开发环境 设置Python解析器 输出彩色控制台文字及…

【C语言】实现贪吃蛇--项目实践(超详细)

前言&#xff1a; 贪吃蛇游戏大家都玩过吧&#xff1f;这次我们要用C语言来亲手制作一个&#xff01;这个项目不仅能让我们复习C语言的知识&#xff0c;还能了解游戏是怎么一步步做出来的。我们会一起完成蛇的移动、食物的生成&#xff0c;还有碰撞检测等有趣的部分。准备好了…

代码随想录——找树左下角的值(Leetcode513)

题目链接 层序遍历 思路&#xff1a;使用层序遍历&#xff0c;记录每一行 i 0 的元素&#xff0c;就可以找到树左下角的值 /*** Definition for a binary tree node.* public class TreeNode {* int val;* TreeNode left;* TreeNode right;* TreeNode() {}*…

el-table 组件实现 “合并单元格 + N行数据小计” 功能

目录 需求 - 要实现的效果初始代码代码升级&#xff08;可供多个表格使用&#xff09;CommonTable.vue 子组件 使用子组件1 - 父组件 - 图1~图3使用效果展示 使用子组件2 - 父组件 - 图4使用效果展示 注意【代码优化 - 解决bug】 需求 - 要实现的效果 父组件中 info 数据示例 …

【vue部署】Apache部署vue项目

Apache部署vue项目 Apache 下载安装(windows)1. 下载2. 安装3. 启动服务 vue 部署配置1. 基础配置2. 解决页面刷新问题 Apache 下载安装(windows) 1. 下载 Apache 2.4.59 下载地址&#xff1a;httpd-2.4.59-240404-win64-VS17.zip Visual C Redistributable for Visual Studi…