簡體   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