Windows下nginx+php構成
3554 ワード
1.まず、nginx.confのPHP構成コメントを削除します.
2.ここで使用するPHPはcgi形式であるため、php-cgiを有効にするphpを修正する.ini、コメントを削除します.
3.php-cgiとnginxの起動
プロセスの中で、nginxとphp-cgiがあれば、成功する差は多くありません.最後に、「No input file specified」の問題が発生する可能性があるので、nginxを修正します.conf :
注記の場所に注意して、次の行に変更して、あなたの具体的なファイルに基づいてパスを構成してください.
D:/nginx/htmlでphpinfoファイルを編集し、localhost/phpinfoを実行する.phpでいい
現代の簡明な魔法
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
include fastcgi_params;
}
2.ここで使用するPHPはcgi形式であるため、php-cgiを有効にするphpを修正する.ini、コメントを削除します.
;cgi.fix_pathinfo=1
cgi.fix_pathinfo=1
3.php-cgiとnginxの起動
php
D:/xampp/php/php-cgi.exe -b 127.0.0.1:9000 -c D:/xampp/php/php.ini
nginx
D:/nginx/start nginx
プロセスの中で、nginxとphp-cgiがあれば、成功する差は多くありません.最後に、「No input file specified」の問題が発生する可能性があるので、nginxを修正します.conf :
location ~ \.php$ {
#root html;
root D:/nginx/html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
#fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
#fastcgi_param SCRIPT_FILENAME D:/nginx/html$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
注記の場所に注意して、次の行に変更して、あなたの具体的なファイルに基づいてパスを構成してください.
D:/nginx/htmlでphpinfoファイルを編集し、localhost/phpinfoを実行する.phpでいい
現代の簡明な魔法