AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / ubuntu / 问题 / 507025
Accepted
k961
k961
Asked: 2014-08-05 22:32:53 +0800 CST2014-08-05 22:32:53 +0800 CST 2014-08-05 22:32:53 +0800 CST

nginx 和 php5-fpm 不工作

  • 772

在我到处搜索并测试所有内容但仍然无法正常工作之前,当我在浏览器中打开 localhost 时,我安装了 php5-fpm 和 nginx,我看到了这个页面:

欢迎使用 nginx!

所以它现在正在使用 nginx 配置 php5-fpm :

/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 conf:

  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
}

# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
#   proxy_pass http://127.0.0.1:8080;    
#}

#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 /usr/share/nginx/html;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
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;

}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#   allow all;
#}
}

问题是当我尝试运行 php 文件时,nginx 将下载 php 文件而不是执行它

php
  • 2 2 个回答
  • 26723 Views

2 个回答

  • Voted
  1. Best Answer
    LiveWireBT
    2014-08-09T07:28:50+08:002014-08-09T07:28:50+08:00

    PHP-FPM 套接字权限

    请检查套接字是否具有适当的权限。

    $ ll /var/run/php5-fpm.sock
    srw-rw---- 1 www-data www-data 0 Aug  6 14:16 /var/run/php5-fpm.sock=
    

    如果输出不同,可能会添加listen.mode = 0660到您的。www.conf

    可能相关:nginx error connect to php5-fpm.sock failed (13: Permission denied)

    nginx 配置

    1. 这真的是您的文件所在的位置吗?

      root /usr/share/nginx/html;
      index index.html index.htm index.php;
      
    2. 这个块应该做什么?

        upstream php {
              server unix:/var/run/php5-fpm.socket;
        }
      
    3. 我建议try_files $uri =404;从location ~ \.php$块中删除。

    4. 为什么 2 和 3 中的行缩进与其余行不同?请注意,这会影响正确的配置,但这给人的印象是它们被粗心地粘贴在一起。请提供指向您使用的说明的链接。

    • 4
  2. Mitesh Shah
    2014-08-09T02:32:55+08:002014-08-09T02:32:55+08:00

    您可以尝试EasyEngine,它可以使用单个命令设置网络服务器

    文档/维基:https ://github.com/rtCamp/easyengine/wiki

    如何设置:http ://www.unixmen.com/easyengine-auto-installer-script-managing-wordpress-nginx-websites-ubuntu-debian/

    • 0

相关问题

  • VirtualHost 的自定义 php.ini

  • http://localhost/ 不工作

  • 如何安装 php-gtk?

  • 我如何创建自己的 php 5.3.3 包/ppa?

  • 如何回滚到 PHP 5.2?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何运行 .sh 脚本?

    • 16 个回答
  • Marko Smith

    如何安装 .tar.gz(或 .tar.bz2)文件?

    • 14 个回答
  • Marko Smith

    如何列出所有已安装的软件包

    • 24 个回答
  • Marko Smith

    无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗?

    • 25 个回答
  • Martin Hope
    Flimm 如何在没有 sudo 的情况下使用 docker? 2014-06-07 00:17:43 +0800 CST
  • Martin Hope
    Ivan 如何列出所有已安装的软件包 2010-12-17 18:08:49 +0800 CST
  • Martin Hope
    La Ode Adam Saputra 无法锁定管理目录 (/var/lib/dpkg/) 是另一个进程在使用它吗? 2010-11-30 18:12:48 +0800 CST
  • Martin Hope
    David Barry 如何从命令行确定目录(文件夹)的总大小? 2010-08-06 10:20:23 +0800 CST
  • Martin Hope
    jfoucher “以下软件包已被保留:”为什么以及如何解决? 2010-08-01 13:59:22 +0800 CST
  • Martin Hope
    David Ashford 如何删除 PPA? 2010-07-30 01:09:42 +0800 CST

热门标签

10.10 10.04 gnome networking server command-line package-management software-recommendation sound xorg

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve