my-owncloud-site.com {

    root owncloud
    log owncloud/access.log
    errors owncloud/access.log

    fastcgi / 127.0.0.1:9000 php {
            env PATH /bin
    }

    rewrite {
        r ^/index.php/.*$
        to /index.php?{query}
    }

    # client support (e.g. os x calendar / contacts)
    redir /.well-known/carddav /remote.php/carddav 301
    redir /.well-known/caldav /remote.php/caldav 301

    # remove trailing / as it causes errors with php-fpm
    rewrite {
        r ^/remote.php/(webdav|caldav|carddav|dav)(\/?)$
        to /remote.php/{1}
    }

    rewrite {
        r ^/remote.php/(webdav|caldav|carddav|dav)/(.+?)(\/?)$
        to /remote.php/{1}/{2}
    }

    # .htacces / data / config / ... shouldn't be accessible from outside
    status 404 {
        /.htaccess
        /data
        /config
        /db_structure
        /.xml
        /README
    }

    header / Strict-Transport-Security "15768000"

}

本来Caddy官方博客是有个配置文件的,但昨天试了下Caddy不能正常启动,主要是rewrite里面嵌套了status吧。

ownCloud,Caddy安装过程中的一些记录

用上面的配置文件,PHP-FPM是这么安装的:

apt-get install -y php7.0-fpm php7.0-mysql php7.0-gd php7.0-curl php7.0-intl php7.0-mcrypt php7.0-xml php7.0-zip php7.0-mbstring
sed -i 's/^listen\s*=.*$/listen = 127.0.0.1:9000/' /etc/php/7.0/fpm/pool.d/www.conf
service php7.0-fpm restart

安装之前没有提示有额外安装的依赖,安装之后也只提示缺少memcache

2016-12-03_212311.png

额,我128MB内存的VPS就不搞Memcached了。。

使用的是Ubuntu 14.04,安装PHP7.0用的是PPA:

apt-get install -y software-properties-common python-software-properties language-pack-en-base
echo -e "\n" | LC_ALL=en_US.UTF-8 add-apt-repository ppa:ondrej/php
apt-get update

Supervisor管理Caddy,详细看:Caddy Server 笔记 v2 - 部署WordPress

其他也就没有什么了。

之所以用Caddy这个Web服务器,主要是部署SSL证书方便!免费证书中,Let's Encrypt还是比较靠谱的。