Skip to content

Instantly share code, notes, and snippets.

@HayatoDoi
Last active November 5, 2017 04:01
Show Gist options
  • Save HayatoDoi/3afa904917a1ba1513baa02f206ffb93 to your computer and use it in GitHub Desktop.
Save HayatoDoi/3afa904917a1ba1513baa02f206ffb93 to your computer and use it in GitHub Desktop.
ownCloud環境構築メモ

ownCloud環境構築メモ

The built environment

  • OS : debian9
  • Middleware : Nginx
  • Application : php7.0-fpm
  • DetaBase : MySQL

Middleware install(Nginx)

apt-get install nginx
systemctl start nginx
systemctl enable nginx
rm /etc/nginx/sites-enabled/default
rm /etc/nginx/sites-available/default
vim /etc/nginx/conf.d/owncloud.conf
systemctl restart nginx

The contents of /etc/nginx/conf.d/owncloud.conf

server {
    listen 80;
    server_name storage.local.nononono.net;
    root       /var/www/owncloud;
    index      index.php;

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
    }
    location = /.well-known/carddav {
        return 301 $scheme://$host/remote.php/dav;
    }
    error_page 403 /core/templates/403.php;
    error_page 404 /core/templates/404.php;
    #location / {
    #    rewrite ^ /index.php$uri;
    #}
    location ~ ^/(?:build|tests|config|lib|3rdparty|templates|data)/ {
        return 404;
    }
    location ~ ^/(?:\.|autotest|occ|issue|indie|db_|console) {
        return 404;
    }
    location ~ ^/(?:index|remote|public|cron|core/ajax/update|status|ocs/v[12]|updater/.+|ocs-provider/.+|core/templates/40[34])\.php(?:$|/) {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass   unix:/var/run/php/php7.0-fpm.sock;
        fastcgi_index  index.php;
        include        fastcgi_params;
        include        fastcgi.conf;
    }
    location ~ ^/(?:updater|ocs-provider)(?:$|/) {
        try_files $uri $uri/ =404;
        index index.php;
    }

    location ~ \.(?:css|js)$ {
        try_files $uri /index.php$uri$is_args$args;
        add_header Cache-Control "max-age=15778463";
        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;
        access_log off;
    }

    location ~ \.(?:svg|gif|png|html|ttf|woff|ico|jpg|jpeg|map)$ {
        add_header Cache-Control "public, max-age=7200";
        try_files $uri /index.php$uri$is_args$args;
        access_log off;
    }
}

Application install(php7.0-fpm)

apt-get install php7.0-fpm
systemctl start php7.0-fpm
systemctl enable php7.0-fpm
apt-get install php7.0-mysql php7.0-zip php7.0-xml php7.0-mbstring php7.0-curl php7.0-gd
vi /etc/php/7.0/fpm/php.ini
# 以下コメントアウトを外す
# extension=php_curl.dll
# extension=php_mysqli.dll
# extension=php_pdo_mysql.dll
systemctl restart php7.0-fpm

DetaBase install(MySQL)

apt-get install mysql-server
systemctl start mysql
systemctl enable mysql
mysql -u root

make user

CREATE DATABASE owncloud;
CREATE USER owncloud IDENTIFIED BY 'password';
GRANT ALL ON owncloud.* TO 'owncloud'@'localhost' IDENTIFIED BY 'password';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment