problems with apache???

Problems with the Linux version of XAMPP, questions, comments, and anything related.

problems with apache???

Postby jesumartt » 02. June 2012 21:11

The Problem:

I take a picture with my webcam and recorded in the directory public/photos. When I check te file it is with zero bytes.
If I check yours permissions the owner is nobody and the group is nogroup but is have assigned read-only permissions.
The project root directory and its subdirectories has all permissions (chmod 777), with owner "root" y group "root"

The message I get is: "Failed to write data to photo.jpg, check permissions "

The path project is: /opt/lampp/htdocs/ProJardin

What should I do to make apache let me record the picture on the web application??
jesumartt
 
Posts: 2
Joined: 02. June 2012 17:27
Operating System: ubuntu 11.04

Re: problems with apache???

Postby JonB » 03. June 2012 15:30

The project root directory and its subdirectories has all permissions (chmod 777), with owner "root" y group "root"


I suspect the owner should be 'nobody'. And the permissions almost for sure should not be '777' (worldwriteable) probably 644 for a data or work folder.

This is a handy 'calculator' that also makes a lot of visual sense
http://www.onlineconversion.com/html_ch ... ulator.htm

A good tutorial -
http://www.perlfect.com/articles/chmod.shtml


The Apache 'worker' processes are what is probably doing the reading and writing in this case. Therefore the 'owner' of those processes needs to have the correct permissions. Although you can only START Apache as root, there are usually many httpd processes running, only the 'parent/listener' is owned by root. In order to make the webserver less vulnerable to attack, Apache creates (spawns) 'worker' children that have less rights ('root' is the superuser) to carry out the tasks.
try this command
Code: Select all
lsof -i | less

COMMAND    PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
systemd      1    root   24u  IPv6  12719      0t0  TCP *:ipp (LISTEN)
avahi-dae  666   avahi   12r  IPv4  15589      0t0  UDP *:mdns
avahi-dae  666   avahi   13u  IPv4  15743      0t0  UDP *:45205
chronyd    721  chrony    1u  IPv4  14895      0t0  UDP *:ntp
chronyd    721  chrony    2u  IPv6  14896      0t0  UDP *:ntp
chronyd    721  chrony    3u  IPv4  14897      0t0  UDP *:323
chronyd    721  chrony    5u  IPv6  14898      0t0  UDP *:323
rpcbind    808    root    7u  IPv4  16641      0t0  UDP *:sunrpc
rpcbind    808    root    8u  IPv4  16642      0t0  UDP *:983
rpcbind    808    root    9u  IPv4  16643      0t0  TCP *:sunrpc (LISTEN)
rpcbind    808    root   10u  IPv6  16644      0t0  UDP *:sunrpc
rpcbind    808    root   11u  IPv6  16645      0t0  UDP *:983
rpcbind    808    root   12u  IPv6  16646      0t0  TCP *:sunrpc (LISTEN)
dhclient   816    root    6u  IPv4  17337      0t0  UDP *:bootpc
dhclient   816    root   20u  IPv4  17296      0t0  UDP *:37786
dhclient   816    root   21u  IPv6  17297      0t0  UDP *:16037
rpc.statd  831 rpcuser    5r  IPv4  17334      0t0  UDP localhost.localdomain:1007
rpc.statd  831 rpcuser    8u  IPv4  17352      0t0  UDP *:56942
rpc.statd  831 rpcuser    9u  IPv4  17355      0t0  TCP *:55177 (LISTEN)
rpc.statd  831 rpcuser   10u  IPv6  17358      0t0  UDP *:37943
rpc.statd  831 rpcuser   11u  IPv6  17361      0t0  TCP *:35190 (LISTEN)
cupsd     1220    root    4u  IPv6  12719      0t0  TCP *:ipp (LISTEN)
cupsd     1220    root   12r  IPv4  19021      0t0  TCP localhost.localdomain:ipp (LISTEN)
cupsd     1220    root   13u  IPv4  19022      0t0  UDP *:ipp
httpd     1385    root    4u  IPv6  19261      0t0  TCP *:http (LISTEN)
httpd     1385    root    6u  IPv6  19269      0t0  TCP *:https (LISTEN)
httpd     1407  nobody    4u  IPv6  19261      0t0  TCP *:http (LISTEN)
httpd     1407  nobody    6u  IPv6  19269      0t0  TCP *:https (LISTEN)
:^z



Good Luck
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7

Re: problems with apache???

Postby jesumartt » 03. June 2012 18:14

I returned to install XAMPP following these steps:

1. login as root:
fernando@jesus-Satellite-A205:~$ sudo bash
2. Check the MD5 checksum of the download package right. Compare the result and is OK.
3.donwnload the package.
root@jesus-Satellite-A205:~# tar xvfz xampp-linux-1.7.7.tar.gz -C /opt
directory permissions opt/ and your owner y group is "root"
drwxr-xr-x 3 root root 4096 2012-06-02 16:52 opt
4.restart.
root@jesus-Satellite-A205:~# sudo reboot
5.proceed to check all the components.
fernando@jesus-Satellite-A205:~$ sudo bash
root@jesus-Satellite-A205:~# /opt/lampp/lampp start
All OK
6.change the "htdocs" directory owner "nobody - root"
root@jesus-Satellite-A205:~# chown -R fernando:fernando htdocs
7. I associate my username with Apache.
root@jesus-Satellite-A205:~# /opt/lampp/etc# pico httpd.conf
8. In httpd.conf.
User fernando
Group nogroup
9.restart.
root@jesus-Satellite-A205:~# /opt/lampp/lampp restart
All OK
10. I associate my username with phpmyadmin.
root@jesus-Satellite-A205:~# /opt/lampp/phpmyadmin# chown fernando:fernando config.inc.php
11. the directories is:
drwxr-xr-x 3 root root 4096 2012-06-02 16:52 opt
drwxr-xr-x 18 root root 4096 2011-09-19 11:33 lampp
drwxrwxrwx 5 fernando fernando 4096 2012-06-03 10:08 htdocs
drwxrwxrwx 9 fernando fernando 4096 2012-05-29 11:50 MyProject
drwxrwxrwx 2 fernando fernando 4096 2012-06-03 11:23 photo

Question???
1. Why get this error?
Failed to write data to "photo/myphoto.jpg", check permissions
jesumartt
 
Posts: 2
Joined: 02. June 2012 17:27
Operating System: ubuntu 11.04

Re: problems with apache???

Postby JonB » 04. June 2012 14:34

OK -

Here's the deal - I have suggested to you the 'xampp' approved permissions (what it was designed for). You now have the situation where there's more than one owner for the files in htdocs (a very bad idea in my opinion). I'm pretty sure it (your script) will work correctly with those original ownership and permission values.

You need to do what you want to do. You seem to think, based on your experience/research, that you need to associate your login user with Apache for some reason. That's OK with me, its your machine/setup. BUT I can't help you with that - AFAIK, I'm here to help people get XAMPP working as it comes from the box basically. If someone else wants, to fine. I have been 'doing' Apache for many years, and I have never set up a single system that way. Its always been either a global user 'Apache' + an Apache group, or when using a remote only headless server whomever the FTP login user is + a special group for Apache users. The developers of XAMPP/LAMPP have designed a bash script that is not a true stack, and 'lampp' therefore makes many assumptions along the way (including whom the owner of the files in /htdocs is).

If you want to set up Apache in some other fashion, I suggest you build a proper stack via an installer (yum, apt-get, etc). Those installations are much more amenable to manipulation, as all the components know what you are doing and why and will have the Apache defaults set -- and often will prevent you from creating problems for yourself.

Finally I will give you a hint about what your problem might be - see who the owner of the Apache processes are when you execute - the worker processes need to own the files. (kind of as I explained)

Good Luck with your project.
8)
User avatar
JonB
AF Moderator
 
Posts: 3210
Joined: 12. April 2010 16:41
Location: Land of the Blazing Sun
Operating System: Windows XP/7 - Fedora 15 1.7.7


Return to XAMPP for Linux

Who is online

Users browsing this forum: No registered users and 43 guests