I have a problem with linking my external storage to my PHP home directory.
I'm using Litespeed web server on Linux Centos 6 and everything work normally in my user home directory.
But I want to create a load balancer between my 2 hard drives for serving better in peak times.
I use configs below in httpd.conf to creating an alias and it works well when I'm trying to download files directly like https://example.com/cdn/file.mp4
Alias /cdn/ "/cdn/files/"
<Directory "/cdn/files">
Options Indexes MultiViews
AllowOverride All
Require all granted
Allow from all
</Directory>
But if I try to use the path in php scripts for example check file_exists seems that I can't.
I set my home user and group in external directories.
Any idea ?!
Update 1 : I tried symbolinks from home dir to external dir and still no result.
Update 2 : my simple php code :
<?php
if(file_exists('/cdn/files/file.mp4') || file_exists('/cdn/file.mp4') || file_exists('./cdn/file.mp4') || file_exists('./~cdn/file.mp4')){
echo "yes";
}else{
echo "no";
}
?>
result : no
The problem was in php.ini open_basedir value. I must append the full path to the new disk in open_basedir value.
Also add open_basedir value in httpd.conf file like below:
<Directory "/home/user/public_html">
php_admin_value open_basedir /home/user/public_html/:/cdn/files
</Directory>
<VirtualHost myip:80>
<Directory "/home/user/public_html">
php_admin_value open_basedir /home/user/public_html/:/cdn/files
</Directory>
</VirtualHost>
<VirtualHost myip:443>
<Directory "/home/user/public_html">
php_admin_value open_basedir /home/user/public_html/:/cdn/files
</Directory>
</VirtualHost>
I hope this be useful for someone :)