1

I have a PHP file in this directory : /home/ec2-user/folder/file.php and I setup the LAMP server.

What I tried:

A. Changing the document root inside the /etc/httpd/conf/httpd.conf

I changed the DocumentRoot and the Directory and I change the Override to All. Here is the changes I made:

#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>

But If I call <publicDNS>/file.php I get the requested URL was not found on the server.

B. Create a serveExternal.php file inside the /var/www/html folder.

Content is:

 $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

But then my PHP file is never called.

Any solutions?

ghostrider
  • 5,131
  • 14
  • 72
  • 120

1 Answers1

1

You will need to change the DocumentRoot to /home/bitnami/folder your files are in this folder and you are setting document root to different user's directory, so you are not able to access those files.

Yalamber
  • 7,360
  • 15
  • 63
  • 89