View Full Version : Cant save PHP files
cobbweb
February 24th, 2006, 08:22 AM
Hey,
I am trying to save php files in my "www" folder (i installed apache) but every time i do, it say's that there was an error and it "could not save the file"
Im really confused on why it would do this. Im saving it as a php file. Im very new to php but have done a lot of Java programming so have I know about program structs but have a hard time with data base stuf (thus the reason im trying to learn php and mysql) Is there a setting off? or im... really not sure. Thanks any help is wanted...
Cobbweb
suRoot
February 24th, 2006, 08:39 AM
Can you save the file elsewhere?
Sounds like a permissions problem to me.
Try saving the file to your home directory & then moving it
sudo mv /home/foo/foo.php /path/to/www
nemik
February 24th, 2006, 08:40 AM
chmod the folder so you can write to it.
cobbweb
February 24th, 2006, 08:56 AM
should i do a 755?
chmod 755 www
or is there a diffrent one i should do...
cobbweb
February 24th, 2006, 09:01 AM
Can you save the file elsewhere?
Sounds like a permissions problem to me.
Try saving the file to your home directory & then moving it
sudo mv /home/foo/foo.php /path/to/www
Works great, but do i have to move the files into the folder like that every time????
Kurt`
February 24th, 2006, 11:09 AM
Try this command:
ls -alFh /path/to/folder/where/www/is
and you should see something like this:
drwxr-xr-x 5 root root 1.3K 2006-02-23 02:32 htdocs/
And now for a quick lesson on linux file permissions ;)
chmod works like this:
chmod (-R) xyz files/folder
(-R is used to apply the new permissions recursively, so be careful with it.)
The xyz works like this:
x = owner's permission
y = the group's permission
z = everyone else's permission
And the values work like this:
4 = read
2 = write
1 = execute (probably won't be necessary)
By combining those 3 numbers, you can determine what chmod values to use for a particular folder. For example, if I wanted to make everything inside my htdocs folder readable, writable, and executable for everyone, I could do this:
chmod -R 777 htdocs
If I want only root (keep in mind, root still owns the folder, use `chown` to change ownership) to be able to write, and only people in the root group to be able to read, I would do this:
chmod -R 640 htdocs
and everyone else gets denied. ;)
Hopefully, that should clear up any confusion.
mtron
February 24th, 2006, 12:41 PM
it's best to use the www-data group for this. make your user a member of this group and you will have write access, if you set the foler ownerships right.
cobbweb
February 26th, 2006, 08:59 AM
Try this command:
and you should see something like this:
And now for a quick lesson on linux file permissions ;)
chmod works like this:
(-R is used to apply the new permissions recursively, so be careful with it.)
The xyz works like this:
x = owner's permission
y = the group's permission
z = everyone else's permission
And the values work like this:
4 = read
2 = write
1 = execute (probably won't be necessary)
By combining those 3 numbers, you can determine what chmod values to use for a particular folder. For example, if I wanted to make everything inside my htdocs folder readable, writable, and executable for everyone, I could do this:
If I want only root (keep in mind, root still owns the folder, use `chown` to change ownership) to be able to write, and only people in the root group to be able to read, I would do this:
and everyone else gets denied. ;)
Hopefully, that should clear up any confusion.
Wow! Very Helpfull thank you soo much.
Cobbweb
cobbweb
February 27th, 2006, 12:12 AM
it's best to use the www-data group for this. make your user a member of this group and you will have write access, if you set the foler ownerships right.
How would i use this method? The other one is great, but I keep getting this error.
Operation is not permitted
mtron
February 27th, 2006, 05:29 PM
How would i use this method?
You can use System->Administration->Users and Groups to create groups and give add user account to group, OR you can edit /etc/group file and add you username after the group (on the same line) - you should probably use pre-existing group www-data.
As a root you can do
chgrp -R www-data /var/www/*
to change all the files and directories under /var/www/ to www-data group (except files starting with dot) and then
chmod -R g+rw /var/www/*
to give www-data group read and write permissions to all files and directories.
Now if your user belongs to group www-data, you can directly copy or save stuff to /var/www (default apache webroot on debian like systems).
You should also make sure that the files are owned by username www-data which is the username apache is run by default. (you can check your apache.conf of apache2.conf for lines like:
User www-data
Group www-data
Powered by vBulletin® Version 4.2.2 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.