• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 329
  • Last Modified:

PHP & HTTPD

Linux FC2

The second script following this one suddenly stopped working so I thought I should start fixing at number one.

This number one gives the following errors:
~/httpd/access_log
192.168.1.13 - - [22/Mar/2005:20:41:27 +0800] "GET /var/nobla/u1/h123.css HTTP/1.1" 404 299 "http://192.168.1.13/open_session.php" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040922"

~/httpd/error_log
[Tue Mar 22 20:41:27 2005] [error] [client 192.168.1.13] File does not exist: /home/meeting/chair/var, referer: http://192.168.1.13/open_session.php

The first error seems to be a path problem to the file, it affects only presentation.
Can anyone point to me what I am doing wrong?

The second error has got me confused, I've got no idea since there is no file named "var" that is called in the script, only a directory (ref: error 1)
Can anyone explain, give me a solution?

Here is the number one script:
# open_session.php
<?  session_start(); ?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html><head><title>Open Session</title>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<link rel=stylesheet type="text/css" href="/var/nobla/u1/h123.css">
</head>
<body class="wp2cpng">
<table class="tabl01"><tr><td width="100%">
<form method="post">1) Click here
<input type="text" name="date"></form><br>

<?php
if (isset($_POST['date'])) {
 $date = ($_POST['date']);
 $filename1 = "agenda/session_agenda" . $date;
 $_SESSION['filename1'] = $filename1;      # save it
 echo "Session date = Day: ";
 ?><b><font color="red"><?
 echo substr($filename1,25,2);
 ?></b></font><?
 echo " &nbsp; Month: ";
 ?><b><font color="red"><?
 echo substr($filename1,23,2);
 ?></b></font><?
 echo " &nbsp; Year: ";
 ?><b><font color="red"><?
 echo "20",substr($filename1,21,2);
 ?></b></font><?
 echo "<br>";
 if (file_exists($filename1)) {
  echo "<form method='post' action='select_element.php'><select size='8' name='selected'>";
  $agenda = file("$filename1");
  $_SESSION['agenda'] = $agenda;
  foreach($agenda as $lineNumber => $lineStr) {
       echo "<option>$lineStr</option>";
  }
    echo "</select><br><br>";
    echo "<input type='submit' name='submit' value='Continue '></form>";
 }
  else   {
  echo "No file found for the date entered<br><br>";
  }
}
?>
</td></tr></table></body></html>

Thank you for your help.
0
rblampain
Asked:
rblampain
  • 2
1 Solution
 
craigwardmanCommented:
just to confirm,

link rel=stylesheet type="text/css" href="/var/nobla/u1/h123.css">

the /var folder is in your disk root, not website root, if you want it to start from website root, remove the preceding /

link rel=stylesheet type="text/css" href="var/nobla/u1/h123.css">

That may help with 404 error if the file is under the website directory :)
0
 
rblampainAuthor Commented:
Thanks to  craigwardman
The file is not under the website root, it is under the disk root.
The "documentroot" in HTTPD is "/home/meeting/chair" and a script from this directory is trying to read the file "/var/nobla/u1/h123.css" ("/var/nobla" was created at installation time).  

Apache is trying to read "/home/meeting/chair/var/nobla/u1/h123.css" how can I make it read "/var/nobla/u1/h123.css"?  
0
 
craigwardmanCommented:
I think you would be best to alias this folder somewhere within the documentroot or to create a symbolic link.. as i doubt Apache will be able to access files outside of documentroot for security reasons..

to create a symlink, use this command from bash$:

ln -s /var/nobla/u1 /home/meeting/chair

This will create a symbolic link to the u1 folder giving access to its files from the /home/meeting/chair documentroot..

(you may need to play around with the file/folder attributes of this directory to get fully working)
(i.e chmod 755 /var/nobla/u1)

In your httpd.conf file, you must make sure to have this directive for Options:

<Directory />
    Options FollowSymLinks          <---
    AllowOverride None
</Directory>


Another way to do it, with a folder alias, would be as follows, in httpd.conf:

Alias /var/nobla/u1/ "/var/nobla/u1/"

<Directory "/var/nobla/u1/">
    Options Indexes
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>

this forwards all requests for documentroot/var/nobla/u1 to the actual directory /var/nobla/u1


but i would personally use the symlink :)

Hope this is helpful !


0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now