我正在使用Ubuntu 13,我已经安装了nginx和php5-fpm;在此之前我安装了PHP5和apache;我删除了
/etc/php5/fpm/pool.d/www.conf
user = www-data
group = www-data
listen = /var/run/php5-fpm.sock
listen.owner = www-data
listen.group = www-data
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
nginx配置文件:
upstream php {
server unix:/var/run/php5-fpm.socket;
}
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /usr/share/nginx/html;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
# Uncomment to enable naxsi on this location
# include /etc/nginx/naxsi.rules
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
当我尝试
时它下载info.php文件而不是执行文件
但是当我尝试时:
显示phpinfo()
功能
问题出在哪里?
答案 0 :(得分:0)
您可以尝试更改一下配置:
server {
listen 80;
server_name localhost;
root /usr/share/nginx/html;
index index.html index.htm index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
//fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_pass localhost:9000;
fastcgi_index index.php;
include fastcgi_params;
}
}
和您的www.conf:
listen = localhost:9000
;listen = /var/run/php5-fpm.sock
答案 1 :(得分:0)
将行更改为server_name localhost local.host 127.0.0.1;
(您确定http://local(dot)host
不是拼写错误吗?)
检查/etc/hostnames
,如果它与上述不同,也请添加它。还要检查您是否没有另一个条目server{ ... }
条目来侦听同一个端口80.
检查文件夹/etc/nginx/sites-enabled/
,default
文件名还包含server{...}
个参数。 http{...}
块位于/etc/nginx/nginx.conf
,有时可能包含server{...}
块。