ownCloud on nginx - Qiita
最近でもストックしてもらえるので需要がある様子。公式ドキュメント(Ver9.2)のURLが変わってしまったのでリンク先を修正しました(2016/09/27)#環境Mac Book (Earl…
上記のとおりなんですが・・・
自分のメモとして残しておきます。
CAUTION
この方法だとownCloudのアップデートに失敗します。nginxを使用した環境の場合は、素の状態からの導入がいいみたいです。
Setup ownCloud 7 with Nginx on Ubuntu 14.0.4.1 – surject.com /
http://www.surject.com/setup-owncloud-7-server-nginx-ubuntu/
環境:
- Distributor ID:Ubuntu
- Description:Ubuntu 14.04.1 LTS
- Release:14.04
- Codename:trusty
手順
1. Nginxの導入
deb http://nginx.org/packages/mainline/ubuntu/ codename nginx
deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx
sudo apt-get update
sudo apt-get install nginx
2. php関連パッケージの道入
sudo apt-get install php5-common php5-fpm php5-cli php5-json
php5-mysql php5-curl php5-intl php5-mcrypt php5-memcache php-xml-parser php-pear
3. apache2の停止
sudo service apache2 stop
4. nginx設定ファイルの修正
sudo cp /etc/nginx/conf.d/default.conf /etc/nginx/conf.d/default.conf.backup
sudo vi /etc/nginx/conf.d/default.conf
upstream php-handler {
#server 127.0.0.1:9000;
server unix:/var/run/php5-fpm.sock;
}
server {
listen 80;
server_name cloud.example.com;
# enforce https
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
server_name cloud.example.com;
ssl_certificate /etc/ssl/nginx/cloud.example.com.crt;
ssl_certificate_key /etc/ssl/nginx/cloud.example.com.key;
# Path to the root of your installation
root /var/www/owncloud/;
# set max upload size
client_max_body_size 10G;
fastcgi_buffers 64 4K;
rewrite ^/caldav(.*)$ /remote.php/caldav$1 redirect;
rewrite ^/carddav(.*)$ /remote.php/carddav$1 redirect;
rewrite ^/webdav(.*)$ /remote.php/webdav$1 redirect;
index index.php;
error_page 403 /core/templates/403.php;
error_page 404 /core/templates/404.php;
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ ^/(?:.htaccess|data|config|db_structure.xml|README){
deny all;
}
location / {
# The following 2 rules are only needed with webfinger
rewrite ^/.well-known/host-meta /public.php?service=host-meta last;
rewrite ^/.well-known/host-meta.json /public.php?service=host-meta-json last;
rewrite ^/.well-known/carddav /remote.php/carddav/ redirect;
rewrite ^/.well-known/caldav /remote.php/caldav/ redirect;
rewrite ^(/core/doc/[^/]+/)$ $1/index.html;
try_files $uri $uri/ /index.php;
}
location ~ .php(?:$|/) {
fastcgi_split_path_info ^(.+.php)(/.+)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param HTTPS on;
fastcgi_pass php-handler;
}
# Optional: set long EXPIRES header on static assets
location ~* .(?:jpg|jpeg|gif|bmp|ico|png|css|js|swf)$ {
expires 30d;
# Optional: Don't log access to assets
access_log off;
}
}
ちなみに上記の設定ファイルは公式ドキュメントのものです。
http://doc.owncloud.org/server/7.0/admin_manual/installation/configuration_nginx.html
5. オレオレ証明書をコピーする。
sudo mkdir /etc/nginx/ssl
sudo cp /usr/local/ssl* /etc/nginx/ssl
6. php-fpmのオーナーを変更する。
listen.owner = nginx
listen.group = nginx
7. サービスを起動する。
sudo service php5-fpm restart && sudo service nginx restart
たぶんアクセスするURLがhttps://xxx.xxx.xxx.xxx/
に変わっているはずです。適宜configを修正してください。
あと・・・
また、uploadサイズがdefaultに戻っているはずなので、必要な場合は修正してください。
memory_limit = 2048M
post_max_size = 2048M
upload_max_filesize = 2048M
External StorageとしてDropboxを接続するときは、defaultのままだと「connection reset by peer
」または「502 bad gateway
」になる可能性が高いので、以下を変更する。
request_terminate_timeout = 60
最初にも書きましたが、このままだとownCloudからのupdateが出来ないので、ソースからの道入を試みたほうがいいと思います。
間違い等あればご指摘ください。