Jump to content

Access denied to /var/www/html [solved]


Recommended Posts

hi,

 

just installed mandriva le 2005 again after a long time and the install went quite well. i m quite new to linux scenario. i was trying to learn some php and came to know that i should be using the /var/www/html directory to store any files with php extension. after writing a file in the word processor and naming it test.php i tried to save the same file to the above said directory ie /var/www/html in order to see my first php page running in the browser, but when i was copying the file up came an error message 'Access denied could not write to /var/www/html' can amy one please help me with this? m i right in storing the php files in the direcotry mentioned above ie /var/www/html? thanks.

Link to comment
Share on other sites

Yes, you're right, for Mandriva the default web directory is /var/www/html so if you want to deliver pages from your web server, whether they're static html files or dynamic php files, they need to go in that directory or a subdirectory of it. A normal user hasn't got write access to this directory though, so you'll need to be root to write them there. One way to do this is to save them from your editor to somewhere in your home directory, and then from a console, after typing "su" and giving the root password, copy the files over to /var/www/html.

 

By the way, I'm not sure what you meant by "word processor" - but just in case you mean something like the OpenOffice word processor, I'd recommend you use a text editor like Kate or even better a special tool like Bluefish or Screem instead.

Link to comment
Share on other sites

If you still can't copy the file over, then either you're not really root (you typed in the wrong password) or you're trying to copy to a non-existent directory. Don't forget that you need the / at the beginning of the path /var/www/html, like this:

su
<enter root password>
cp test.php /var/www/html/

And obviously make sure you're in the directory where you saved your php file when you do that. If that doesn't work, post the error message here.

 

As for an editor to use, I made 3 recommendations above. If you have KDE, you already have kate (under More Applications->Editors->Kate in the menu); if you use Gnome you already have gedit. Try those out first. If you want something specially for web/html/php editing you can add it, eg Bluefish or Screem.

As scoonma says, you can use a word processor, but you have to be careful with which file type you save the file, and you don't get all the nifty helpful features that a text editor will give you.

Link to comment
Share on other sites

yes i did the same thing as u said.

 

first of all i used the kate application to write the code. and saved it as test.php on the desktop first.

 

then i logged in as su and entered the password and then entered the command to copy the thing and the copying has been done successfully. i as i can see the test.php there. now when i double click on this test.php file copied using the command in the /var/www/html/ folder, there comes a dialogue box asking open with and i m choosing Internet-Web Browsers-Mozilla Firefox and then click the OK button at the bottom of the box then mozilla firefox window opens up but comes with another dialog box saying 'you have chosen to open test.php which is a php script from /var/www/html/ what should firefox do with this file ? then i m again choosing the 1st option 'open with' which has two options kate and other and a new box opens with the heading 'choose helper application' i m getting insane here. please tell me what i m doing wrong. thanks.

Edited by tech291083
Link to comment
Share on other sites

Nonono,

You need to run your webserver and access the file through there. The web server is what is running the php stuff, so you must get the file via http. Double-clicking on the file won't run your web server.

 

Make sure your web server is running, and point your browser at http://localhost/test.php

 

<ShamelessOwnWebsitePlug>

You might find this page I wrote useful in getting started. It starts off with running the web server in Mandriva, and delivering html pages. Then it adds php.

</ShamelessOwnWebsitePlug>

Link to comment
Share on other sites

Neddie,

 

Thanks, thanks, thanks mate,

 

excellent. tutorial. very simple and inspiring for people like me who are completely new to linux stuff. please keep writing tutorials like this one and believe me it helps a lot. now my php pages are working well. thanks to you and rest of the guys who have shown a great deal of patience dealing with me. i was making a simple mistake of just double clicking the test.php page and expecting it to load in firefox. now i have realised the mistake. i m now working on getting the mysql thing started. i will get back to you if i have further problems. thanks again and keep writing the good tutorials. i have already mailed the link to more than 100+ friends and collegues of mine. hope they like it as well. bye for now.

Edited by tech291083
Link to comment
Share on other sites

Thanks for the feedback, glad you found it useful! mub-beer.gif

 

Just be careful about emailing so many people, because they won't all appreciate it! Thanks for the thought but emailing 100+ people is rarely a good idea. And I'd prefer it if my website didn't get on a blacklist of spammers ;)

Link to comment
Share on other sites

  • 1 month later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...