其他分享
首页 > 其他分享> > 搭建自己的网盘Nextcloud

搭建自己的网盘Nextcloud

作者:互联网

报错:
PHP module dom not installed. 
 
Please ask your server administrator to install the module. 
 
PHP module XMLWriter not installed. 
 
Please ask your server administrator to install the module. 
 
PHP module XMLReader not installed. 
 
Please ask your server administrator to install the module. 
 
PHP module mb multibyte not installed. 
 
Please ask your server administrator to install the module. 
 
PHP module GD not installed. 
 
Please ask your server administrator to install the module. 
 
PHP modules have been installed, but they are still listed as missing? 
 
Please ask your server administrator to restart the web server.
解决
#PHP module mb multibyte
yum -y install php72w-mbstring

#PHP module dom
yum -y install php72w-dom

#PHP module XMLWriter
yum -y install php72w-xmlwriter

#PHP module GD
yum -y install php72w-gd

#PHP module XMLReader
yum -y install php72w-xmlreader


#查看已安装的php扩展
php-m

centos7搭建Nextcloud

systemctl stop firewalld
systemctl disable firewalld
vim /etc/selinux/config
selinux修改disabled
SELINUX=disabled

临时关闭:
setenforce 0

安装nginx

[root@hl-web lnmp-wordpress]# rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm

[root@hl-web ~]# yum search nginx
[root@hl-web ~]#  yum install -y pcre-devel openssl-devel #安装nginx依赖包
[root@hl-web ~]# yum install -y nginx

安装php

[root@hl-web ~]# systemctl start nginx
[root@hl-web ~]# systemctl enable nginx

安装Mysql

生成SSL证书

此步骤不一定必须,但是为了后面配置文件一致,所以一并配置。

证书的申请可以去网上腾讯云或者其它的平台申请免费的证书,此处使用openssl生成自定义证书。

推荐大家去腾讯云生成一个免费的证书,每次有效期是一年的时候。

#创建文件证书的目录
mkdir -p /etc/nginx/cert/
# 生成证书
openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key
#修改权限 
chmod 700 /etc/nginx/cert
chmod 600 /etc/nginx/cert/* 

安装和配置nextcloud

#安装解压缩软件
yum install unzip 

#下载,此处链接可以直接打开,选择最新版本14.0.3
wget --no-check-certificate https://download.nextcloud.com/server/releases/nextcloud-14.0.3.zip


#解压
unzip nextcloud-14.0.3.zip

#移动到nginx的root目录
mv nextcloud/ /usr/share/nginx/html/

#创建一个存放文件的Data目录
cd /usr/share/nginx/html/
mkdir -p nextcloud/data/

#变更 nextcloud 目录的拥有者为 nginx 用户和组
chown nginx:nginx -R nextcloud/

此处的nginx用户可以根据实际的需要,只有设置了用户组才能够进行安装,否则无法出现安装的页面。
能够出现下面的安装配置页面,那么基本上也就成功了。
接着我们来配置nginx,先创建配置文件。
cd /etc/nginx/conf.d/
vi nextcloud.conf 

在这里一定注意几个地方,比如server的监听方式,要与php-fpm中的配置保持一致。至于域名可以使用自己的内部域名。

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

server {
    listen 80;
    server_name 192.168.0.124;
 # enforce https
 return 301 https://$server_name$request_uri;
}

server {
    listen 443 ssl;
    server_name 192.168.0.124;

    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;";
    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;

 # 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;

    # Disable gzip to avoid the removal of the ETag header
    gzip off;

    # Uncomment if your server is build with the ngx_pagespeed module
    # This module is currently not supported.
    #pagespeed 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 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)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "public, max-age=7200";
        # 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;";
        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;
 # Optional: Don't log access to other assets
        access_log off;
    }
} 

#检测配置成功之后,可以启动服务
systemctl restart nginx 
systemctl restart php-fpm 

最后我们输入http://域名,或者IP来打开安装界面完成配置安装 ,使用之前配置的域名打开,出现安装界面。

  1. 设置管理员账号
  2. 选择文件存放目录
  3. 配置选择数据库

点击完成安装,稍等几分钟之后便跳转到首页。

标签:网盘,server,php72w,nginx,install,Nextcloud,php,root,搭建
来源: https://blog.csdn.net/s_frozen/article/details/121053240