Problem with symlink - forbidden.

Discussion in 'Installation/Configuration' started by Martinss, Jan 14, 2012.

  1. Martinss

    Martinss New Member

    Hello there! My problem is that i have a large hdd with my filesharing homepage and mounted it as

    Code:
    /home/lejup/hd1/www/
    but my domain name default www directory is

    Code:
    /var/www/clients/client0/web1/web/
    .

    So i deleted the "web" directory, and created a symlink like this

    Code:
    ln -s /home/lejup/hd1/www /var/www/clients/client0/web1/web
    but there is problem, now when i point to domain.ltd it shows up 403 Forbidden, also a subdomain img.domain.ltd shows the same. I changed chmod to 777 ford index.html files and also for thos directories, but nothing changed, where is the problem? :(
     
  2. Martinss

    Martinss New Member

    Also, i chmoded and chowned www-data and web* users to new symlink, but it still gets me forbidden error. :(
     
  3. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Do you have an index file (index.html, index.php, etc.) in /home/lejup/hd1/www/?
     
  4. Martinss

    Martinss New Member

    Yes i do, but it still shows me forbidden.
     
  5. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    Please post the exact error message from the error.log of the website. Beside that, which php mode do you use and is suexec enabled in that website?

    Instead of symlinking the directory, you can try to mount the harddiskpartition directly in the directory /var/www/clients/client0/web1/web
     
  6. Martinss

    Martinss New Member

    Error log shows me

    Code:
    [Sun Jan 15 16:10:20 2012] [error] [client 85.15.246.78] Symbolic link not allowed or link target not accessible: /var/www/domain.ltd/web/www
    [Sun Jan 15 16:10:20 2012] [error] [client 85.15.246.78] Symbolic link not allowed or link target not accessible: /var/www/domain.ltd/web/www
    
    Theres default setting for suexec - enabled, and for php is FastCGI, i guess? Nothing have been changed.

    also, mounted the hard drive to the /web/ and it gives me forbidden 403. It is chmoded as 777
     
    Last edited: Jan 15, 2012
  7. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    The above errors are from suexec as the symlink is a security violation for apache so that it denies access to this directory. Please post the new error message that you receive after removing the symlink and changing it back to be a directory and then using mount to mount the harddrive to the directory.

    That are too many permissions, that can cause problems as well.Please change the permissions of the web directory back to 710 and ensure that the web directory is owned by the user and group of the website,
     
  8. Martinss

    Martinss New Member

    mounted the hardrive as directory in web, put 710 permission to web directory, now i got a .htaccess error

    Code:
    [Sun Jan 15 16:45:00 2012] [crit] [client 78.84.*.*] (13)Permission denied: /var/www/domain.ltd/web/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable
    
    Created blank .htaccess file with 710 permissions and with web* user and client* group, still gives permission denied about htaccess
     
  9. Martinss

    Martinss New Member

    Problem solved. :) There was not right permissions for /web/ directory. Two days of downtime because of this, i lold. But it's normal for newbie. Anyways, big thanks for help falko and till. :)
     
  10. Martinss

    Martinss New Member

    Now i have some problem with PHP, what is different ir ISPconfig? I put php from fastcgi to mod-php and still nothing. The problem is that one script exits and nothing happens, looks like this:

    Code:
    <?
    include "config.php";
    
    if (!isset($HTTP_POST_FILES['userfile'])) exit;
    
    
    if (is_uploaded_file($HTTP_POST_FILES['userfile']['tmp_name'])) {
    
    if ($HTTP_POST_FILES['userfile']['size']>$max_size) {
            echo "<center><br><br><br>Fails ir parak liels, ludzu samazini to!</center>"; exit; }
    if(($HTTP_POST_FILES['userfile']['type']=="image/gif") || 
    ($HTTP_POST_FILES['userfile']['type']=="image/pjpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/jpeg") || ($HTTP_POST_FILES['userfile']['type']=="image/x-png") || ($HTTP_POST_FILES['userfile']['type']=="image/png")) {
    
            if (file_exists("./".$path . $HTTP_POST_FILES['userfile']['name'])) {
                    echo "<center><br><br><br>Bilde ar shadu nosaukumu jau eksistee! Nomaini nosaukumu un meegjini veelreiz!</center>"; exit; }
    
    //generate random number
    $zufall = time();
    $fupl = "$zufall";
    $nosaukums = $HTTP_POST_FILES['userfile']['name'];
    $ext = substr(strrchr($nosaukums, '.'), 1);
    $punkc = ".";
    if (file_exists("./".$path .$fupl .$punkc .$ext)) {
                    echo "<center><br><br><br>Bilde ar shadu nosaukumu jau eksistee! Nomaini nosaukumu un meegjini veelreiz!</center>"; exit; }
            $res = copy($HTTP_POST_FILES['userfile']['tmp_name'], "./".$path .$fupl .$punkc .$ext);
    		        
            if (!$res) { echo "<center><br><br><br>Bilde ar shadu nosaukumu jau eksistee! Nomaini nosaukumu un meegjini veelreiz!</center>"; exit; } else {
            ?>
    <br>
    
    <?
    //set url variable
    $domst = "";
    $drecks = "/";
    $imgf = $fupl.$punkc.$ext;
    $thbf = $tpath.$imgf;
    $urlf = $domst .$domain .$drecks .$path .$imgf;
    
    
    //create thumbnails
    function createthumb($name,$filename,$new_w,$new_h){
    	$system=explode('.',$name);
    	if (preg_match('/jpg|jpeg|JPG/',$system[1])){
    		$src_img=imagecreatefromjpeg($name);
    	}
    	if (preg_match('/png|PNG/',$system[1])){
    		$src_img=imagecreatefrompng($name);
    	}
    	if (preg_match('/gif|GIF/',$system[1])){
    		$src_img=imagecreatefromgif($name);
    	}
    
    $old_x=imageSX($src_img);
    $old_y=imageSY($src_img);
    if ($old_x > $old_y) {
    	$thumb_w=$new_w;
    	$thumb_h=$old_y*($new_h/$old_x);
    }
    if ($old_x < $old_y) {
    	$thumb_w=$old_x*($new_w/$old_y);
    	$thumb_h=$new_h;
    }
    if ($old_x == $old_y) {
    	$thumb_w=$new_w;
    	$thumb_h=$new_h;
    }
    
    $dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
    	imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 
    
    
    if (preg_match("/png/",$system[1]))
    {
    	imagepng($dst_img,$filename); 
    } 
    if (preg_match("/gif/",$system[1]))
    {
    	imagegif($dst_img,$filename);
    }
    else {
    	imagejpeg($dst_img,$filename); 
    }
    imagedestroy($dst_img); 
    imagedestroy($src_img); 
    }
    
    createthumb($path.$imgf,$tpath.$imgf,$tsize,$tsize);
    ?>
    
    
    
    <center>
    <div class="rezultats" id="agreement">
    <table border='0' >
    <link rel="STYLESHEET" type="text/css" href="style.css">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <FORM action="nowhere" method="post"><title>Attēlu augšupielāde</title>
    <center>
    <tr><td>BBkods ar mazbildi:</td><td><input type="text" name="thetext" size="60" value="[URL=<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>][IMG]<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>[/IMG][/URL]"></td></tr>
    <tr><td>BBkods ar pilna izmēra bildi:</td><td><input type="text" name="thetext" size="60" value="[URL=http://wwwdomain.ltd][IMG]<? echo $domst.$domain.$drecks.$path.$imgf; ?>[/IMG][/URL]"></td></tr>
    <tr><td>Saite:</td><td><input type="text" name="thetext" size="60" value='<? echo $domst .$domain .$drecks ?>viewer.php?id=<? echo $imgf; ?>'></td></tr>
    <tr><td>Tiešā saite:</td><td><input type="text" name="thetext" size="60" value="<? echo $urlf; ?>"></td></tr>
    <tr><td>HTML kods:</td><td><input type="text" name="thetext" size="60" value="<a href='<? echo $domst .$domain .$drecks; ?>viewer.php?id=<? echo $imgf; ?>'><img src='<? echo $domst.$domain.$drecks.$tpath.$imgf; ?>'></a>"></td></tr>
    
    <tr><td>Attēla mazbilde:</td><td>                 <img src='<? echo $thbf ?>'>               </td></br><a href="javascript:history.go(-1);" title="uz iepreiksejo lapu">Atpakaļ</a> </div></tr></td></tr>
    <?
    
    }
    } else { echo "<font color=\"#333333\" face=\"Geneva, Arial, Helvetica, sans-serif\"><link rel='stylesheet' href='style.css' type='text/css'><div class='support' id='agreement'><p><center>Šis ir nepareizs faila formāts!</font></center></div><br>\n"; exit; }
    }
    ?>
    </table>
    <br><br>
    </body>
    

    It just displays white page and thats all. :( Haven't modified anything in that script, just moved from old server to this new Ubuntu-Server 10.4 with ISPconfig 3. :(
     
  11. falko

    falko Super Moderator Howtoforge Staff Moderator HowtoForge Supporter ISPConfig Developer

    Does your PHP accept short open tags (<?)? If not, either use <?php or adjust your php.ini.
     
  12. Martinss

    Martinss New Member

    It accepts short tags, the problem was in that $HTTP_POST_FILES doesen't work, used $_FILES and all now is ok. :)
     
  13. till

    till Super Moderator Howtoforge Staff HowtoForge Supporter ISPConfig Developer

    These 'old style' arrays to access get/post/filecontents are disabled in latest PHP versions, they can be enabled in php.ini with the setting:

    register_long_arrays = On
     
  14. Martinss

    Martinss New Member

    Ok, thanks for info. :)
     

Share This Page