SitePoint Sponsor

User Tag List

Results 1 to 12 of 12
  1. #1
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PHP won't download file outside homedir

    Hi guys,

    I am on a Plesk server and trying to get PHP to download a file outside the home dir, i.e. /var/www/vhosts/mydomain.com/downloads

    Any ideas on how I can enable this on Plesk?

  2. #2
    SitePoint Zealot Servyces's Avatar
    Join Date
    Jun 2007
    Location
    The Netherlands
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you specify the full path to the download in your script? And do you get any kind of error?
    Servyces.com
    Where itís all about you.
    Your partner in online solutions.
    Visit our website at http://www.servyces.com/

  3. #3
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    You might need to add the path to the open_basedir restriction. Its a few years since I worked with Plesk before, but I seem to remember that I had to do that last time myself.

  4. #4
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    You might need to add the path to the open_basedir restriction. Its a few years since I worked with Plesk before, but I seem to remember that I had to do that last time myself.
    Yes I supplied the full path. Here is my VirtualHost for the domain, how can I add an exception?

    Code:
    <VirtualHost 64.67.105.211:80>
    	ServerName   mydomain.com:80
    	ServerAlias  www.mydomain.com
    	UseCanonicalName Off
    	SuexecUserGroup         myuser psacln
    	ServerAdmin  "me@mydomain.com"
    	DocumentRoot /var/www/vhosts/mydomain.com/httpdocs
    	CustomLog  /var/www/vhosts/mydomain.com/statistics/logs/access_log plesklog
    	ErrorLog  /var/www/vhosts/mydomain.com/statistics/logs/error_log
    <IfModule mod_userdir.c>
    	UserDir /var/www/vhosts/mydomain.com/web_users
    </IfModule>
    	ScriptAlias  /cgi-bin/ /var/www/vhosts/mydomain.com/cgi-bin/
    	<IfModule mod_ssl.c>
    		SSLEngine off
    	</IfModule>
    	<Directory /var/www/vhosts/mydomain.com/httpdocs>
    	<IfModule mod_perl.c>
    	<Files ~ (\.pl$)>
    		SetHandler perl-script
    		PerlHandler ModPerl::Registry
    		Options ExecCGI
    		allow from all
    		PerlSendHeader On
    	</Files>
    	</IfModule>
    	<IfModule sapi_apache2.c>
    		php_admin_flag engine on
    		php_admin_flag safe_mode off
    		php_admin_value open_basedir "/var/www/vhosts/mydomain.com/httpdocs:/tmp"
    	</IfModule>
    	<IfModule mod_php5.c>
    		php_admin_flag engine on
    		php_admin_flag safe_mode off
    		php_admin_value open_basedir "/var/www/vhosts/mydomain.com/httpdocs:/tmp"
    	</IfModule>
    	<IfModule mod_fcgid.c>
    		<Files ~ (\.fcgi)>
    			SetHandler fcgid-script
    			Options +FollowSymLinks +ExecCGI
    		</Files>
    	</IfModule>
    		Options -Includes +ExecCGI
    	</Directory>
    	<Directory /var/www/vhosts/mydomain.com/web_users>
    	<IfModule sapi_apache2.c>
    		php_admin_flag engine off
    	</IfModule>
    	<IfModule mod_php5.c>
    		php_admin_flag engine off
    	</IfModule>
    	</Directory>
    </VirtualHost>

  5. #5
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    You will need to add the path, look for open_basedir to find out where.

    Change:
    php_admin_value open_basedir "/var/www/vhosts/mydomain.com/httpdocs:/tmp"

    Into:
    php_admin_value open_basedir "/var/www/vhosts/mydomain.com/downloads/:var/www/vhosts/mydomain.com/httpdocs:/tmp"

    Remember to change it on all places for that account. The best solution is to set this up in config files outside the main httpd.conf file. I know Plesk automatically look for config files in specific folders, but I cant remember what they were. You can try to google "Plesk and open_basedir restrictions" and see if you can find that information from there.

  6. #6
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    You will need to add the path, look for open_basedir to find out where.

    Change:
    php_admin_value open_basedir "/var/www/vhosts/mydomain.com/httpdocs:/tmp"

    Into:
    php_admin_value open_basedir "/var/www/vhosts/mydomain.com/downloads/:var/www/vhosts/mydomain.com/httpdocs:/tmp"

    Remember to change it on all places for that account. The best solution is to set this up in config files outside the main httpd.conf file. I know Plesk automatically look for config files in specific folders, but I cant remember what they were. You can try to google "Plesk and open_basedir restrictions" and see if you can find that information from there.
    I just tried adding those lines in httpd.include but it does not seem to be the problem. When I place the ZIP (download) file in the httpdocs directory, it works. I checked the error logs and there is nothing there!

  7. #7
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Did you restart the apache server after you added it? As the basepath restriction is where your issue is located.

    If not try that:
    httpd restart

  8. #8
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by TheRedDevil View Post
    Did you restart the apache server after you added it? As the basepath restriction is where your issue is located.

    If not try that:
    httpd restart
    Yes I reloaded Apache after each change.

  9. #9
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks, sorted it now, the file was owned by the wrong group.

  10. #10
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Most probably the file you added it into is wrong I guess, though you should try to find someone that use Plesk, we only use Cpanel these days so I am not able to help you any further.

    You can take a look on some of the articles here on how to edit the open_basedir on plesk:
    http://www.google.no/search?client=o...utf-8&oe=utf-8

    Good luck

  11. #11
    SitePoint Wizard TheRedDevil's Avatar
    Join Date
    Sep 2004
    Location
    Norway
    Posts
    1,198
    Mentioned
    4 Post(s)
    Tagged
    1 Thread(s)
    Ah, the file was manually uploaded. Makes sense, did not even consider that one.

    Glad you got it working.

  12. #12
    SitePoint Wizard Zaggs's Avatar
    Join Date
    Feb 2005
    Posts
    1,051
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep :-) Thanks for your help anyway!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •