私はbrewによってインストールされたphp56とNginxでphpファイルを実行しようとしています。php56とNginx for OSXでphpファイルを実行するには?
brew install nginx brew install php56
だから、/usr/local/etc/nginx/nginx.conf
はここにあります。
worker_processes 1;
error_log /usr/local/var/log/nginx/error.log;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
server_name localhost;
listen 8080;
root /Users/kent/work;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
include servers/*;
}
私は、htmlファイルindex.html
とディレクトリ/Users/kent/work/html
を作ります。
<h1>this is my first file!</h1>
http://localhost:8080/html/index.html
で動作します。
そして、ディレクトリ/Users/kent/work/php
にPHPファイルindex.php
を作成します。
http://localhost:8080/php/index.php
で閲覧していません。 不思議なことに、index.phpファイルをダウンロードします。
ブラウザでphp情報を参照する必要があります。 何か間違っていますか?いくつかの提案をお願いしますか?
ご協力いただきありがとうございます。しかし、もし私がphp-fpm -vコマンドを実行すると、私のコンソールはPHP 5.6.23(fpm-fcgi)を返します(構築:Jul 24 2016 11:25:06)(DEBUG)Copyright(c)1997-2016 PHP Group Zend Engine v2.6.0、Copyright(c)1998-2016 Zend Technologies'。 php-fpmがインストールされていますが間違っています。 –
@KentFujii php-fpmが起動していてポート9000でリッスンしている場合は、 '$ lsof -Pni4 | grep LISTEN | grep php' –