Drupal と Nextcloud を連携させる
Drupal さっぽろ勉強会
## dsm47という名前のフォルダにffdsmをクローンする
$ git clone https://github.com/bkenro/ffdsm.git dsm47
## フォルダに移動して Vagrantfile を編集する
$ cd dsm47
$ vi Vagrantfile
Vagrant.configure("2") do |config|
config.vm.box = "bkenro/ffdsm"
config.vm.network "private_network", ip: "192.168.56.81"
config.vm.hostname = "dsm47.internal"
config.vm.provider "virtualbox" do |vb|
vb.name = "vm-dsm47"
vb.customize ["modifyvm", :id, "--memory", "2048"]
end
# config.vm.synced_folder ".", "/vagrant", disabled: true
# config.vm.synced_folder "www", "/var/www", type: "virtualbox"
end
$ vagrant up
〜
$ vagrant ssh
https://nextcloud.com/install/
$ sudo chown vagrant:vagrant /var/www
$ cd /var/www
$ wget https://download.nextcloud.com/server/releases/latest.zip
$ unzip latest.zip
$ sudo chown -R www-data:www-data nextcloud
/etc/apache2/sites-available/nextcloud.conf
<VirtualHost *:80>
DocumentRoot /var/www/nextcloud
ServerName nextcloud.internal
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory "/var/www">
AllowOverride All
</Directory>
</VirtualHost>
## ホスト側
$ sudo vi /etc/hosts
### local dev hosts: dsm47
192.168.56.81 drupal.internal
192.168.56.81 nextcloud.internal
/etc/php/8.3/apache2/php.ini
〜
memory_limit = 512M
〜
opcache.interned_strings_buffer=16
〜
$ cd /var/www/nextcloud
$ sudo -u www-data php occ db:add-missing-indices
$ sudo -u www-data php occ maintenance:repair --include-expensive
設定項目 | 値 |
---|---|
送信モード | SMTP |
暗号化 | None/STARTTLS |
送信元アドレス | 任意(例:admin@nextcloud.internal) |
サーバーアドレス | localhost:1025 |
認証を必要とする | OFF |
## 自己認証局の構成
$ mkcert -install
## ルート証明書と鍵の確認
$ ls $(mkcert -CAROOT)
rootCA-key.pem rootCA.pem
## Vagrant の共有フォルダに移動
$ cd dsm47
## ルート証明書と秘密鍵をコピー
$ cp $(mkcert -CAROOT)/*.pem .
$ mkcert nextcloud.internal
Created a new certificate valid for the following names 📜
- "nextcloud.internal"
The certificate is at "./nextcloud.internal.pem" and the key at "./nextcloud.internal-key.pem" ✅
It will expire on 24 March 2027 🗓
## 仮想マシン上
## ホストとの共有フォルダに移動
$ cd /vagrant
## サーバー証明書と鍵を所定の場所にコピー
$ sudo cp nextcloud.internal.pem /etc/ssl/certs/
$ sudo cp nextcloud.internal-key.pem /etc/ssl/private/
## Apache の SSL モジュールを有効化
$ sudo a2enmod ssl
## HTTPS 用の仮想ホストを追加
$ cd /etc/apache2/sites-available
$ sudo vi nextcloud-ssl.conf
/etc/apache2/sites-available/nextcloud-ssl.conf
<VirtualHost *:443>
## 対象ドメインと対応するディレクトリを指定
ServerName nextcloud.internal
DocumentRoot /var/www/nextcloud
## Apacheログの設定
ErrorLog ${APACHE_LOG_DIR}/nextcloud_error.log
CustomLog ${APACHE_LOG_DIR}/nextcloud_access.log combined
## HTTPSの有効化と証明書/鍵ファイルの指定
SSLEngine on
SSLCertificateFile /etc/ssl/certs/nextcloud.internal.pem
SSLCertificateKeyFile /etc/ssl/private/nextcloud.internal-key.pem
<FilesMatch "\.(?:cgi|shtml|phtml|php)$">
SSLOptions +StdEnvVars
</FilesMatch>
<Directory "/var/www">
AllowOverride All
</Directory>
<Directory /usr/lib/cgi-bin>
SSLOptions +StdEnvVars
</Directory>
</VirtualHost>
## 作成したhttps用の設定を組み込む
$ sudo a2ensite nextcloud-ssl.conf
## Webサーバーを再起動して反映
$ sudo systemctl restart apache2
$ sudo vi /etc/hosts
/etc/hosts
〜
### local dev hosts: dsm47
192.168.56.81 drupal.internal
192.168.56.81 nextcloud.internal
$ wget https://nextcloud.internal/
--2024-12-24 15:09:02-- https://nextcloud.internal/
Resolving nextcloud.internal (nextcloud.internal)... 192.168.56.81
Connecting to nextcloud.internal (nextcloud.internal)|192.168.56.81|:443... connected.
ERROR: cannot verify nextcloud.internal's certificate, issued by ‘CN=mkcert bkenro@dev01,OU=bkenro@dev01,O=mkcert development CA’:
Unable to locally verify the issuer's authority.
To connect to nextcloud.internal insecurely, use `--no-check-certificate'.
## 仮想マシン内の操作
$ cd /vagrant
$ sudo cp rootCA.pem /usr/share/ca-certificates/
$ sudo vi /etc/ca-certificates.conf
/etc/ca-certificates.conf
〜
rootCA.pem
$ sudo update-ca-certificates
Nextcloud を OIDC の IDP、Drupal を SP
Drupal を OIDC の IDP、Nextcloud を SP