前提
- Ubuntu
- PHP7.4
- Composerをインストール済み
- nginxの起動ユーザはwww-data
- rootユーザ実行
php-fpmのインストールと設定
インストール
apt-get update
apt-get install php7.4-fpm
以下の設定を書き込む。
/etc/php/7.4/fpm/pool.d/www.conf
user = www-data
group = www-data
listen = /run/php/php7.4-fpm.sock
その後再起動
自動起動と再起動
systemctl enable php7.4-fpm.service
systemctl start php7.4-fpm.service
nginxのインストールと設定
インストール
apt-get update
apt-get install php7.4-fpm
設定ファイルを修正
/etc/nginx/nginx.conf
user www-data;
worker_processes auto;
worker_rlimit_nofile 8192; # should be bigger than worker_connections
pid /run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
}
http {
include mime.types;
default_type application/octet-stream;
server {
listen 80;
root /var/www/grav;
index index.php index.html index.htm;
server_name libproc.com;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ [^/]\.php(/|$) {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
if (!-f $document_root$fastcgi_script_name) {
return 404;
}
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
}
}
}
自動起動と再起動
systemctl enable nginx.service
systemctl start nginx.service
Gravのインストール
composerでインストールを実行
composer create-project getgrav/grav /var/www/grav
これで最低限のGrav導入が完了。
Tips
- オススメのnginx.confについて
- SSL対応※ 後でやる
あと最後になりますが、よく考えたらGravで作った環境に書けば良かったと気づきました笑