- 追加された行はこの色です。
- 削除された行はこの色です。
#author("2017-03-30T14:37:30+09:00","default:wikiwriter","wikiwriter")
#author("2020-02-28T05:37:10+00:00","default:wikiwriter","wikiwriter")
&tag(Debian/Nginx);
*目次 [#b0ab99a4]
#contents
*関連ページ [#xecaf30d]
-[[Nginx]]…全般設定
*参考情報 [#g5147bc1]
-deb http://nginx.org/packages/debian/ jessie nginx
*インストール [#g2ba8b88]
-Debian 8公式だと1.6.2が最新版の模様。nginx公式リポジトリを使う。
-キーの追加
#pre{{
# wget http://nginx.org/keys/nginx_signing.key
# apt-key add nginx_signing.key
}}
-リポジトリを追加。/etc/apt/sources.list.d/nginx.listを編集。
#pre{{
deb http://nginx.org/packages/debian/ jessie nginx
deb-src http://nginx.org/packages/debian/ jessie nginx
}}
-インストール
apt-get install nginx
-2017/03/30(木)現在、1.10がインストールされた。
*設定 [#d9210c39]
**自動起動の設定 [#tedaf4bd]
-apacheが動いている場合はまず無効化
systemctl stop apache # だめな場合/etc/init.d/apache2 stop
systemctl disable apache
-以下で有効に
systemctl start nginx
systemctl enable nginx
**PHP-FPMを使う [#v3c004e7]
-[[../PHP]]の設定に従ってPHP-FPMをインストールしておく。
***PHP-FPM側の設定 [#z2fd7c96]
-/etc/php5/fpm/pool.d/www.confを編集し、www-dataをnginxに変更する
#pre{{
user = nginx
group = nginx
listen.owner = nginx
listen.group = nginx
}}
-unixソケットが/var/run/php5-fpm.sockであることにも注目。
ls -l /var/run/php5-fpm.sock
-再起動。
#pre{{
systemctl restart php5-fpm
}}
***Nginx側の設定 [#gad4779f]
-/etc/nginx/conf.d/default.confを編集し以下の設定を追加。
#pre{{
location ~ \.php$ {
root /usr/share/nginx/html;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}}
-再起動
systemctl restart nginx
-テストファイルを作成。/usr/share/nginx/html/index.phpを作成。
#pre{{
<?php
phpinfo();
?>
}}
-http://localhost/index.phpにアクセス。