Изменение корня документа Apache на AWS EC2 не работает

У меня есть файл PHP в этом каталоге: /home/ec2-user/folder/file.php и я настраиваю сервер LAMP.

Что я пробовал:

A. Изменение корня документа внутри /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 Я получаю запрошенный URL-адрес не найден на сервере.

Б. Создать 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-файл никогда не вызывается.

Какие-либо решения?

1

Решение

Вам нужно будет изменить папку DocumentRoot на / home / bitnami /, где ваши файлы находятся в этой папке, и вы устанавливаете корневой каталог документа в другой каталог пользователя, поэтому вы не можете получить доступ к этим файлам.

1

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector