loko
Posts: 35
Joined: Tue Sep 24, 2013 9:57 am

Copy files to /var/www

Thu Oct 17, 2013 7:42 am

I cant manage to copy my php files to my apache /var/www . It says something like:
not enough permission to perform this action
I have no experience with apache and almolst no experience with the raspberry pi.

What should I do to be able to copy my files to the directory?

SirLagz
Posts: 1705
Joined: Mon Feb 20, 2012 8:53 am
Location: Perth, Australia
Contact: Website

Re: Copy files to /var/www

Thu Oct 17, 2013 7:48 am

either chown /var/www to 777 to allow everyone to copy it, or use sudo to copy the files over.
My Blog - http://www.sirlagz.net
Visit my blog for Tips, Tricks, Guides and More !
WiFi Issues ? Have a look at this post ! http://www.raspberrypi.org/phpBB3/viewtopic.php?f=28&t=44044

loko
Posts: 35
Joined: Tue Sep 24, 2013 9:57 am

Re: Copy files to /var/www

Thu Oct 17, 2013 8:36 am

SirLagz wrote:either chown /var/www to 777 to allow everyone to copy it, or use sudo to copy the files over.
Chown? How do I chown? What is chown?

User avatar
joan
Posts: 14985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Copy files to /var/www

Thu Oct 17, 2013 8:39 am

What is x?

man x

User avatar
RaTTuS
Posts: 10565
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Copy files to /var/www

Thu Oct 17, 2013 8:40 am

man chown
but
sudo cp files /var/www
is prossibly what you need
though
ls -l /var/www
and make sure the ownership and permissions remain the same

sudo chown group:user files
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

loko
Posts: 35
Joined: Tue Sep 24, 2013 9:57 am

Re: Copy files to /var/www

Thu Oct 17, 2013 8:44 am

RaTTuS wrote:man chown
but
sudo cp files /var/www
is prossibly what you need
though
ls -l /var/www
and make sure the ownership and permissions remain the same

sudo chown group:user files
Almost no experience with Linux either, but how does sudo cp files work? where in the command do I tell what file to place in /var/www? For example if I have test.php. How do I copy it to /var/www with that command?

User avatar
joan
Posts: 14985
Joined: Thu Jul 05, 2012 5:09 pm
Location: UK

Re: Copy files to /var/www

Thu Oct 17, 2013 8:47 am

man sudo
man cp

User avatar
RaTTuS
Posts: 10565
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Copy files to /var/www

Thu Oct 17, 2013 8:58 am

http://www.hypexr.org/bash_tutorial.php
may help
but
sudo cp test.php /var/www
also see
man sudo
man cp
man man
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

texy
Forum Moderator
Forum Moderator
Posts: 5160
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Copy files to /var/www

Thu Oct 17, 2013 12:56 pm

....dont forget that you will to 'cd' to the directory of where test.php resides before you can 'cp' it.

Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

User avatar
rpdom
Posts: 17402
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Copy files to /var/www

Thu Oct 17, 2013 1:33 pm

Another option is to add your user to the group www-data which has write permissions to /var/www. You'll need to log out and in again to trigger the change.

lazarus78
Posts: 236
Joined: Thu Jul 25, 2013 5:16 pm

Re: Copy files to /var/www

Thu Oct 17, 2013 6:55 pm

joan wrote:man sudo
man cp
That isn't really helpful. From my personal experience, the man pages are lackluster at best, and only really help if you understand what is even going on. This is the "Biginners" forum, and chances are there are kids snooping around for information. I duno about you, but when I was younder, if someone said something like what you did, I would be confused and ask, or completely disregard you all together because you provide no information. You are just redirecting.

While in most cases, it may seem wasteful to reinvent the wheel, and parrot the same information over and over, however, sometimes it is very beneficial. I find it so frustrating when Im trying to find information and most people's replies are vague, lacking in any sort of detail, and assume professional knowledge. I may know what you mean by "man sudo" and "man cp", but others may not. How are they to know those are commands to manuals on the given command if you don't at least say they are?

Honestly, if you are just going to post things like this, then please, don't bother. At least not in this forum where people are here to learn something they may know nothing about. For me, I took interest in the Raspberry Pi because it was cheap, and I had just taken a linux class in school, so I thought it would be fun to mess around with, and in fact, I am being paid to work with Raspberrys in an effort to reclaim some PCs that are being used to power TVs displaying reports. I have come to these "Biginner" froums many times seeking help and information, and have received several posts like yours. And did they help me? No. They confused me more and forced me to seek help and information elsewhere.

/rant

Sorry about all that folks... Just one of those moods.
loko wrote: Almost no experience with Linux either, but how does sudo cp files work? where in the command do I tell what file to place in /var/www? For example if I have test.php. How do I copy it to /var/www with that command?
That is the command used to copy files, but executed with root, or sudo, privileges.

The command "cp" is used to copy files. If you have a files located in "/home/TacoMan/files/MyFile.txt", and you want to move it to "/home/NachoLover/files", you would use the command as follows.

Code: Select all

cp /home/TacoMan/files/MyFile.txt /home/NachoLover/files
The basic setup of the command is "cp [WhereTheFileIs] [WhereYouWantTheCopy]".

The command "sudo" is used to run another command as though you are root. If, for example, you want to copy a file like in the example above, but you do not have permissions with the destination directory, you would add "sudo" to the beginning of the command, like so:

Code: Select all

sudo cp /home/TacoMan/files/MyFile.txt /home/NachoLover/files
That is a basic rundown of what joan was trying to say.

yvonnezoe
Posts: 127
Joined: Thu Feb 14, 2013 2:10 am
Contact: Website

Re: Copy files to /var/www

Sun Mar 16, 2014 3:49 pm

sudo chown -R pi /var/www
Just started my Raspberry Pi journey >> http://yvonnezoe.wordpress.com

drifterf
Posts: 140
Joined: Sat Dec 08, 2018 9:09 am
Location: Northants, England

Re: Copy files to /var/www

Thu Jan 10, 2019 6:54 pm

yvonnezoe wrote:
Sun Mar 16, 2014 3:49 pm
sudo chown -R pi /var/www
solved my problem, thanks !!

jahboater
Posts: 5924
Joined: Wed Feb 04, 2015 6:38 pm
Location: West Dorset

Re: Copy files to /var/www

Thu Jan 10, 2019 7:24 pm

lazarus78 wrote:
Thu Oct 17, 2013 6:55 pm
If you have a files located in "/home/TacoMan/files/MyFile.txt", and you want to move it to "/home/NachoLover/files", you would use the command as follows.
Actually, to move a file, I would use mv (see "man mv").

The man pages are fine:-

cp - copy files and directories
sudo, sudoedit -- execute a command as another user

Some of the options are complicated it is true.

They cover almost everything on the system. Be thankful they are there.

The important thing is not these particular commands, but that the user learns how to find things out for the future.
Pointing people to the man pages or the help is great.

When I worked on a help desk many decades ago, I sometimes used to pretend I didn't know the answer and then go through the process of finding out in front of the user. More helpful in the long run.

User avatar
RaTTuS
Posts: 10565
Joined: Tue Nov 29, 2011 11:12 am
Location: North West UK
Contact: Twitter YouTube

Re: Copy files to /var/www

Fri Jan 11, 2019 8:26 am

drifterf wrote:
Thu Jan 10, 2019 6:54 pm
yvonnezoe wrote:
Sun Mar 16, 2014 3:49 pm
sudo chown -R pi /var/www
solved my problem, thanks !!
necro post ..
this will make the webserver probably not safe and bork
How To ask Questions :- http://www.catb.org/esr/faqs/smart-questions.html
WARNING - some parts of this post may be erroneous YMMV

1QC43qbL5FySu2Pi51vGqKqxy3UiJgukSX
Covfefe

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Copy files to /var/www

Fri Jan 11, 2019 9:00 am

Strictly speaking, the default DocumentRoot is /var/www/html/ instead though isn't it?

As for the permissions, think about privilege separation and least privilege in regards to the file system access by both the people using the server and the HTTP/HTTPS daemon. The people need read and write access to documents, the daemons need read-only access except in special, advanced use-cases.

For single-user systems, setting the web server's document root ownership to the user's account is the safe way and correct way to provide read and write access to the files being published, assuming o=r for files and o=rx for directories. The web server thus retains read-only access and the user account has read-write access. Write access by the web server should be avoided except in advanced use-cases where the sysadmin / developer really knows what is going on. For web servers with multiple people logging in on separate accounts, some tricks with groups are necessary to grant write access to the document root in consistent and amicable manner.

Speaking of granting write access, the advice about 777 or www-data are both incorrect and unsafe. The 777 permissions would be unsafe because it would grant write access to all system processes including the web server. Putting the user into the group www-data would do the same once write permssions are granted to www-data, and thus also be unsafe.

Perhaps the default ownership for the nginx and Apache2 packages could set /var/www/html/ to user "pi" and group "pi". Or else if there are relevant tutorials and guides, these should have the right permissions.

User avatar
rpdom
Posts: 17402
Joined: Sun May 06, 2012 5:17 am
Location: Chelmsford, Essex, UK

Re: Copy files to /var/www

Fri Jan 11, 2019 10:14 am

tpyo kingg wrote:
Fri Jan 11, 2019 9:00 am
Strictly speaking, the default DocumentRoot is /var/www/html/ instead though isn't it?
It is now.

In earlier versions of Raspbian/Debian it was /var/www.

tpyo kingg
Posts: 809
Joined: Mon Apr 09, 2018 5:26 pm
Location: N. Finland

Re: Copy files to /var/www

Fri Jan 11, 2019 12:18 pm

How embarassing, I seem to have misread the 3 as an 8. Can old threads be locked after a time?

Return to “Beginners”