php - 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;
#}
}
解决方案
推荐阅读
- c# - 如何为 ASP.Net core 3.1 应用程序创建测试视图框架
- r - R从数据帧创建一个不均匀的(7行6列)转换矩阵
- python - 使用 Beautiful Soup 从站点抓取数据时无法获取完整的 HTML
- python - Python matplotlib,删除线图中的间隙,其中数据仅存在于 xaxis 的部分
- mysql - 我想从 mysql 表中获取所有经过验证的用户名并在 res.json 中发送数据
- javascript - 对 V8 到底是什么感到困惑
- xamarin.ios - 创建发布版本时出现错误“解压缩文件时出错”
- html - 如何使此图像对移动设备具有响应性?
- arrays - 从动态变化的数组中发出值
- ruby - ruby 中的可执行文件