facebook twitter hatena line email

Linux/nginx/php動作

提供: 初心者エンジニアの簡易メモ
2015年5月20日 (水) 11:53時点における36.55.238.17 (トーク)による版 (ページの作成:「==phpを動作させるには== php-fpmと連携する方法と、apacheからphpを実行する方法があります。 ここではphp-fpmを連携する方法を紹...」)

(差分) ←前の版 | 最新版 (差分) | 次の版→ (差分)
移動: 案内検索

phpを動作させるには

php-fpmと連携する方法と、apacheからphpを実行する方法があります。

ここではphp-fpmを連携する方法を紹介

php-fpmインストール

linux/phpインストール/php-fpm [ショートカット]

nginx設定変更

nginx.confに以下を追加

location ~ \.php$ {
     root /etc/nginx/html;
     fastcgi_pass   127.0.0.1:9000;
     fastcgi_index  index.php;
     fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
     include        fastcgi_params;
}
  • /etc/nginx/html/index.php
<?php
echo 'helloworld'; // helloworld

サーバ再起動

$ sudo /etc/init.d/nginx restart
$ sudo /etc/init.d/php-fpm restart