我正在制作一个带有联系表单的网站,我想使用 PHP。该网站使用 NGINX 托管在我简单的本地服务器上。我知道 NGINX 使用 FastCGI 和 PHP-FPM,但由于我是新手,我不确定如何配置所有内容以使其正常工作。这是我的 nginx.conf 文件中的内容:
server {
listen 7070;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root /Users/vibhusharma/Sites/JCA;
access_log "/Users/vibhusharma/Sites/JCA/jca_access.log";
error_log "/Users/vibhusharma/Sites/JCA/jca_errors.log";
index index.html index.htm;
try_files $uri $uri/ /index.html =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;
#fastcgi_buffers 256 128k;
#fastcgi_connect_timeout 300s; fastcgi_send_timeout 300s;
#fastcgi_read_timeout 300s;
#include fastcgi_params;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
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;
}
我还需要做什么才能让我的服务器解释我的 php 文件?谢谢!
答案1
您启用了 PHP 吗?显然 OS-X 默认不启用 PHP。或者可能没有安装。
http://jason.pureconcepts.net/2012/10/install-apache-php-mysql-mac-os-x/