基于LNMP架构部署NextCloud私有云盘
一、NextCloud 概述
云盘这个词无论是做技术出身的朋友还是普通的网民、想必已经听的非常多了、在日常生活当中我们用的最多的云盘莫过于百度网盘了
在前几年百花齐放的网盘市场、到现如今只剩下了百度网盘、说起百度网盘大家并不陌生、特别是它限速的特征、让广大朋友久久不能忘怀啊
不过也没办法、任何企业都是以盈利为目的、你既然享受了线上存储给你带来的便利、那你就得交钱、不交钱就给你限速、限到你哭晕在厕所
另一方面大家需要知道、做存储也是非常烧钱的、譬如给用户提供数据存储的磁盘开销、以及给用户提供数据上传与下载的带宽开销、而且这些钱烧的可不是一点点、所以大家也得谅解
有限速?不安全?要会员? 基于以上这几点大家可能会想到部署个人存储、部署个人存储的程序大家可能又会想到 Seafile、dropbox、OwnCloud、Syncbox 等软件、这其中有些是开源的、有些是收费的
而今天写的这篇文章是基于 NextCloud 这个开源程序的、那NextCloud又是啥呢?
NextCloud 是原 OwnCloud 团队所打造的、号称是下一代存储、在没用过之前心里会想到这么厉害?? 用过之后也算是实至名归了、如果要部署个人云存储、那么使用 NextCloud 绝对是一个非常好的选择
开源这个特点咱们就抛开不说了、NextCloud 使用PHP与JavaScript 所编写、支持多种数据库类型、包括:MySQL、Oracle、Mariadb、SQLite、PostgreSQL 等主流的数据库
与此同时 NextCloud 也为 Linux、Windows、Android、ios、Mac 等各种主流平台提供了相应的客户端、从而实现了跨平台的设备数据共享与同步
不仅如此 NextCloud 还提供了许多应用软件与插件的安装、包括 office文档、日历、邮件、思维导图、在线编辑、文件管理、等丰富的附加功能、所以要是自己部署私有云存储、或者团队数据共享、那 NextCloud 可以称得上是首选
说了那么多、下面进入正题、本文基于(centos-7.5+nginx-1.16.1+mysql-5.6.45+php-7.3.13+redis-3.2.13)来部署NextCloud
所采用的安装方式均为源码(tar.gz 格式)、因为使用源码部署在后面需要安装某些软件的扩展时非常方便
注意:这里的PHP版本需要5.X以上的、否则部署完成以后、在浏览访问会提示版本过低
二、部署 NextCloud
1)准备工作
1、关闭相应的安全软件、否则放行相应的流量
[root@nextcloud ~]# setenforce 0 [root@nextcloud ~]# systemctl stop firewalld
2、提前安装所有的依赖包
[root@nextcloud ~]# yum clean all && yum makecache [root@nextcloud ~]# yum -y install libss-devel libstdc++-devel dbus-devel libaio-devel \ bison-devel libverto-devel curl curl-devel openssl openssl-devel bzip2 bzip2-devel \ icu libicu-devel gmp gmp-devel readline readline-devel pcre pcre-devel zlib zlib-devel gcc gcc-c++ ncurses-devel \ libaio-devel freetype freetype-devel ImageMagick ImageMagick-devel autoconf m4 libgcc e2fsprogs perl-Data-Dumper \ libcurl libcurl-devel libxml2 libxml2-devel gd gd-devel libjpeg libjpeg-devel libpng libpng-devel libxslt libxslt-devel
3、为MySQL与Nginx创建专门的运行用户
[root@nextcloud ~]# groupadd mysql [root@nextcloud ~]# useradd -M -s /sbin/nologin nginx [root@nextcloud ~]# useradd -M -s /sbin/nologin mysql -g mysql
2)部署Nginx
1、下载并安装Nginx
[root@nextcloud ~]# wget -c http://www.nginx.org/download/nginx-1.16.1.tar.gz [root@nextcloud ~]# tar xf nginx-1.16.1.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/nginx-1.16.1/ [root@nextcloud nginx-1.16.1]# ./configure --prefix=/etc/nginx --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module && make -j 8 && make install -j 8 && cd ~
2、添加Nginx至环境变量、并将其添加为系统服务
[root@nextcloud ~]# echo 'export PATH=/etc/nginx/sbin:$PATH' >> /etc/profile [root@nextcloud ~]# source /etc/profile && nginx [root@nextcloud ~]# cat > /usr/lib/systemd/system/nginx.service << EOF [Unit] Description=nginx After=network.target [Service] Type=forking PIDFile=/etc/nginx/logs/nginx.pid ExecStart=/etc/nginx/sbin/nginx ExecReload=killall -s HUP $(cat /etc/nginx/logs/nginx.pid) ExecStop=killall -s QUIT $(cat /etc/nginx/logs/nginx.pid) PrivateTmp=Flase [Install] WantedBy=multi-user.target EOF [root@nextcloud ~]# systemctl daemon-reload && pkill -9 nginx [root@nextcloud ~]# systemctl restart nginx && systemctl enable nginx Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
3)部署MySQL
1、安装MySQL之前、我们先安装cmake工具
[root@nextcloud ~]# wget -c https://cmake.org/files/v2.8/cmake-2.8.12.tar.gz [root@nextcloud ~]# tar xf cmake-2.8.12.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/cmake-2.8.12/ [root@nextcloud cmake-2.8.12]# ./configure && gmake -j 8 && gmake install && cd
2、下载并安装MySQL
[root@nextcloud ~]# wget -c https://downloads.mysql.com/archives/get/file/mysql-5.6.45.tar.gz [root@nextcloud ~]# tar xf mysql-5.6.45.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/mysql-5.6.45/ [root@nextcloud mysql-5.6.45]# cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DSYSCONFDIR=/etc \ -DMYSQL_DATADIR=/usr/local/mysql/data \ -DENABLED_LOCAL_INFILE=ON \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all \ -DWITH_DEBUG=0 \ -DMYSQL_UNIX_ADDR=/usr/local/mysql/tmp/mysql.sock make -j 8 && make install -j 8 && cd ~
3、将MySQL添加至环境变量、并创建对应的存储目录、授予对应的权限
[root@nextcloud ~]# mkdir /usr/local/mysql/tmp [root@nextcloud ~]# mkdir /usr/local/mysql/log [root@nextcloud ~]# mkdir /usr/local/mysql/pid [root@nextcloud ~]# mkdir /usr/local/mysql/binlog [root@nextcloud ~]# mkdir /usr/local/mysql/relaylog [root@nextcloud ~]# mkdir /usr/local/mysql/tmpdata [root@nextcloud ~]# chown -R mysql:mysql /usr/local/mysql [root@nextcloud ~]# echo 'export PATH=/usr/local/mysql/bin:$PATH' >> /etc/profile [root@nextcloud ~]# source /etc/profile [root@nextcloud ~]# mv /etc/my.cnf /etc/my.cnf.bak [root@nextcloud ~]# cd /usr/src/mysql-5.6.45 && cp support-files/my-default.cnf /etc/my.cnf
4、优化MySQL配置文件以提升性能
[root@nextcloud mysql-5.6.45]# cat > /etc/my.cnf << EOF [client] port = 3306 socket = /usr/local/mysql/tmp/mysql.sock [mysqld] user = mysql port = 3306 bind_address = 0.0.0.0 max_connections = 3600 max_connect_errors = 200 autocommit = ON skip-name-resolve symbolic-links = 0 skip-external-locking explicit_defaults_for_timestamp = ON basedir = /usr/local/mysql datadir = /usr/local/mysql/data socket = /usr/local/mysql/tmp/mysql.sock innodb_tmpdir = /usr/local/mysql/tmpdata pid-file = /usr/local/mysql/pid/mysql.pid log-error = /usr/local/mysql/log/mysql_error.log character-set-server = utf8 init_connect = SET NAMES utf8 collation-server = utf8_general_ci slow_query_log = ON long_query_time = 1 relay_log_recovery = 1 log_slow_admin_statements = 1 log_slow_slave_statements = 1 min_examined_row_limit = 960 log_queries_not_using_indexes = OFF slow_query_log_file = /usr/local/mysql/log/mysql_slow.log server-id = 11 sync_binlog = 0 expire_logs_days = 9 max_binlog_size = 512M max_binlog_cache_size = 8M transaction_isolation = repeatable-read back_log = 300 max_allowed_packet = 64M sort_buffer_size = 1M join_buffer_size = 1M read_buffer_size = 2M read_rnd_buffer_size = 2M thread_cache_size = 64 thread_stack = 256K query_cache_size = 32M query_cache_limit = 2M query_cache_min_res_unit = 2k tmp_table_size = 64M max_heap_table_size = 64M table_open_cache = 4096 open_files_limit = 65535 table_open_cache_instances = 8 connect_timeout = 9 interactive_timeout = 21600 wait_timeout = 21600 default-storage-engine = InnoDB innodb_buffer_pool_size = 2G innodb_log_file_size = 128M innodb_log_files_in_group = 3 innodb_log_buffer_size = 16M innodb_flush_log_at_trx_commit = 2 innodb_file_per_table = 1 innodb_read_io_threads = 8 innodb_write_io_threads = 8 innodb_flush_method = O_DIRECT innodb_thread_concurrency = 16 innodb_large_prefix = ON innodb_file_format = barracuda EOF
5、对MySQL进行初始化
[root@nextcloud mysql-5.6.45]# BASEDIR="/usr/local/mysql" [root@nextcloud mysql-5.6.45]# DATADIR="/usr/local/mysql/data" [root@nextcloud mysql-5.6.45]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=$BASEDIR --datadir=$DATADIR
6、将MySQL添加为系统服务
[root@nextcloud mysql-5.6.45]# cp support-files/mysql.server /usr/local/mysql/bin/mysql.sh [root@nextcloud mysql-5.6.45]# chmod +x /usr/local/mysql/bin/mysql.sh && cd ~ [root@nextcloud ~]# cat > /usr/lib/systemd/system/mysql.service << EOF [Unit] Description=MySQL After=network.target [Service] User=mysql Group=mysql LimitNOFILE=65535 Type=forking ExecStart=/usr/local/mysql/bin/mysql.sh start ExecStop=/usr/local/mysql/bin/mysql.sh stop [Install] WantedBy=multi-user.target EOF
7、启动MySQL服务
[root@nextcloud ~]# systemctl start mysql [root@nextcloud ~]# netstat -anput | grep mysql tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 32584/mysqld [root@nextcloud ~]# systemctl enable mysql Created symlink from /etc/systemd/system/multi-user.target.wants/mysql.service to /usr/lib/systemd/system/mysql.service.
4)安装libzip库
[root@nextcloud ~]# wget -c https://nih.at/libzip/libzip-1.2.0.tar.gz [root@nextcloud ~]# tar xf libzip-1.2.0.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/libzip-1.2.0/ [root@nextcloud libzip-1.2.0]# ./configure && make -j 8 && make install -j 8 && cd ~ [root@nextcloud ~]# cp /usr/local/lib/libzip/include/zipconf.h /usr/local/include/zipconf.h [root@nextcloud ~]# cat > /etc/ld.so.conf.d/local.conf << EOF /usr/local/lib64 /usr/local/lib /usr/lib /usr/lib64 EOF ldconfig -v
5)部署PHP
1、下载并安装PHP
[root@nextcloud ~]# wget -c https://www.php.net/distributions/php-7.3.13.tar.gz [root@nextcloud ~]# tar xf php-7.3.13.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/php-7.3.13/ [root@nextcloud php-7.3.13]# ./configure --prefix=/usr/local/php7 --with-config-file-path=/usr/local/php7 --enable-mbstring --enable-fpm \ --with-gd --with-zlib --enable-inline-optimization --with-jpeg-dir=/usr/lib --disable-debug --disable-rpath \ --enable-shared --with-libxml-dir --with-xmlrpc --enable-soap --with-openssl --enable-exif --enable-fileinfo \ --enable-filter --with-pcre-dir --enable-ftp --with-openssl-dir --with-jpeg-dir --with-png-dir --with-zlib-dir \ --with-freetype-dir --enable-gd-jis-conv --with-gettext --with-gmp --enable-json --enable-mbregex --enable-mbregex-backtrack \ --with-onig --enable-pdo --with-mysqli=mysqlnd --with-pdo-mysql=mysqlnd --with-zlib-dir --with-pdo-sqlite --enable-session --enable-shmop \ --enable-simplexml --enable-sockets --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --with-libxml-dir --with-xsl --enable-zip \ --enable-mysqlnd-compression-support --with-pear --enable-opcache --with-mhash --with-pcre-regex --with-sqlite3 --enable-bcmath --with-iconv --with-bz2 \ --enable-calendar --with-curl --with-cdb --enable-dom --without-pear --disable-phar && make -j 8 && make install -j 8
2、复制参考文件、并为PHP创建软连接
[root@nextcloud php-7.3.13]# cp php.ini-production /usr/local/php7/php.ini [root@nextcloud php-7.3.13]# ln -s /usr/local/php7/bin/* /usr/local/bin/ [root@nextcloud php-7.3.13]# ln -s /usr/local/php7/sbin/* /usr/local/sbin/ && cd ~
6)部署redis
1、下载并安装redis
[root@nextcloud ~]# wget -c http://download.redis.io/releases/redis-3.2.13.tar.gz [root@nextcloud ~]# tar xf redis-3.2.13.tar.gz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/redis-3.2.13/ [root@nextcloud redis-3.2.13]# make -j 8 && make PREFIX=/usr/local/redis install && cd ~
2、创建对应的存储目录、并做好软连接
[root@nextcloud ~]# mkdir /usr/local/redis/conf [root@nextcloud ~]# mkdir /usr/local/redis/pid [root@nextcloud ~]# mkdir /usr/local/redis/log [root@nextcloud ~]# mkdir /usr/local/redis/tmp [root@nextcloud ~]# mkdir /usr/local/redis/data [root@nextcloud ~]# cp /usr/src/redis-3.2.13/redis.conf /usr/local/redis/conf/ [root@nextcloud ~]# cp /usr/local/redis/conf/redis.conf /usr/local/redis/conf/redis.conf.bak [root@nextcloud ~]# ln -s /usr/local/redis/bin/* /usr/local/bin/
3、定义redis配置文件以优化性能
[root@nextcloud ~]# cat > /usr/local/redis/conf/redis.conf << EOF bind 0.0.0.0 port 6379 timeout 180 daemonize yes maxclients 6500 protected-mode yes requirepass abc-123 tcp-backlog 2048 tcp-keepalive 300 databases 16 supervised no syslog-enabled yes syslog-ident redis syslog-facility local0 loglevel notice logfile "/usr/local/redis/log/redis.log" pidfile "/usr/local/redis/pid/redis.pid" unixsocketperm 755 unixsocket "/usr/local/redis/tmp/redis.sock" slowlog-log-slower-than 5000 slowlog-max-len 128 dir "/usr/local/redis/data" save 900 1 save 300 10 save 60 10000 rdbcompression yes rdbchecksum no dbfilename dump.rdb stop-writes-on-bgsave-error no appendonly yes appendfsync everysec aof-load-truncated yes appendfilename appendonly.aof no-appendfsync-on-rewrite no auto-aof-rewrite-percentage 100 auto-aof-rewrite-min-size 64mb aof-rewrite-incremental-fsync yes repl-diskless-sync no repl-diskless-sync-delay 5 repl-disable-tcp-nodelay no repl-backlog-size 1mb repl-backlog-ttl 3600 slave-priority 100 hz 10 maxmemory-policy noeviction activerehashing yes hash-max-ziplist-value 64 hash-max-ziplist-entries 512 list-compress-depth 0 lua-time-limit 5000 notify-keyspace-events "" list-max-ziplist-size -2 latency-monitor-threshold 0 set-max-intset-entries 512 zset-max-ziplist-entries 128 zset-max-ziplist-value 64 hll-sparse-max-bytes 3000 client-output-buffer-limit normal 0 0 0 client-output-buffer-limit pubsub 32mb 8mb 60 client-output-buffer-limit slave 256mb 64mb 60 EOF
4、将redis添加为系统服务、最后启动redis服务即可
[root@nextcloud ~]# cat > /usr/lib/systemd/system/redis.service << EOF [Unit] Description=redis After=network.target [Service] Type=forking LimitNOFILE=10240 ExecStart=/usr/local/bin/redis-server /usr/local/redis/conf/redis.conf [Install] WantedBy=multi-user.target EOF systemctl enable redis systemctl start redis
7)安装intl模块、因为部署OwnCloud要用到、这里部署的是NextCloud 所以这个也可以不安装
[root@nextcloud ~]# cd /usr/src/php-7.3.13/ext/intl/ [root@nextcloud intl]# /usr/local/php7/bin/phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 [root@nextcloud intl]# ./configure --with-php-config=/usr/local/php7/bin/php-config && make -j 8 && make install -j 8 [root@nextcloud intl]# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/intl.so /usr/local/php7/include/php/ext/ [root@nextcloud intl]# sed -i '3i extension=intl.so' /usr/local/php7/php.ini && cd
8)安装imagick模块、用于图像处理
[root@nextcloud ~]# wget -c https://pecl.php.net/get/imagick-3.4.4.tgz [root@nextcloud ~]# tar xf imagick-3.4.4.tgz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/imagick-3.4.4/ [root@nextcloud imagick-3.4.4]# /usr/local/php7/bin/phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 [root@nextcloud imagick-3.4.4]# ./configure --with-php-config=/usr/local/php7/bin/php-config && make -j 8 && make install -j 8 [root@nextcloud imagick-3.4.4]# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/imagick.so /usr/local/php7/include/php/ext/ [root@nextcloud imagick-3.4.4]# sed -i '4i extension=imagick.so' /usr/local/php7/php.ini && cd
9)安装opcache模块、用于提升性能
[root@nextcloud ~]# cd /usr/src/php-7.3.13/ext/opcache/ [root@nextcloud opcache]# /usr/local/php7/bin/phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 [root@nextcloud opcache]# ./configure --with-php-config=/usr/local/php7/bin/php-config && make -j 8 && make install -j 8 && cd ~ [root@nextcloud ~]# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/opcache.so /usr/local/php7/include/php/ext/
10)安装redis模块、用于缓存数据、提升性能
[root@nextcloud ~]# wget -c http://pecl.php.net/get/redis-3.1.6.tgz [root@nextcloud ~]# tar xf redis-3.1.6.tgz -C /usr/src/ [root@nextcloud ~]# cd /usr/src/redis-3.1.6/ [root@nextcloud redis-3.1.6]# /usr/local/php7/bin/phpize Configuring for: PHP Api Version: 20180731 Zend Module Api No: 20180731 Zend Extension Api No: 320180731 [root@nextcloud redis-3.1.6]# ./configure --with-php-config=/usr/local/php7/bin/php-config && make -j 8 && make install -j 8 && cd ~ [root@nextcloud ~]# cp /usr/local/php7/lib/php/extensions/no-debug-non-zts-20180731/redis.so /usr/local/php7/include/php/ext/ [root@nextcloud ~]# sed -i '5i extension=redis.so' /usr/local/php7/php.ini
11)编辑PHP配置文件、优化相应的参数以提升性能
注意:这里面的配置项、在PHP的配置文件当中几乎都有了、但都是注释的、只需将其打开并调整相应参数即可、最后的那个 zend_extension 需要添加在 [opcache] 下
[root@nextcloud ~]# cp /usr/local/php7/php.ini /usr/local/php7/php.ini.bak [root@nextcloud ~]# vim /usr/local/php7/php.ini memory_limit = 1024M max_execution_time = 0 post_max_size = 10800M upload_max_filesize = 10240M opcache.enable=1 opcache.enable_cli=1 opcache.fast_shutdown = 1 opcache.save_comments = 1 opcache.revalidate_freq = 5 opcache.validate_timestamps = 0 opcache.memory_consumption = 512 opcache.interned_strings_buffer = 8 opcache.max_accelerated_files = 10000 zend_extension = /usr/local/php7/include/php/ext/opcache.so
12)复制模板文件、并将PID的路径改为绝对路径
[root@nextcloud ~]# cp /usr/local/php7/etc/php-fpm.conf.default /usr/local/php7/etc/php-fpm.conf [root@nextcloud ~]# cp /usr/local/php7/etc/php-fpm.d/www.conf.default /usr/local/php7/etc/php-fpm.d/www.conf [root@nextcloud ~]# sed -i 's#;pid = run/php-fpm.pid#pid = /usr/local/php7/var/run/php-fpm.pid#' /usr/local/php7/etc/php-fpm.conf
13)更改属主与属组、并开启动态模式、调整动态参数、最后需要打开环境变量、打开变量、不然在NextCloud检测中、会提示找不到路径
[root@nextcloud ~]# cp /usr/local/php7/etc/php-fpm.d/www.conf /usr/local/php7/etc/php-fpm.d/www.conf.bak [root@nextcloud ~]# vim /usr/local/php7/etc/php-fpm.d/www.conf user = nginx group = nginx pm = dynamic pm.max_children = 130 pm.start_servers = 15 pm.min_spare_servers = 6 pm.max_spare_servers = 35 env[HOSTNAME] = $HOSTNAME env[PATH] = /usr/local/bin:/usr/bin:/bin env[TMP] = /tmp env[TMPDIR] = /tmp env[TEMP] = /tmp
14)启动 php-fpm 服务的时候、大家先使用 -t 选项 检查一下、然后即可启动 php-fpm 服务、如果有错误、那就根据提示进行排查、最后使用 -m 选项 查看自己安装了那些模块
[root@nextcloud ~]# /usr/local/sbin/php-fpm -t #检查 [20-Dec-2019 15:14:12] NOTICE: configuration file /usr/local/php7/etc/php-fpm.conf test is successful [root@nextcloud ~]# echo $? 0 [root@nextcloud ~]# /usr/local/sbin/php-fpm #以上检查成果之后就使用此命令启动 php-fpm 服务 [root@nextcloud ~]# /usr/local/sbin/php-fpm -m #使用 -m 选项、查看自己安装了那些模块 bcmath bz2 calendar cgi-fcgi Core ctype curl date dba dom exif fileinfo filter ftp gd gettext gmp hash iconv imagick intl json libxml mbstring mysqli mysqlnd openssl pcre PDO pdo_mysql pdo_sqlite posix redis Reflection session shmop SimpleXML soap sockets SPL sqlite3 standard sysvmsg sysvsem sysvshm tokenizer wddx xml xmlreader xmlrpc xmlwriter xsl zip zlib
15)下载 NextCloud 软件包、并解压至 Nginx 相关目录、最后授予相应的权限
[root@nextcloud ~]# wget -c https://download.nextcloud.com/server/releases/nextcloud-17.0.2.zip [root@nextcloud ~]# unzip nextcloud-17.0.2.zip > /dev/null [root@nextcloud ~]# mv nextcloud /etc/nginx/html/cloud [root@nextcloud ~]# chown -R nginx:nginx /etc/nginx/html/cloud
16)定义 Nginx 配置文件、将访问目录指向 NextCloud 刚刚解压的目录
[root@nextcloud ~]# cp /etc/nginx/conf/nginx.conf /etc/nginx/conf/nginx.conf.bak [root@nextcloud ~]# vim /etc/nginx/conf/nginx.conf user nginx; worker_processes 8; worker_rlimit_nofile 65535; worker_cpu_affinity 00000001 00000010 00000100 00001000 00010000 00100000 01000000 10000000; pid /etc/nginx/logs/nginx.pid; #自定义 error_log /etc/nginx/logserror.log info; #自定义 events { use epoll; worker_connections 65535; } http { include mime.types; default_type application/octet-stream; log_format mds '$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 mds; sendfile on; tcp_nopush on; tcp_nodelay on; send_timeout 10; keepalive_timeout 60; server_tokens off; client_max_body_size 512m; fastcgi_buffers 64 4K; client_header_buffer_size 15k; large_client_header_buffers 4 128k; open_file_cache_valid 30s; open_file_cache_min_uses 2; open_file_cache max=65535 inactive=20s; gzip on; gzip_min_length 3k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 1; gzip_vary on; gzip_types text/plain application/x-javascript text/css application/xml; server { listen 80; #自定义 server_name www.mds.com; #自定义 charset utf-8; root /etc/nginx/html/cloud; #自定义 add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "none" always; add_header X-XSS-Protection "1; mode=block" always; fastcgi_hide_header X-Powered-By; location ~ ^\/(?:index|remote|public|cron|core\/ajax\/update|status|ocs\/v[12]|updater\/.+|oc[ms]-provider\/.+)\.php(?:$|\/) { 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 modHeadersAvailable true; fastcgi_param front_controller_active true; fastcgi_intercept_errors on; fastcgi_request_buffering off; fastcgi_pass 127.0.0.1:9000; #自定义 } rewrite /.well-known/carddav /remote.php/dav permanent; rewrite /.well-known/caldav /remote.php/dav permanent; location / { rewrite ^ /index.php; } location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap)$ { try_files $uri /index.php$request_uri; access_log off; } location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) { try_files $uri/ =404; index index.php; } location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) { deny all; } location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ { deny all; } location ~ \.(?:css|js|woff2?|svg|gif|map)$ { try_files $uri /index.php$request_uri; add_header Cache-Control "public, max-age=15778463"; add_header Referrer-Policy "no-referrer" always; add_header X-Content-Type-Options "nosniff" always; add_header X-Download-Options "noopen" always; add_header X-Frame-Options "SAMEORIGIN" always; add_header X-Permitted-Cross-Domain-Policies "none" always; add_header X-Robots-Tag "none" always; add_header X-XSS-Protection "1; mode=block" always; access_log off; } } }
17)添加hosts映射、最后重启 Nginx 服务即可
[root@nextcloud ~]# echo "10.2.3.11 www.mds.com" >> /etc/hosts [root@nextcloud ~]# cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 10.2.3.11 www.mds.com [root@nextcloud ~]# nginx -t nginx: the configuration file /etc/nginx/conf/nginx.conf syntax is ok nginx: configuration file /etc/nginx/conf/nginx.conf test is successful [root@nextcloud ~]# [root@nextcloud ~]# systemctl restart nginx [root@nextcloud ~]# [root@nextcloud ~]# netstat -anput | grep nginx tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 106307/nginx: maste [root@nextcloud ~]# [root@nextcloud ~]# systemctl | grep nginx nginx.service loaded active running nginx
18)为 NextCloud 创建数据存储目录、并为其设置权限
[root@nextcloud ~]# mkdir -p /opt/cloud/data [root@nextcloud ~]# chown -R nginx:nginx /opt/cloud/data/
19)创建 NextCloud 所使用的数据库、并为其授权、最后重启MySQL服务即可
[root@nextcloud ~]# mysqladmin -u root password 'abc-123' 2> /dev/null [root@nextcloud ~]# mysql -u root -pabc-123 -e"drop database test;" 2> /dev/null [root@nextcloud ~]# mysql -u root -pabc-123 -e"create database cloud;" 2> /dev/null [root@nextcloud ~]# mysql -u root -pabc-123 -e"grant all privileges on cloud.* to 'cloud'@'10.2.3.%' identified by 'abc-123'" 2> /dev/null [root@nextcloud ~]# systemctl restart mysql
20)确认所有服务都已全部启动
[root@nextcloud ~]# netstat -anput Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 106095/php-fpm: mas tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 107289/mysqld tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 107484/redis-server tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 106307/nginx: maste
三、NextCloud 使用
1、初始化 NextCloud
提示:在浏览器中、输入 www.mds.com 即可出现如下界面、按照提示添加完成以后、点击安装完成即
2、初始化完成以后、即可跳到如下界面
3、上传软件包
4、设置头像、设置邮件、设置语言
5、查看 NextCloud 日志、如果有错误、请按照提示进行解决
6、查看系统负载情况
7、为 NextCloud 添加 redis 缓存、内容需要放在括号内、不要放在括号外、最后重启各个服务即可
[root@nextcloud ~]# cp /etc/nginx/html/cloud/config/config.php /etc/nginx/html/cloud/config/config.php.bak [root@nextcloud ~]# vim /etc/nginx/html/cloud/config/config.php 'memcache.local' => '\OC\Memcache\Redis', 'redis' => array ( 'host' => '10.2.3.11', 'port' => '6379', 'password' => 'abc-123', 'timeout' => 1.5, 'memcache.locking' => '\OC\Memcache\Redis', ), [root@nextcloud ~]# pkill -9 php-fpm [root@nextcloud ~]# /usr/local/sbin/php-fpm [root@nextcloud ~]# systemctl restart nginx mysql redis
8、点击概览、可以看见有两个提示、第一个是要求使用 https 、这里主要解决的是第二个警告
注意:它要求使用 https 因为我这里是虚拟机、不是云服务器、所以这里我就不再赘述、如果是云服务器、那就自己去申请证书即可、而下面的配置主要就是解决第二个警告、只需执行如下命令即可
[root@nextcloud ~]# sudo -u nginx /usr/local/bin/php /etc/nginx/html/cloud/occ db:convert-filecache-bigint The process control (PCNTL) extensions are required in case you want to interrupt long running commands - see http://php.net/manual/en/book.pcntl.php Following columns will be updated: * mounts.storage_id * mounts.root_id * mounts.mount_id This can take up to hours, depending on the number of files in your instance! Continue with the conversion (y/n)? [n] y #回答 y 即可
9、确认所有警告都已解决、如下所示
10、对 NextCloud 配置邮件测试
注意:这一步是配置发件人、而收件人是刚刚在个人信息里面所配置的邮箱
11、查看发送的邮件
12、将 NextCloud 挂载到本地
注意:需要先修改注册表
路径为:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\WebClient\Parameters、里面有个名为 BasicAuthLevel 的项、值本为1、将其修改为 2 即可、接下来去服务里面开启 WebClieent 服务
进入 NextCloud 复制这个 URL 连接
接下来就直接在 Windows 当中映射即可、如下所示
输入用户名和密码、这里登录 NextCloud 的密码
可以看到、映射成功、并且可以正常复制文件、这样就可以像使用本地磁盘一样来使用 NextCloud 了
【只是为了打发时间】
基于LNMP架构部署NextCloud私有云盘的更多相关文章
- 基于LNMP架构部署wordpress
[root@localhost ~]# yum -y install unzip[root@localhost ~]# unzip wordpress-5.2.3.zip[root@localhost ...
- 用lnmp架构部署wordpress网站详细步骤
用lnmp架构部署wordpress网站 ①.下载和上传网站代码 用winscp或者xftp, 或者xshell下执行rz命令进行上传网站的包文件. ②.解压程序代码,并将程序代码保存到站点目录,并进 ...
- 政务私有云盘系统建设的工具 – Mobox私有云盘
序言 这几年,智慧政务已经成为了政府行业IT建设发展的重要进程.传统办公方式信息传递速度慢.共享程度低.查询利用难,早已成为政府机关获取和利用信息的严重制约因素.建立文档分享共用机制,加强数据整合,避 ...
- 搭建LAMP环境部署Nextcloud私人网盘
搭建 LAMP 环境部署 Nextcloud 私人网盘 前言 Nextcloudd 是一个开源的.基于本地的文件共享和协作平台,它允许您保存文件并通过多个设备(如PC.智能手机和平板电脑)访问它们. ...
- LNMP架构部署
第1章 部署LNMP架构步骤 1.1 ①部署Linux系统(OK) 基本优化完成(ip地址设置 yum源更新 字符集设置) 安全优化完成(iptables关闭 selinux关闭 /tmp/ 1777 ...
- 快速部署简单私有云CloudStack(上)
前言: 亲身用了大半年,没出过重大毛病,也就是服务挂了,跟服务器也没啥关系.如果想更深入学习cloudstack可以试试高级网络,我是一直用的简单网络(扁平网络). 由来:CloudStack的前身是 ...
- 《Linux就该这么学》培训笔记_ch20使用LNMP架构部署动态网站环境
<Linux就该这么学>培训笔记_ch20使用LNMP架构部署动态网站环境 文章最后会post上书本的笔记照片. 文章主要内容: 源码包程序 LNMP动态网站架构 配置Mysql服务 配置 ...
- linux运维、架构之路-Lnmp架构部署
一.Lnmp架构原理 二. Lnmp架构软件安装 1.Nginx安装脚本 #!/bin/bash useradd -s /sbin/nologin -M www mkdir -p /server/to ...
- 基于LNMP架构搭建wordpress博客之安装架构说明
架构情况 架构情况:基于LNMP架构搭建wordpress系统 软件包版本说明: 系统要求 : CentOS-6.9-x86_64-bin-DVD1.iso PHP版本 : php-7.2.29 ...
随机推荐
- ArcEngine版本管理(Version)项目总结
需求: 在ArcGIS项目中,大型的数据库都是使用ArcSDE进行连接管理.使用的数据版本(Version)都是默认版本(sde.default).这样多个人员在编辑的过程中就直接编辑的是默认版本数据 ...
- ILSpy反编译工具之C#反汇编
1.下载ILspy工具 https://github.com/icsharpcode/ILSpy#ilspy------- 注意: ILspy需要在电脑上安装.NET Framework 4.0. ...
- kettle连接oracle数据库报错,ORA-12505
报错信息: Error connecting to database: (using class oracle.jdbc.driver.OracleDriver) Listener refused t ...
- 区间dp - 括号匹配并输出方案
Let us define a regular brackets sequence in the following way: 1. Empty sequence is a regular seque ...
- Java架构师中的内存溢出和内存泄露是什么?实际操作案例!
JAVA中的内存溢出和内存泄露分别是什么,有什么联系和区别,让我们来看一看. 01 内存泄漏 & 内存溢出 1.内存泄漏(memory leak ) 申请了内存用完了不释放,比如一共有 102 ...
- 《爬虫学习》(二)(urllib库使用)
urllib库是Python中一个最基本的网络请求库.可以模拟浏览器的行为,向指定的服务器发送一个请求,并可以保存服务器返回的数据. 1.urlopen函数: 在Python3的urllib库中,所有 ...
- python打包成可执行文件
1 最开始我直接把在Windows上打包的run.exe文件上传到Linux以为可以直接用了.但是./run后报错.百度后知道,Windows上的程序不能在Linux上运行 Linux下文件是否可执行 ...
- ubuntu 16.10 shu rufa meiy ou l e geng xi zhi hou
- 第二次团队作业-需求分析(By七个小矮人)
第二次团队作业-需求分析 一.格式描述 这个作业属于哪个课程 https://edu.cnblogs.com/campus/xnsy/GeographicInformationScience/ 这个作 ...
- zbar+opencv检测图片中的二维码或条形码
zbar本身自带检测二维码条形码功能,这里使用opencv只是做一些简单的读取图片,灰度图片以及显示条形码和二维码时用到一些绘制 // barcode-qrcodescanner.cpp: 定义控制台 ...