搭建Nextcloud

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 安装 私有云盘,mysql nginx redis php等组件
                     Nextcloud搭建

第一步 install start download
cd /usr/loacal/src
wget https://download.nextcloud.com/server/releases/nextcloud-13.0.2.tar.bz2
tar -jxf nextcloud-13.0.2.tar.bz2
mkdir -p /data/www
mv nextcloud /data/www
chown -R nginx. /data/www/nextcloud
useradd -s /sbin/nologin/ nginx -M
第二步骤 安装nginx
安装依赖
yum install gcc--c++ pcre pcre-devel zlib zlib-devel op
enssl openssl-devel -y
编译
./configure --prefix=/usr/local/nginx --pid-path
=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --error-log-path=/va
r/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzi
p_static_module --http-client-body-temp-path=/var/temp/nginx/client --http-prox
y-temp-path=/var/temp/nginx/proxy --http-fastcgi-temp-path=/var/temp/nginx/fast
cgi --http-uwsgi-temp-path=/var/temp/nginx/uwsgi --http-scgi-temp-path=/var/tem
--with-http_ssl_module
创建nginx temp目录
mkdir -p /var/temp/nginx
make install

启动 nginx
/usr/local/nginx/sbin/nginx
第三步install mariadb
yum install mariadb mariadb-server -y
vim /etc/my.cnf
[client]
default-character-set=utf8mb64
[mysql]
default-character-set=utf8mb64
[mysqld]
character-set-server=utf8mb64
collection-server=utf8mb64_unicode_cli
innodb_large_prefix=ON
innodb_file_format=Barracuda
innodb_file_per_table=ON
innodb_file_per_table=1
default-storage-engine = INNODB
初始化设置
/usr/bin/mysql_install_db --user=mysql --datadir=/var/lib/mysql
开启mysql服务
systemctl restart mariadb
创建数据库
create database nextcloud CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;
授权操作
grant all privileges on nextcloud.* to "nextcloud"@"%" identified by "nextcloud";
grant all privileges on nextcloud.* to "nextcloud"@"localhost" identified by "nextcloud";
刷新权限
flush privileges;
第四步安装php相关
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://rpms.remirepo.net/enterprise/remi-release-7.rpm
rpm -Uvh remi-release-7.rpm epel-release-latest-7.noarch.rpm
subscription-manager repos --enable=rhel-6-server-optional-rpms
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php70w-fpm php70w-cli php70w-opcache php70w-gd php70w-mcrypt php70w-mysql php70w-pear php70w-xml php70w-mbstring php70w-pdo php70w-json php70w-pecl-apcu php70w-pecl-apcu-devel
验证php7的版本
php -v
配置php-fpm
sed -i "/^user =/s/apache/nginx/g" /etc/php-fpm.d/www.conf

sed -i '/^ugroup =/s/apache/nginx/g' /etc/php-fpm.d/www.conf

更改授权用户

mkdir -p /var/lib/php/session
chown nginx:nginx -R /var/lib/php/session/
最后 nginx的配置

vim vhost/*.conf
upstream php-handler {

    server 127.0.0.1:9000;
    }
server {
    listen       80;
    server_name  localhost;
    add_header Referrer-Policy "no-referrer" 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;
    # Remove X-Powered-By, which is an information leak
    fastcgi_hide_header X-Powered-By;
    root /data/www/nextcloud;

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

    location = /.well-known/carddav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }
    location = /.well-known/caldav {
      return 301 $scheme://$host:$server_port/remote.php/dav;
    }




    location / {
         rewrite ^ /index.php;
    }

    location ~ ^\/(?:build|tests|config|lib|3rdparty|templates|data)\/ {
        deny all;
    }
    location ~ ^\/(?:\.|autotest|occ|issue|indie|db_|console) {
        deny all;
    }                                                                                                                      
                                                                                                                           
    error_page   500 502 503 504  /50x.html;                                                                               
    location = /50x.html {                                                                                                 
        root   html;                                                                                                       
    }                                                                                                                      
                                                                                                                           
                                                                                                                           
        root /data/www/nextcloud;                                                                                          
        fastcgi_pass 127.0.0.1:9000;                                                                                       
        fastcgi_index index.php;                                                                                           
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;                                                  
        fastcgi_split_path_info ^(.+?\.php)(\/.*|)$;                                                                       
        fastcgi_param PATH_INFO $fastcgi_path_info;                                                                        
        include fastcgi_params;                                                                                            
    }                                                                                                                      
                                                                                                                           
#    location ~ \.php$ {                                                                                                   
#        if (!-e $request_filename) {                                                                                      
#               rewrite ^/(.*)$ /index.php/$1 last;                                                                        
#        }                                                                                                                 
#        root           /usr/local/nginx/html/nextcloud;                                                                   
#        fastcgi_pass   127.0.0.1:9000;                                                                                    
#        fastcgi_index  index.php;                                                                                         
#        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;                                               
#        include        fastcgi_params;                                                                                    
#    }                                                                                                                     
     location ~ ^\/(?:updater|oc[ms]-provider)(?:$|\/) {                                                                   
          try_files $uri/ =404;                                                                                            
          index index.php;                                                                                                 
        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;" always;                      
        #                                                                                                                  
        # 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 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;                                                                
                                                                                                                           
        # Optional: Don't log access to assets                                                                             
        access_log off;                                                                                                    
     }                                                                                                                     
    location ~ \.(?:png|html|ttf|ico|jpg|jpeg|bcmap|mp4|webm)$ {                                                           
        try_files $uri /index.php$request_uri;                                                                             
        # Optional: Don't log access to other assets                                                                       
        access_log off;                                                                                                    
    }                                                                                                                      
                                                                                                                           
    # 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 applicat
ion/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;
}
Systemctl restart mariadb
Systemctl start php-fpm
/usr/local/nginx/sbin/nginx -s reload

相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
6月前
|
存储 Ubuntu 网络协议
Ubuntu本地部署Nextcloud并结合内网穿透实现远程访问搭建个人云盘
Ubuntu本地部署Nextcloud并结合内网穿透实现远程访问搭建个人云盘
413 1
|
6月前
|
关系型数据库 MySQL 网络安全
VPS搭建WordPress
如果你想搭建的WordPress拥有一个较好的性能的话,那么你可以选择在VPS上搭建WordPress。本文将会带你从零开始,在VPS上一步一步敲代码来搭建WordPress。首先,你需要注册一台VPS,登录你的VPS先搭建好LAMP环境;接下来你需要将你的域名已经解析到你的VPS。在域名解析成功后,你需要创建MySQL数据库,然后安装PHP插件并配置Apache,接下来下载并配置WordPress,最后是安装SSL证书。
240 1
VPS搭建WordPress
|
弹性计算 关系型数据库 应用服务中间件
Wordpress 安装部署
简单几个步骤即可使用 ECS、RDS 进行 wordpress 安装,完成内容站点的部署。
177 0
|
安全 关系型数据库 MySQL
基于LNMP搭建WordPress
基于LNMP搭建WordPress
2177 0
|
关系型数据库 MySQL 应用服务中间件
|
Kubernetes 数据可视化 数据库
docker搭建图形化界面portainer1.24.2,快速搭建wordpress5.7.2站点
docker搭建图形化界面portainer1.24.2,快速搭建wordpress5.7.2站点
373 0
docker搭建图形化界面portainer1.24.2,快速搭建wordpress5.7.2站点
|
负载均衡 Ubuntu 固态存储
Linux服务器搭建gitlab需要什么配置?
Linux服务器搭建gitlab需要什么配置?
1022 0
|
弹性计算 Ubuntu Unix
安装 NextCloud 网盘程序| 学习笔记
快速学习安装 NextCloud 网盘程序。
478 0
安装 NextCloud 网盘程序| 学习笔记
|
Linux Docker 容器
Centos7下Docker搭建Nextcloud个人网盘
Centos7下Docker搭建Nextcloud个人网盘
1275 0
Centos7下Docker搭建Nextcloud个人网盘
|
关系型数据库 MySQL Linux