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
    • 最新
    • 标签
主页 / user-833061

Kl3m Michard's questions

Martin Hope
Kl3m Michard
Asked: 2021-09-16 05:25:33 +0800 CST

浏览器下载文件而不是打开 php 文件

  • 0

所以,我发布了一个答案,因为在两次全新安装之后,我设置了一个但不同的东西(以我的观点)。就像我上面说的那样,我面临着两难境地,因为我所拥有的配置与我能找到的任何其他答案都不相同。例如 :

我的 /etc/nginx 文件夹基本构成如下:

|- /etc/nginx/
|  |- conf.d/
|  |  |- default.conf
|  |
|  |- fastcgi_params
|  |- mime.types
|  |- modules/ -> /usr/lib/nginx/modules
|  |- nginx.conf
|  |- scgi_params
|  |- uwsgi_params

没有 /sites-available 或 /sites-enabled 随处可见,提到的 fastcgi-php.conf 实际上是根文件夹中的 fastcgi_params,因此我的默认值不在 site-available 文件夹中。

这是我现在拥有的两个配置文件(域隐藏在 my_domain.com 下):首先:nginx.conf(几乎未触及)

    user  nginx;

worker_processes  auto;

error_log  /var/log/nginx/error.log notice;

pid        /var/run/nginx.pid;


events {
    worker_connections  1024;

}

http {
    include       /etc/nginx/mime.types;
    include       /etc/nginx/sites-available/*.conf;
    default_type  application/octet-stream;


    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';



    access_log  /var/log/nginx/access.log  main;
    sendfile        on;
    #tcp_nopush     on;
    keepalive_timeout  65;
    #gzip  on;
    include /etc/nginx/conf.d/*.conf;

}

其次 /etc/nginx/conf.d/default.conf

    server {
    listen       80;
    server_name  my_domain.com www.my_domain.com;

    location / {
        root /var/www/www.my_domain.com;
        index  index.php index.html index.htm;
    }

    #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   /var/www/www.my_domain.com;
    }

    # 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$ {
        fastcgi_split_path_info ^(.+?\.php)(/.*)$;
        #if (!-f $document_root$fastcgi_script_name) {
        #    return 404;
        #}
        root           /var/www/www.my_domain.com;
    #    fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        include        fastcgi_params;
        fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
    }
    

}

我还加了一行

text/php            php;

对于 mime.types,我还记得在我使用的浏览器(Firefox、Opera 和 Chrome)中删除 my_domain 的缓存。

但是,文件仍然被下载。

我做错了什么 ?

编辑:因为我想创建一个 blog.my_domain.com、shop.my_domain.com 和 forum._mydomain.com,所以我创建了 /site-available 和 /site-enabled 文件夹,打算创建一个 blog/forum/shop .my_domain.com.conf 在位于 /sites-available 中的每个同名文件夹中,但我正在等待一个工作配置以使它们在 nginx.conf 中可见(带有包含行,对吗?)。

所以我真的不明白这两个文件夹是如何工作的。子域的 CNAME 记录设置为 my_domain.com。我还阅读了有关为这些子网站制作符号链接的信息,但我真的不知道从哪里到哪里?再次感谢

错误日志告诉我与 /var/run/php/ 的连接被拒绝。默认用户是 www-data www-data,但我的默认 nginx 用户是 nginx(如果我更改它,它甚至不会启动。)我应该做一个

chown nginx:nginx /var/run/php/

?

users nginx phpmyadmin chown
  • 2 个回答
  • 944 Views

Sidebar

Stats

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

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

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

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve