我在这个目录中有一个PHP文件:/home/ec2-user/folder/file.php
我设置了LAMP服务器。
我尝试了什么:
一个。更改/etc/httpd/conf/httpd.conf
我更改了DocumentRoot和目录,然后将覆盖更改为全部。以下是我所做的更改:
#DocumentRoot "/var/www/html"
DocumentRoot "/home/ec2-user/folder"
#<Directory "/var/www/html">
<Directory "/home/ec2-user/folder">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
# Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn't give it to you.
#
# The Options directive is both complicated and important. Please see
# http://httpd.apache.org/docs/2.2/mod/core.html#options
# for more information.
#
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
# Options FileInfo AuthConfig Limit
#
AllowOverride All
#
# Controls who can get stuff from this server.
#
Order allow,deny
Allow from all
</Directory>
但如果我致电<publicDNS>/file.php
,我会在服务器上找不到请求的网址。
B中。在serveExternal.php
文件夹中创建/var/www/html
文件。
内容是:
$fileName = $_GET['filename'];
echo $fileName; // shown correctly
$cwd = getcwd(); // get the current working directory
echo $cwd ; // prints the /var/www/html
chdir ("/home/ec2-user/folder/"); // Change directory to /home/bitnami/folder/
require_once($fileName); // include the required file
chdir ($cwd); // Change the directory to its original location
但是我的PHP文件永远不会被调用。
任何解决方案?
答案 0 :(得分:1)
您需要将DocumentRoot更改为文件位于此文件夹中的/ home / bitnami /文件夹,并将文档根目录设置为不同用户的目录,因此您无法访问这些文件。