Nextcloud私人网盘部署安装

环境:

centos版本 CentOS Linux release 7.5.1804 (Core) 
内核版本 3.10.0-862.el7.x86_64
数据库 MySQL5.7
Nextcloud nextcloud-13.0.0
PHP PHP 7

1、安装基本工具关闭防火墙,或者开放端口。都行

[root@tiger ~]# yum -y install epel-release wget unzip gcc

[root@tiger ~]# yum -y install libsmbclient libsmbclient-devel redis

[root@tiger ~]# setenforce 0 

[root@tiger ~]# systemctl stop firewalld

2、安装MySQL,redis

[root@tiger ~]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm

[root@tiger ~]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm

[root@tiger ~]# yum install mysql-server -y

[root@tiger ~]# systemctl start mysqld

这里去mysqld.log拿到密码,修改原始密码

[root@tiger ~]# mysqladmin -uroot -p'91d7g+o*ZivG' password 'YingYingYing!111'

进入数据库授权

mysql> create database nextcloud_db;

mysql> create user nextclouduser@localhost identified by 'YingYingYing!111';

mysql> grant all privileges on nextcloud_db.* to nextclouduser@localhost identified by 'YingYingYing!111';

mysql> flush privileges;

3、安装nginx,redis

[root@tiger ~]# yum -y install nginx

[root@tiger ~]# mkdir /var/www

[root@tiger ~]# chown -R nginx:nginx /var/www

启动nginx
[root@tiger ~]# systemctl start nginx

[root@tiger ~]# yum -y install redis

redis这里有点懵逼,可以先不安装或者安装不修改任何配置,服务一样可以起来

4、安装PHP

[root@tiger ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

[root@tiger ~]# yum -y install php71w-fpm php71w-cli php71w-gd php71w-mcrypt php71w-mysql php71w-pear php71w-xml php71w-mbstring php71w-pdo php71w-json php71w-opcache php71w-pecl-apcu php71w-pecl-apcu-devel php71w-pecl-igbinary php71w-pecl-igbinary-devel php71w-pecl-imagick php71w-pecl-imagick-devel php71w-pecl-redis php71w-pecl-redis-devel

修改配置文件
[root@tiger ~]# vim /etc/php-fpm.d/www.conf
apache改为nginx
user = nginx
group = nginx
注释解开
env[HOSTNAME] = $HOSTNAME
env[PATH] = /usr/local/bin:/usr/bin:/bin
env[TMP] = /tmp
env[TMPDIR] = /tmp
env[TEMP] = /tmp

[root@tiger ~]# mkdir -p /var/lib/php/session 

[root@tiger ~]# chown -R nginx:nginx /var/lib/php/session/

[root@tiger ~]# vim /etc/php.d/opcache.ini

解开注释或者修改
zend_extension=opcache.so
opcache.enable=1
opcache.enable_cli=1
opcache.memory_consumption=128
opcache.interned_strings_buffer=8
opcache.max_accelerated_files=10000
opcache.revalidate_freq=1
opcache.save_comments=1

安装smbclient模板

[root@tiger ~]# yum -y install libsmbclient libsmbclient-devel

[root@tiger ~]# pecl install smbclient

[root@tiger ~]# vim /etc/php.d/smbclient.ini     //添加下面这一行
extension=smbclient.so

启动PHP-fpm服务

[root@tiger ~]# systemctl start php-fpm

五、安装Nextcloud

5.1、下载并解压到www目录
[root@tiger ~]# wget https://download.nextcloud.com/server/releases/nextcloud-13.0.0.zip

[root@tiger ~]# unzip nextcloud-13.0.0.zip 

[root@tiger ~]# mv nextcloud /var/www/

[root@tiger ~]# chown -R nginx:nginx /var/www

5.2、生成SSL证书
[root@tiger ~]# mkdir -p /etc/nginx/cert/

[root@tiger ~]# openssl req -new -x509 -days 365 -nodes -out /etc/nginx/cert/nextcloud.crt -keyout /etc/nginx/cert/nextcloud.key

[root@tiger ~]# chmod 700 /etc/nginx/cert

[root@tiger ~]# chmod 600 /etc/nginx/cert/*

5.3、在Nginx配置
老多了   往下看直接粘上去就行
events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

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

    server {
        listen 80;
        server_name www.suibianxie.com;
        # enforce https
        return 301 https://$server_name$request_uri;
    }

    server {
        listen 443 ssl http2;
        server_name www.suibianxie.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 /var/www/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;
        }
    }

}

[root@tiger ~]# nginx -t   //查看配置是否错误,无错的话  重启nginx,或者直接nginx重新载入配置

[root@tiger ~]# nginx -s reload
或
[root@tiger ~]# systemctl restart nginx




解析过后,访问  www.suibianxie.com 就可以  账号密码自行设置

Nextcloud私人网盘部署安装_第1张图片

你可能感兴趣的:(Nextcloud私人网盘部署安装)