下载 php 文件而不是执行 nginx

下载 php 文件而不是执行 nginx

我正在做一个学校作业的项目。我们必须制作一个带有 wordpress 的 Web 服务器。

我们必须更改一些东西,比如将 nginx 和 mariadb 的用户更改为 webuser 和 dbuser。这样我们就可以积累 Linux 方面的经验。

我需要在网络服务器上安装 wordpress,但是 php 文件无法在网站上执行。html 文件可以工作。

我已经在 Google 上搜索了一整天,还问过我的老师,但他说去 Google 上查,哈哈。

请帮忙。

这是 nginx 配置:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

user webuser;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

# Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
include /usr/share/nginx/modules/*.conf;

events {
    worker_connections 1024;
}

http {
    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;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 4096;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    # Load modular configuration files from the /etc/nginx/conf.d directory.
    # See http://nginx.org/en/docs/ngx_core_module.html#include
    # for more information.
    include /etc/nginx/conf.d/*.conf;

server {
        listen 80;
        server_name localhost;

        access_log /Website/logs/access.log;
        error_log /Website/logs/error.log;

location / {
        root /Website;
        index index.php index.html index.htm;

if (-f $request_filename) {
        expires 30d;
        break;
}

if (!-e $request_filename) {
        rewrite ^(.+)$ /index.php?q=$1 last;
        }
}

location ~ .php$ {
        fastcgi_pass   localhost:9000;  # port where FastCGI processes were spawned
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME   /Website/$fastcgi_script_name;  # same path as above
        fastcgi_param PATH_INFO               $fastcgi_script_name;
        include /etc/nginx/fastcgi_params;
        }
}
}

相关内容