N
N
Nubzilo2014-12-05 19:13:54
linux
Nubzilo, 2014-12-05 19:13:54

How to give php script access to another directory?

Good afternoon. I am not familiar with linux systems at all.
There is a vps, it uses apache (httpd) and php.
The httpd and php configuration is standard, web access is on /var/www/html, there is also a test.php file
. There is also another directory and file in the system:
/home/test/text.txt
What needs to be done to make the test script. php could access test.txt? Google did not help, but I do not rule out that I was looking for the wrong queries.
All my attempts end up like this:

Warning: scandir(/home/test/): failed to open dir: Permission denied in /var/www/html/test.php on line 6

Warning: scandir(): (errno 13): Permission denied in /var/www/html/test.php on line 6

Answer the question

In order to leave comments, you need to log in

2 answer(s)
Y
yarofon, 2014-12-05
@yarofon

chmod -R 777 /home/test/
is not the best way, but I think it's the best in your case

D
Dmitry Spirin, 2014-12-07
@MipH

To get to the contents of /home/test/ the php script needs to be able to traverse through /home/ (traverse a directory). To do this, you need to insert an execute bit (chmod ..+x) on /home (but not a read bit, which would allow you to read the directory).
Next, you need to set the appropriate rights to the /home/test folder itself (you can use 777 for simplicity, i.e. chmod -R 777 /home/test).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question