nginx をテンプレートにして作成
[
トップ
] [
新規
|
一覧
|
検索
|
最終更新
|
ヘルプ
|
ログイン
]
開始行:
ほとんどの場面でapache httpdを使っているのだが、このnginx...
ここでは&color(lightseagreen){''CentOS 7''};でnginxを使う...
***インストール [#y6ee849f]
&color(lightseagreen){''CentOS 7''};提供のリポジトリで ng...
#code(nonumber){{
[root@c110 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@c110 ~]#
[root@c110 ~]# yum install epel-release
[root@c110 ~]# sed -i 's/enabled=1/enabled=0/' /etc/yum.r...
[root@c110 ~]# yum --enablerepo=epel install nginx
}}
***起動 [#z282dad6]
systemctlを使って起動させる
#code(nonumber){{
[root@c110 ~]# systemctl start nginx
[root@c110 ~]# systemctl enable nginx
}}
ブラウザでそのマシンにアクセスすると下図のように表記される
&ref(2017y05m21d_210601160.png,nolink);
この画面からコンテンツの場所は、''/usr/share/nginx/html''...
設定ファイルは''/etc/nginx/nginx.conf'' にあることが分かる
***php連携 [#c9bfede8]
apache httpdだとモジュールphp5_moduleを読み込んで同一http...
nginxはどうやらcgiとしてphpを動かすみたい(あるかもしれな...
まずはphp。php-fpm(php-FastCGI Process Manager)をインスト...
#code(nonumber){{
[root@c110 ~]# yum install php-fpm
}}
***php連携(設定) [#ff2ef7fb]
nginxとphpの連携はTCPソケットかUNIXソケットで行う。インス...
#code(diff,nonumber){{
[root@c110 ~]# diff -u /etc/php-fpm.d/www.conf.orig /etc/...
--- /etc/php-fpm.d/www.conf.orig 2016-11-06 09:32:...
+++ /etc/php-fpm.d/www.conf 2017-05-21 21:31:48.48623...
@@ -36,9 +36,9 @@
; Note: The user is mandatory. If the group is not set, ...
; will be used.
; RPM: apache Choosed to be able to access some dir as h...
-user = apache
+user = nginx
; RPM: Keep a group allowed to write in log dir.
-group = apache
+group = nginx
; Choose how the process manager will control the number...
; Possible Values:
[root@c110 ~]#
}}
そして、nginxへの設定
/etc/nginx/nginx.confの中へ追記する方法もあるのだが、「se...
用意されているので下記ファイルで設定を有効にさせた。
&color(red){*};&size(10){nginx.confを汚したくないので};
#code(nonumber){{
[root@c110 ~]# vi /etc/nginx/default.d/php-fpm.conf
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_s...
include fastcgi_params;
}
}}
***サービス再起動 [#d3f1bebe]
php-pfmのデーモンを起動させ、nginxを再起動させる
#code(nonumber){{
[root@c110 ~]# systemctl start php-fpm
[root@c110 ~]# systemctl enable php-fpm
[root@c110 ~]# systemctl restart nginx
}}
テストコンテンツを用意する。っと言っても簡単なものを。場...
#code(nonumber){{
[root@c110 ~]# vi /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
[root@c110 ~]#
}}
として、該当URLにアクセス
&ref(2017y05m21d_220541868.png,nolink);
一応動いた
終了行:
ほとんどの場面でapache httpdを使っているのだが、このnginx...
ここでは&color(lightseagreen){''CentOS 7''};でnginxを使う...
***インストール [#y6ee849f]
&color(lightseagreen){''CentOS 7''};提供のリポジトリで ng...
#code(nonumber){{
[root@c110 ~]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@c110 ~]#
[root@c110 ~]# yum install epel-release
[root@c110 ~]# sed -i 's/enabled=1/enabled=0/' /etc/yum.r...
[root@c110 ~]# yum --enablerepo=epel install nginx
}}
***起動 [#z282dad6]
systemctlを使って起動させる
#code(nonumber){{
[root@c110 ~]# systemctl start nginx
[root@c110 ~]# systemctl enable nginx
}}
ブラウザでそのマシンにアクセスすると下図のように表記される
&ref(2017y05m21d_210601160.png,nolink);
この画面からコンテンツの場所は、''/usr/share/nginx/html''...
設定ファイルは''/etc/nginx/nginx.conf'' にあることが分かる
***php連携 [#c9bfede8]
apache httpdだとモジュールphp5_moduleを読み込んで同一http...
nginxはどうやらcgiとしてphpを動かすみたい(あるかもしれな...
まずはphp。php-fpm(php-FastCGI Process Manager)をインスト...
#code(nonumber){{
[root@c110 ~]# yum install php-fpm
}}
***php連携(設定) [#ff2ef7fb]
nginxとphpの連携はTCPソケットかUNIXソケットで行う。インス...
#code(diff,nonumber){{
[root@c110 ~]# diff -u /etc/php-fpm.d/www.conf.orig /etc/...
--- /etc/php-fpm.d/www.conf.orig 2016-11-06 09:32:...
+++ /etc/php-fpm.d/www.conf 2017-05-21 21:31:48.48623...
@@ -36,9 +36,9 @@
; Note: The user is mandatory. If the group is not set, ...
; will be used.
; RPM: apache Choosed to be able to access some dir as h...
-user = apache
+user = nginx
; RPM: Keep a group allowed to write in log dir.
-group = apache
+group = nginx
; Choose how the process manager will control the number...
; Possible Values:
[root@c110 ~]#
}}
そして、nginxへの設定
/etc/nginx/nginx.confの中へ追記する方法もあるのだが、「se...
用意されているので下記ファイルで設定を有効にさせた。
&color(red){*};&size(10){nginx.confを汚したくないので};
#code(nonumber){{
[root@c110 ~]# vi /etc/nginx/default.d/php-fpm.conf
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_s...
include fastcgi_params;
}
}}
***サービス再起動 [#d3f1bebe]
php-pfmのデーモンを起動させ、nginxを再起動させる
#code(nonumber){{
[root@c110 ~]# systemctl start php-fpm
[root@c110 ~]# systemctl enable php-fpm
[root@c110 ~]# systemctl restart nginx
}}
テストコンテンツを用意する。っと言っても簡単なものを。場...
#code(nonumber){{
[root@c110 ~]# vi /usr/share/nginx/html/index.php
<?php
phpinfo();
?>
[root@c110 ~]#
}}
として、該当URLにアクセス
&ref(2017y05m21d_220541868.png,nolink);
一応動いた
ページ名:
1