centos6.5下使用lnmp架构安装nextcloud云盘
发表于:2024-10-19 作者:千家信息网编辑
千家信息网最后更新 2024年10月19日,最近两年随着各大网盘纷纷关闭,百度云也早早的就开始限速,文件的安全也没有保障。所以还不如自己搭建一个网盘。网上看了下,发现有一个nextcloud比较好用。支持多平台客户端,支持分享,使用操作简单。支
千家信息网最后更新 2024年10月19日centos6.5下使用lnmp架构安装nextcloud云盘
最近两年随着各大网盘纷纷关闭,百度云也早早的就开始限速,文件的安全也没有保障。所以还不如自己搭建一个网盘。网上看了下,发现有一个nextcloud比较好用。支持多平台客户端,支持分享,使用操作简单。支持插件扩展,文件预览,在线协作。
安装nginx
wget http://nginx.org/download/nginx-1.10.3.tar.gztar -zxf nginx-1.10.3.tar.gz && cd nginx-1.10.3./configure --prefix=/usr/local/data/nginx --user=nginx --group=nginx --with-pcre --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_modulemake && make install
2.安装配置php
yum install http://rpms.famillecollet.com/enterprise/remi-release-6.rpmyum --enablerepo=remi-php56 install php php-fpm php-mysql php-gd php-xml php-redis php-libs php-devel php-zlib php-mbstring
nginx 和php-fpm 的运行用户这里使用nginx
vim /etc/php-fpm.confuser = nginxgroup = nginxlisten = 127.0.0.1:9000env[HOSTNAME] = $HOSTNAMEenv[PATH] = /usr/local/bin:/usr/bin:/binenv[TMP] = /tmpenv[TMPDIR] = /tmpenv[TEMP] = /tmp
3.安装mysql
yum -y install mysql mysql-serverservice mysqld start
4.建库,授权
CREATE DATABASE nextcloud_db;GRANT ALL ON nextcloud_db.* TO 'nextcloud'@'%' IDENTIFIED BY 'nextcloud'; //注意一定要加 "%",否则无法让网络让任何人上传文件FLUSH PRIVILEGES;
5.安装nextcloud
wget https://download.nextcloud.com/server/releases/nextcloud-10.0.2.zip --no-check-certificateunzip nextcloud-10.0.2.zipmv nextcloud /usr/local/data/nginx/html/usr/local/data/nginx/htmlchown -R nginx.nginx
创建数据目录,这里建议数据目录不要和web目录放到一起
/usr/local/data/nginx/html/nextcloud/data
6.申请证书
为了网盘的安全,有必要使用https 证书,这里可以在阿里云后台申请免费的DV证书
7.配置nginx
创建虚拟主机文件
cd /usr/local/data/nginx/confvim nextcloud.confupstream php-handler {server 127.0.0.1:9000;}server {listen 80;server_name cloud.nextcloud.com;return 301 https://$server_name$request_uri;}server {listen 443 ssl;server_name cloud.nextcloud.com;ssl_certificate /usr/local/data/nginx/conf/nextcloud.crt;ssl_certificate_key /usr/local/data/nginx/conf/nextcloud.key;#添加如下header主要为了安全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;#nextcloud代码目录root /usr/local/data/nginx/html/nextcloud/;location = /robots.txt {allow all;log_not_found off;access_log off;}#为了支持user_webfinger apprewrite ^/.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;}#设置上传文件的最大大小,php也得修改client_max_body_size 512M;fastcgi_buffers 64 4K;# Disable gzip to avoid the removal of the ETag headergzip off;error_page 403 /core/templates/403.php;error_page 404 /core/templates/404.php;#重要的:将所有请求转发到index.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 twicefastcgi_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;}# 添加js和css文件的缓存控制头location ~* \.(?:css|js)$ {try_files $uri /index.php$uri$is_args$args;add_header Cache-Control "public, max-age=7200";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;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;}}
vim nginx.confinclude nextcloud.conf;service nginx start
8.配置php上传大小
vim /etc/php.inimax_execution_time = 0post_max_size = 512Mupload_max_filesize = 512Mservice php-fpm start
9.配置nextcloud
10.nextcloud 配置redis缓存
使用Redis做内存缓存可以有效提升程序运行速度。
curl -O http://download.redis.io/releases/redis-3.2.8.tar.gztar -zxvf redis-3.2.8.tar.gzcd redis-3.2.8/deps/make geohash-int hiredis jemalloc linenoise luacd ..make && make installcd utils/./install_server.sh
配置redis
vim /etc/redis/6379.conf# requirepass foobaredrequirepass ExpvUwNOk9XRawC8bind 192.168.40.200
启动
redis-server /etc/redis/6379.conf
配置nextcloud
cd /usr/local/nginx/html/nextcloud/configvim config.php 'memcache.local' => '\OC\Memcache\Redis','redis' => array('host' => '192.168.40.200','port' => 6379,'password' => 'ExpvUwNOk9XRawC8',),
刷新页面
设置定时
*/15 * * * * /usr/bin/php /usr/local/nginx/html/nextcloud/cron.php >/dev/null
参考文档
https://docs.nextcloud.com/server/10/admin_manual/installation/index.html
配置
文件
安全
支持
目录
缓存
证书
内容
大小
建议
数据
部分
运行
最大
有效
重要
必要
主机
代码
内存
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
网络安全事件及风险隐患
增强网络安全意识的作文
东莞规划网络安全协会
瀑布模型追求软件开发的速度
大学生网络安全讲座采访
浙江网络技术服务信息推荐
室做服务器
手机数据库损坏怎么修
服务器搭建与管理心得
服务器流量异常
数据库语言图片
数据库的网络模型
备份数据库提示没有选中任何表
银川app软件开发多少费用
网络安全审查信息
推理服务器销售价格
中信戴卡 网络安全工程师
软件开发工具基本原则
霞浦县凑勇网络技术服务部
兴城市小通云网络技术工作室
河南服务器机柜定制价格
交控科技工业互联网
个人app软件开发费用
网络技术方面的活动
网络安全软件黑客
江苏调度服务器挂式云主机
软件开发 给公司建议
如何在网易服务器开挂
领信互联网科技信息有限公司
嵌入式软件开发和软件开发的区