主机放于家庭电视机柜中,24小时开机,乔思伯V3 ITX HTPC机箱
主板集成J1800 CPU,无风扇,TDP 15w,足够放1080p X264编码的高清电影,不过现在建议用更高级的N3455主板,能放4k的高清。
上述路由器的默认帐户和密码是root,出于安全的需要,请把密码改了
ssh [email protected]
vi uhttp
,把两个listen_http后面的端口改成800。config uhttpd 'main'
list listen_http '0.0.0.0:800'
list listen_http '[::]:800'
list listen_https '0.0.0.0:443'
list listen_https '[::]:443'
21->21:#For FTP
20->20:#For FTP
22->22:#For SSH remote login
443->443:#For Https
6800->6800:#For Aria2
6801->6801:#For Aria2
system-config-samba
,最好在htpc上直接用键盘操作。sudo apt-get install mysql-server mysql-client
/dev/sdb5 /mnt/disk1 ntfs locale=zh_CN.UTF-8,uid=33,gid=33,dmask=007,windows_names 0 0
www-data
和用户组www-data
sudo apt-get install nginx
sudo add-apt-repository ppa:ondrej/php
sudo apt-get update
sudo apt-get install php7.0 php-fpm php-mysql php-mbstring
/home/test/www
sudo chown www-data -R /home/test/www
sudo chmod 755 -R /home/test/www
- 拷贝原始配置文件
cd /home/test/www/phpmyadmin
cp config.sample.inc.php config.inc.php
vi /home/test/www/phpmyadmin/config.inc.php
$cfg['blowfish_secret'] = '$#%#$%#$%#$^#^ETETR';
就是一个加密信息,越乱越好cd /home/test/www/phpmyadmin/libraries
vi config.default.php
$cfg['blowfish_secret']
- php.ini:
short_open_tag = On
extension_dir = "/usr/lib/php/20151012"
,目录通过catfish
搜索mysql.so
找到,用于安装各种扩展,应该是apt-get install
时自动放入。extension=mysqli.so
,extension=pdo_mysql.so
include=/etc/php/7.0/fpm/pool.d/*.conf
,里面有www.conf
文件
listen
: listen = /run/php/php7.0-fpm.sock
,配置nginx时会用到sudo service php7-fpm restart
/etc/php5/fpm
,也是这两个文件* php-fmp.conf和php.ini*两个重要的文件
- php.ini
1. 设置 ```short_open_tag = On```
2. ``extension_dir="/usr/lib/php5/20121212"``,注意和php7的不同,估计也是编译时生成
3. ``cgi.fix_pathinfo=1``,应该是和owncloud有关的一个设置,否则会报错。
4. 各种extensions,有部分是和owncloud相关
```
extension=mysql.so
extension=mysqli.so
extension=pdo_mysql.so
extension=pdo.so
extension=json.so
extension=gd.so
extension=opcache.so
```
include=/etc/php5/fpm/pool.d/*.conf
,里面有www.conf
文件,找listen参数:listen = /var/run/php5-fpm.sock
owncloud9.0强制要求https服务,需要对自己web站进行认证,实际中我试过两种方案,最后用的是第一种方案
- 采用自验证方案,借用廖雪峰大神的脚本给Nginx配置一个自签名的SSL证书
- 运行这个脚本后,把生成的key文件和crt文件复制到
/etc/nginx/ssl/
目录,
如/etc/nginx/ssl/testdomain.changeip.com.crt
和/etc/nginx/ssl/testdomain.changeip.com.key
配置nginx时要用到
或者你直接在后面写nginx文件时指向这两个文件
- 被大牛吐槽自授权是错误的价值观,在他的建议下换成 Let’s Encrypt(是一个免费、自动化、开放的证书颁发机构,由网络安全研究小组运作)的免费授权系统,主要参考了Let's Encrypt SSL证书配置和折腾Let‘s Encrypt免费SSL证书
git clone https://github.com/certbot/certbot.git
cd certbot
./letsencrypt-auto --help
./letsencrypt-auto certonly -d testdomain.changip.com -m [email protected]
/etc/letsencrypt/live/testdomain.changeip.com/fullchain.pem
/etc/letsencrypt/live/testdomain.changeip.com/privkey.pem
sudo openssl dhparam -out /etc/nginx/ssl/dhparams.pem 2048
rpc-secret=secret #token加密方式
enable-rpc=true
rpc-allow-origin-all=true
rpc-listen-all=true
rpc-listen-port=6800#nginx里有个转发到这个端口的设置
rpc-secure=true
rpc-certificate=/etc/letsencrypt/live/testdomain.changeip.com/fullchain.pem
rpc-private-key=/etc/letsencrypt/live/testdomain.changeip.com/privkey.pem
max-concurrent-downloads=5
continue=true
max-connection-per-server=5
min-split-size=10M
split=10
max-overall-download-limit=3M
max-download-limit=0
max-overall-upload-limit=256K
max-upload-limit=0
dir=/mnt/disk2/Downloads
disk-cache=32M
file-allocation=prealloc
input-file=/home/kodi/.aria2/aria2.session
save-session=/home/kodi/.aria2/aria2.session
setting
后,要把JSON-RPC Path
设置成https://token:[email protected]:6801/jsonrpc #请注意https和6801
upstream php5-handler {
server unix:/var/run/php5-fpm.sock;
}
upstream php7-handler {
server unix:/run/php/php7.0-fpm.sock;
}
server{
listen 6801 ssl;
server_name testdomain.changeip.com;
ssl_certificate /etc/letsencrypt/live/testdomain.changeip.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/testdomain.changeip.com/privkey.pem;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:6800;
}
}
server {
listen 443 ssl;
server_name testdomain.changeip.com 192.168.10.150;
ssl_certificate /etc/letsencrypt/live/testdomain.changeip.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/testdomain.changeip.com/privkey.pem;
ssl_dhparam /etc/nginx/ssl/dhparams.pem;
ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';
ssl_prefer_server_ciphers on;
# Add headers to serve security related headers
# Before enabling Strict-Transport-Security headers please read into this topic first.
#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;
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
# Path to the root of your installation
root /home/kodi/www/;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location /luci{
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://192.168.10.1;
}
# The following 2 rules are only needed for the user_webfinger app.
# Uncomment it if you're planning to use this app.
#rewrite ^/.well-known/host-meta /owncloud/public.php?service=host-meta last;
#rewrite ^/.well-known/host-meta.json /owncloud/public.php?service=host-meta-json last;
location = /.well-known/carddav { return 301 $scheme://$host/owncloud/remote.php/dav; }
location = /.well-known/caldav { return 301 $scheme://$host/owncloud/remote.php/dav; }
location /.well-known/acme-challenge { }
location ^~ /phpmyadmin{
location /phpmyadmin{
server_name_in_redirect off;
index index.php;
}
location ~ ^/phpmyadmin/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/phpmyadmin/(?:\.|autotest|occ|issue|indie|console) {
deny all;
}
location ~ "^\/phpmyadmin\/.*\.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;
fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
fastcgi_param front_controller_active true;
fastcgi_pass php5-handler;
fastcgi_intercept_errors on;
# fastcgi_request_buffering off;
}
location ~ "^\/phpmyadmin\/.*\.\(htm|html|gif|jpg|png|js|css\)$" {
root /home/kodi/www;
}
}
location ^~ /owncloud {
# set max upload size
client_max_body_size 51200M;
fastcgi_buffers 64 4K;
# Disable gzip to avoid the removal of the ETag header
gzip off;
# Uncomment if your server is build with the ngx_pagespeed module
# This module is currently not supported.
#pagespeed off;
location /owncloud {
rewrite ^ /owncloud/index.php$uri;
}
location ~ ^/owncloud/(?:build|tests|config|lib|3rdparty|templates|data)/ {
deny all;
}
location ~ ^/owncloud/(?:\.|autotest|occ|issue|indie|db_|console) {
deny all;
}
location ~ ^/owncloud/(?: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;
fastcgi_param modHeadersAvailable true; #Avoid sending the security headers twice
fastcgi_param front_controller_active true;
fastcgi_pass php5-handler;
fastcgi_intercept_errors on;
# fastcgi_request_buffering off;
}
location ~ ^/owncloud/(?:updater|ocs-provider)(?:$|/) {
try_files $uri/ =404;
index index.php;
}
# Adding the cache control header for js and css files
# Make sure it is BELOW the PHP block
location ~* \.(?:css|js)$ {
try_files $uri /owncloud/index.php$uri$is_args$args;
add_header Cache-Control "public, max-age=7200";
# 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;";
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;
# Optional: Don't log access to assets
access_log off;
}
location ~* \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg)$ {
try_files $uri /owncloud/index.php$uri$is_args$args;
# Optional: Don't log access to other assets
access_log off;
}
}
}