繁体   English   中英

在 apache 服务器的 /var/www 中找不到.php 文件

[英]Could not find .php file in /var/www in apache server

我正在使用 Vagrant 提供程序作为服务器,现在看看我的目录:

在我的系统中:

https://i.stack.imgur.com/XCXIm.png

流浪者网站
-项目(/var/www)
--public (/var/www/html)
---index.php

now I created a sample.php file in Project folder then when I run vagrant and logged in vagrant ssh when I cd to /var/www,that.php file doesn't exist there and I could not work with

include __DIR__ . '/../count.html.php';

这行代码不起作用,因为该文件在 /var/www 中不存在,但在我的系统中存在

该 index.php 文件它的工作没有问题,但我想在公共目录之外创建一个 php 文件,只有我自己可以访问它,现在当我在项目文件夹中创建该文件时,现在这个文件必须在 / var/www and when I use include command in my php code, php can not found that, I used file_exists() function and gave the path of php file function, now the function returned false then I check /var/www directory to check那个php文件存在与否,不存在!

如果您发现它无法工作,那么您是否尝试在 /etc/php/7.x/php.ini 中配置 php.ini? 或者尝试在您的 web 服务器中启用 php 作为 Apache 或 Z62E0B5B350C9E43D2C19AA80 到工作它?

请查找这些日志并找出失败的地方。

跟我们多说些:)

我解决了问题,
在同步文件夹配置部分的 vagrant 文件中,我发现我可以添加更多目录,所以我同步:./Project 到 /var/www 但请记住,同步后它会改变,这个目录:/var/www/html,那个html 文件夹内 apache2 它将删除并替换为您的公共目录名称(在您的设备内,对我来说它是 public )公共目录文件夹,现在您需要更改此路径中 000-default.conf 文件中的根目录地址: /etc/apache2/sites-available/000-default.conf 更改后重启 apache2 服务

DocumentRoot /var/www/html change this => /var/www/your public directory name  

sudo service apache2 restart

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM