Nextcloud
系统环境
CentOS release 6.9 (Final) 64 位
1
2
[ root@xsage] # cat /etc/redhat-release
CentOS release 6.9 ( Final)
安装环境
秋水逸冰 LAMP 一键包,
Apache 2.4
php 7.0.16
MariaDB 5.5
1
2
[ root@xsage] # lamp add
[ root@xsage] # cd /data/cluod.example.com/
虽然是在 VPS 上安装,但是我用的是 Web installer(For shared hosts),这个相对来说更方便一些。
1
wget https://download.nextcloud.com/server/installer/setup-nextcloud.php
下载之后,访问自己的域名 https://cloud.example.com/setup-nextcloud.php,按照提示便可完成安装。
使用 lamp.sh 一键包可能需要改动的文件和命令
1
2
3
4
5
6
7
/etc/init.d/httpd restart #重启apache
chown -R apache:apache /data/www/test.xsage.cn/ #设置虚拟主机目录权限
/usr/local/apache/conf/vhost/ # vhost配置目录
/usr/local/php/etc/php.ini #php配置文件
另外,在创建 vhost 时我就配置了 SSL,这里附上自己的设置
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
<VirtualHost *:80>
ServerName test.xsage.cn
ServerAlias test.xsage.cn
DocumentRoot /data/www/test.xsage.cn
DirectoryIndex index.php index.html index.htm
<Directory /data/www/test.xsage.cn>
Options +Includes -Indexes
AllowOverride All
Order Deny,Allow
Require all granted
php_admin_value open_basedir /data/www/test.xsage.cn:/tmp:/proc
</Directory>
ErrorLog /data/wwwlog/test.xsage.cn/error.log
TransferLog /data/wwwlog/test.xsage.cn/access.log
</VirtualHost>
Listen 443
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:/usr/local/apache/logs/ssl_scache(512000)"
SSLSessionCacheTimeout 300
<VirtualHost *:443>
DocumentRoot /data/www/test.xsage.cn/
ServerName test.xsage.cn
ServerAlias test.xsage.cn
ErrorLog "/usr/local/apache/logs/test_xsxage_cn_error_log"
TransferLog "/usr/local/apache/logs/test_xsxage_cn_access_log"
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCipherSuite ALL:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
SSLCertificateFile /usr/local/apache/conf/ssl/test.xsage.cn.crt
SSLCertificateKeyFile /usr/local/apache/conf/ssl/test.xsage.cn.key
CustomLog "/usr/local/apache/logs/test_xsage_cn_request_log" \
"%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b \"%{Referer}i\" \"%{User-Agent}i\""
BrowserMatch "MSIE [2-5]" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
<Directory /data/www/test.xsage.cn/>
Options -Indexes +FollowSymLinks
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
安装过程中遇到的问题和解决办法:
Q: “PHP is apparently set up to strip inline doc blocks. This will make several core apps inaccessible. This is probably caused by a cache/accelerator such as Zend OPcache vs Accelerator.” A: 将 /usr/local/php/php.d/opcache.ini 文件移动到别的目录下,重启 Apache 。需要用时,恢复此配置文件,重启 Apache。
Q:Give PHP read access to /dev/urandom
A:When having an open_basedir
configured within your php.ini
file, make sure to include /dev/urandom
.
开启 HTTPS,Apache 参考如下
<VirtualHost *:80>
ServerName cloud.nextcloud.com
Redirect permanent / https://cloud.nextcloud.com/
</VirtualHost>
开启HSTS(HTTP Strict Transport Security),Apache参考如下
1
2
3
4
5
6
<VirtualHost *:443>
ServerName cloud.nextcloud.com
<IfModule mod_headers.c>
Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains; preload"
</IfModule>
</VirtualHost>
在 https://www.ssllabs.com/ssltest/ 的评级是 A+。
参考文档:
https://teddysun.com/lamp/comment-page-29
https://docs.nextcloud.com/server/11/admin_manual/configuration_server/harden_server.html
https://lamp.sh/install.html