nginxにphpを導入する
#備忘録 #nginx
結論
php fpmを入れる
php fpmのインストール
$ sudo apt install -y php-fpm
nginxのconfigファイルの設定
code:nginx
location ~ \.php$ {
fastcgi_pass unix:/run/php/php-fpm.sock;
# fastcgi_pass unix:/run/php/php7.4-fpm.sock; # 直接バージョン指定しても動く
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
error_page 403 404 =404 /404/index.html;
}
参考
https://qiita.com/Yuhkih/items/2b26f3761578637d0005
https://qiita.com/witchcraze/items/ab2ed43614cf9df13df1