GCEのf1-microインスタンスにDokuWikiを超手っ取り早くインストールする
Debian 10 + Nginx + php-fpmでインストールを行います。
DokuWikiは非常に軽量なので、GCEの無料f1-microインスタンスでも快適に動作します。
パッケージのインストール
Section titled “パッケージのインストール”推奨パッケージのインストールを無効にします。
必須パッケージをインストールします。
apt install nginx php-fpm php-gd
nginxの設定変更
Section titled “nginxの設定変更”個別に説明するのめんどうなので設定ファイルをご覧ください。
/etc/nginx/site-enabled/default
Section titled “/etc/nginx/site-enabled/default”通信量削減のためIPアドレス指定やwww無しでのアクセスを拒否してhttps(cloudflare経由)にリダイレクトするように構成する
server { listen 80 default_server; listen [::]:80 default_server;
server_name _;
return 301 https://www.junk-labs.com$request_uri;}/etc/nginx/site-enabled/dokuwiki
Section titled “/etc/nginx/site-enabled/dokuwiki”クライアントから直接アクセス場合はhttpsにリダイレクトするように/etc/nginx/site-enabled/defaultを構成し、SSLをcloudflare側で処理するためhttpのみ設定。
### You should look at the following URL's in order to grasp a solid understanding# of Nginx configuration files in order to fully unleash the power of Nginx.# https://www.nginx.com/resources/wiki/start/# https://www.nginx.com/resources/wiki/start/topics/tutorials/config_pitfalls/# https://wiki.debian.org/Nginx/DirectoryStructure## In most cases, administrators will remove this file from sites-enabled/ and# leave it as reference inside of sites-available where it will continue to be# updated by the nginx packaging team.## This file will automatically load configuration files provided by other# applications, such as Drupal or Wordpress. These applications will be made# available underneath a path with that package name, such as /drupal8.## Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.##
# Default server configuration#
server { listen 80; listen [::]:80;
# SSL configuration # # listen 443 ssl default_server; # listen [::]:443 ssl default_server; # # Note: You should disable gzip for SSL traffic. # See: https://bugs.debian.org/773332 # # Self signed certs generated by the ssl-cert package # Don't use them in a production server! # # include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP index index.html index.htm index.php;
# ここにリダイレクトするように構成するためserver_nameを指定する。 server_name www.junk-labs.com;
# 通常だと404を返すがdocuwikiにrewriteするように変更する location / { # First attempt to serve request as file, then # as directory, then fall back to displaying a 404. try_files $uri $uri/ @dokuwiki; }
location @dokuwiki { rewrite ^/_media/(.*) /lib/exe/fetch.php?media=$1 last; rewrite ^/_detail/(.*) /lib/exe/detail.php?media=$1 last; rewrite ^/_export/([^/]+)/(.*) /doku.php?do=export_$1&id=$2 last; rewrite ^/(?!lib/)(.*) /doku.php?id=$1&$args last; }
# aptで標準リポジトリからphp-fpmをインストールした場合はコメントアウトするだけでOK # pass PHP scripts to FastCGI server # location ~ \.php$ { include snippets/fastcgi-php.conf; # # # With php-fpm (or other unix sockets): fastcgi_pass unix:/run/php/php7.3-fpm.sock; # # With php-cgi (or other tcp sockets): # fastcgi_pass 127.0.0.1:9000; }
# deny access to .htaccess files, if Apache's document root # concurs with nginx's one # #location ~ /\.ht { # deny all; #}
# dokuwikiのデータディレクトリへのアクセスを禁止する location ~ ^/(data|conf|bin|inc|vendor)/ { deny all; }}ファイルの所有者、パーミッションを変更する
Section titled “ファイルの所有者、パーミッションを変更する”DokuWikiにはアップデート用プラグインが存在するので、/var/www/html全体を書き込み可能にします。
アップデート用プラグインを使わない場合はdataディレクトリとconfディレクトリを書き込み可能に設定します。
install.phpにアクセスしてインストールを完了
