nextclound的安装

一)#install start download

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

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

mkdir -p  /data/cdata

useradd -s /sbin/nologin/ nginx -M

chown -R nginx.  /data/cdata

安装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 

p/nginx/scgi

创建nginx temp目录

nkdir -p /var/temp/nginx

make  install

 

启动 nginx

/usr/local/nginx/sbin/nginx

 

二)#install mariadb

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

yum install mariadb mariadb-server -y

echo >> /etc/my.cnf<<EOF

[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

EOF

初始化设置

/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及其nextclound需要的包

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

#安装php及其nextclound需要的包

首先安装 remi

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 

#vim /etc/php-fpm.d/www.conf 

user = nginx 

group = nginx   #在第8行和第10行,user和group赋值为nginx。

listen = 127.0.0.1:9000   #在第 22 行,确保 php-fpm 运行在指定端口。

 

env[HOSTNAME] = $HOSTNAME

env[PATH] = /usr/local/bin:/usr/bin:/bin

env[TMP] = /tmp

env[TMPDIR] = /tmp

env[TEMP] = /tmp         #取消第366-370行的注释,启用php-fpm的系统环境变量。

 

#更改授权用户

mkdir -p /var/lib/php/session 

chown nginx:nginx -R /var/lib/php/session/

然后启动php-fpm和nginx 并且将他们设置为开机启动

systemctl start php-fpm 

systemctl start nginx 

systemctl enable php-fpm 

systemctl enable nginx

 

四)nginx的配置

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

42

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

58

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

75

76

77

78

79

80

81

82

83

84

85

86

87

88

89

90

91

92

93

94

95

96

97

98

99

100

101

102

103

104

105

106

107

108

109

110

111

112

113

114

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;

    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值