首页 > 解决方案 > Apache2 或 Nginx 在 Fedora 30 上遇到 PHP 问题

问题描述

我想在本地 Fedora 30 上设置 PHP 服务器。我已经安装了 php7.0-fpm。因此,当运行命令 PHP -S localhost:8800 时,它会在此端口上运行文件夹。

现在我安装了 Apache2 并启动了服务器,所以在 localhost:80 中它工作正常。当我尝试将 PHP 文件放在 /var/www/html/ 文件夹中时,它会回显未执行 PHP 文件的代码。喜欢

<?php echo "Test"; ?>

所以我尝试安装 Nginx,当我使用 Nginx 运行 PHP 文件时,它正在下载文件 PHP 文件。

我已按照说明单击它尚未解决。

我想在 Fedora 30 上使用 Apache2 或 Nginx 运行 PHP。谁能帮我解决这个问题?

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    # SSL configuration
    #
    # listen 443 ssl default_server;
    # listen [::]:443 ssl default_server;
    #
    # Note: You should disable gzip for SSL traffic.
    # See: https://bugs.debian.org/773332
    #
    # Read up on ssl_ciphers to ensure a secure configuration.
    # See: https://bugs.debian.org/765782
    #
    # Self signed certs generated by the ssl-cert package
    # Don't use them in a production server!
    #
    # include snippets/snakeoil.conf;

    root /var/www/html;

    # Add index.php to the list if you are using PHP
    index  index.html index.htm index.nginx-debian.html;

    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;
    }

    # pass PHP scripts to FastCGI server
    #
    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_split_path_info ^(.+\.php)(/.+)$;
    #       # With php-fpm (or other unix sockets):
            fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
    # With php-cgi (or other tcp sockets):
    #       fastcgi_pass 127.0.0.1:9000;
    #}

}

标签: phpnginxserverapache2

解决方案


推荐阅读