This is a discussion on Re: [PHP] mkdir permission errors within the PHP General forums, part of the PHP Programming Forums category; Wei, Alice J. wrote: > Hi, Rob: > > I forgot to mention that I have been using yum install. &...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Wei, Alice J. wrote:
> Hi, Rob: > > I forgot to mention that I have been using yum install. > I have reinstalled the entire thing, put back all the packages, and then I went to /var and did a chmod -R 777 var, and then did a > > [root@localhost var]# chown -R apache:apache . > > Interestingly, I do not see anything different, and I still get this error that says my permission is denied. Here is my > > [root@localhost var]# ps awxu | grep -E 'apache|httpd' > root 31547 0.0 0.3 21268 6584 ? Ss 16:12 0:00 /usr/sbin/httpd > apache 31549 0.0 0.2 21400 5572 ? S 16:12 0:00 /usr/sbin/httpd > apache 31550 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd > apache 31551 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd > apache 31552 0.0 0.2 21400 4896 ? S 16:12 0:00 /usr/sbin/httpd > apache 31553 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd > apache 31554 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd > apache 31555 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd > apache 31556 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd > root 31708 0.0 0.0 4120 728 pts/1 R+ 16:30 0:00 grep -E apache|httpd > > Obviously, my last one has already changed the owner to apache already.Nevertheless, I am still denied even when I am now logged in as root. Is this anything with firewalls? > Hang on a minute: you're original message said the error was: Warning: chmod() [function.chmod]: Permission denied in /usr/local/apache/htdocs/file_linux.php on line 27 But you say you've re-installed, and done "chmod -R 777 var" and "chown -R apache:apache ." in /var A few things there: When you are changing permissions and ownerships on such a large scale, you should always use absolute paths to be sure you are doing the right thing - like "chmod -R 777 /var" and "chown -R apache:apache /var" Next, changing permission and ownership recursively on something like /var is likely to wreck your system in weird and wonderful ways, and is pretty difficult to undo - you might be looking at a total OS reinstall here (once you've solved your Apache problems) Finally, the error message refers to a file in /usr/local/apache/htdocs, but you then are changing permissions in /var - where is your web root?! It looks like your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web files are actually in /var/something... -- Peter Ford phone: 01580 893333 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent |
|
|||
|
Wei, Alice J. wrote:
> > -----Original Message----- > From: Peter Ford [mailto:pete@justcroft.com] > Sent: Tuesday, July 15, 2008 4:06 AM > To: php-general@lists.php.net > Subject: Re: [php] mkdir permission errors > > Wei, Alice J. wrote: >> Hi, Rob: >> >> I forgot to mention that I have been using yum install. >> I have reinstalled the entire thing, put back all the packages, and then I went to /var and did a chmod -R 777 var, and then did a >> >> [root@localhost var]# chown -R apache:apache . >> >> Interestingly, I do not see anything different, and I still get this error that says my permission is denied. Here is my >> >> [root@localhost var]# ps awxu | grep -E 'apache|httpd' >> root 31547 0.0 0.3 21268 6584 ? Ss 16:12 0:00 /usr/sbin/httpd >> apache 31549 0.0 0.2 21400 5572 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31550 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31551 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31552 0.0 0.2 21400 4896 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31553 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31554 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31555 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >> apache 31556 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >> root 31708 0.0 0.0 4120 728 pts/1 R+ 16:30 0:00 grep -E apache|httpd >> >> Obviously, my last one has already changed the owner to apache already.Nevertheless, I am still denied even when I am now logged in as root. Is this anything with firewalls? >> > > Hang on a minute: you're original message said the error was: > > Warning: chmod() [function.chmod]: Permission denied in > /usr/local/apache/htdocs/file_linux.php on line 27 > > But you say you've re-installed, and done "chmod -R 777 var" and "chown -R > apache:apache ." in /var > > A few things there: > When you are changing permissions and ownerships on such a large scale, you > should always use absolute paths to be sure you are doing the right thing - like > "chmod -R 777 /var" and "chown -R apache:apache /var" > > Next, changing permission and ownership recursively on something like /var is > likely to wreck your system in weird and wonderful ways, and is pretty difficult > to undo - you might be looking at a total OS reinstall here (once you've solved > your Apache problems) > > Finally, the error message refers to a file in /usr/local/apache/htdocs, but you > then are changing permissions in /var - where is your web root?! It looks like > your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web > files are actually in /var/something... > > I forgot to mention that I use Fedora on a Linux machine. I used yum install apache and yum install php to install my packages. Therefore, I don't have a /usr/local/apache/htdocs folder. The web root is now /var/www/html, which originally I do have /usr/local/apache/htdocs that I configured during previous installations. This is not there anymore after my reinstallations since yesterday. > > Do I really have to reinstall the entire Fedora? I hate to say that my scripts worked fine BEFORE yesterday until the power went out and nothing went right after I have restarted the entire system. > > Alice > You don't *have* to reinstall Fedora (yet) - that was just a warning that changing ownership and permissions on /var might cause some problems later... So the question is, does the error message say that it cannot change permissions on /usr/local/apache/htdocs/file_linux.php or /var/www/html/file_linux.php ? And does your PHP script have the correct path? The original problem may just have been that the /usr/local file system was mounted read-only after the power outage (perhaps due to some disk corruption caused by the failure?). Since then you have reinstalled apache, but possibly not in the place your PHP script expects it to be. That would be my first thing to check... -- Peter Ford, Developer phone: 01580 893333 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS |
|
|||
|
Wei, Alice J. wrote:
> From: Peter Ford [pete@justcroft.com] > Sent: Tuesday, July 15, 2008 7:28 AM > To: Wei, Alice J. > Cc: php-general@lists.php.net > Subject: Re: [php] mkdir permission errors > > Wei, Alice J. wrote: >> -----Original Message----- >> From: Peter Ford [mailto:pete@justcroft.com] >> Sent: Tuesday, July 15, 2008 4:06 AM >> To: php-general@lists.php.net >> Subject: Re: [php] mkdir permission errors >> >> Wei, Alice J. wrote: >>> Hi, Rob: >>> >>> I forgot to mention that I have been using yum install. >>> I have reinstalled the entire thing, put back all the packages, and then I went to /var and did a chmod -R 777 var, and then did a >>> >>> [root@localhost var]# chown -R apache:apache . >>> >>> Interestingly, I do not see anything different, and I still get this error that says my permission is denied. Here is my >>> >>> [root@localhost var]# ps awxu | grep -E 'apache|httpd' >>> root 31547 0.0 0.3 21268 6584 ? Ss 16:12 0:00 /usr/sbin/httpd >>> apache 31549 0.0 0.2 21400 5572 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31550 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31551 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31552 0.0 0.2 21400 4896 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31553 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31554 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31555 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31556 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> root 31708 0.0 0.0 4120 728 pts/1 R+ 16:30 0:00 grep -E apache|httpd >>> >>> Obviously, my last one has already changed the owner to apache already.Nevertheless, I am still denied even when I am now logged in as root. Is this anything with firewalls? >>> >> Hang on a minute: you're original message said the error was: >> >> Warning: chmod() [function.chmod]: Permission denied in >> /usr/local/apache/htdocs/file_linux.php on line 27 >> >> But you say you've re-installed, and done "chmod -R 777 var" and "chown -R >> apache:apache ." in /var >> >> A few things there: >> When you are changing permissions and ownerships on such a large scale, you >> should always use absolute paths to be sure you are doing the right thing - like >> "chmod -R 777 /var" and "chown -R apache:apache /var" >> >> Next, changing permission and ownership recursively on something like /var is >> likely to wreck your system in weird and wonderful ways, and is pretty difficult >> to undo - you might be looking at a total OS reinstall here (once you've solved >> your Apache problems) >> >> Finally, the error message refers to a file in /usr/local/apache/htdocs, but you >> then are changing permissions in /var - where is your web root?! It looks like >> your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web >> files are actually in /var/something... >> >> I forgot to mention that I use Fedora on a Linux machine. I used yum install apache and yum install php to install my packages. Therefore, I don't have a /usr/local/apache/htdocs folder. The web root is now /var/www/html, which originally I do have /usr/local/apache/htdocs that I configured during previous installations. This is not there anymore after my reinstallations since yesterday. >> >> Do I really have to reinstall the entire Fedora? I hate to say that my scripts worked fine BEFORE yesterday until the power went out and nothing went right after I have restarted the entire system. >> >> Alice >> > > You don't *have* to reinstall Fedora (yet) - that was just a warning that > changing ownership and permissions on /var might cause some problems later... > > So the question is, does the error message say that it cannot change permissions on > /usr/local/apache/htdocs/file_linux.php > or > /var/www/html/file_linux.php > ? > > This portion is to answer Rob's question: > > [root@localhost var]# ls -la > total 92 > drwxrwxrwx 22 root root 4096 2008-06-24 08:34 . > drwxr-xr-x 21 root root 4096 2008-07-14 08:17 .. > drwxrwxrwx 2 root root 4096 2008-06-24 08:25 account > drwxrwxrwx 13 root root 4096 2008-07-14 16:07 cache > drwxrwxrwx 2 root root 4096 2008-02-19 20:47 cvs > drwxrwxrwx 3 root root 4096 2008-06-24 08:25 db > drwxrwxrwx 3 root root 4096 2008-06-24 08:29 empty > drwxrwxrwx 2 root root 4096 2008-04-07 17:44 games > drwxrwxrwx 2 root root 4096 2008-05-01 22:45 gdm > drwxrwxrwx 35 root root 4096 2008-07-14 16:07 lib > drwxrwxrwx 2 root root 4096 2008-04-07 17:44 local > drwxrwxrwx 5 root root 4096 2008-07-15 04:10 lock > drwxrwxrwx 17 root root 4096 2008-07-15 04:10 log > lrwxrwxrwx 1 root root 10 2008-06-24 08:24 mail -> spool/mail > drwxrwxrwx 6 root root 4096 2008-06-24 08:26 named > drwxrwxrwx 2 root root 4096 2008-04-07 17:44 nis > drwxrwxrwx 2 root root 4096 2008-04-07 17:44 opt > drwxrwxrwx 2 root root 4096 2008-04-07 17:44 preserve > drwxrwxrwx 27 root root 4096 2008-07-14 16:12 run > drwxrwxrwx 13 root root 4096 2008-06-24 08:35 spool > drwxrwxrwx 2 root root 4096 2008-07-14 16:10 tmp > drwxrwxrwx 8 root root 4096 2008-07-14 16:07 www > drwxrwxrwx 3 root root 4096 2008-06-24 08:29 yp > > And does your PHP script have the correct path? > > This is the latest error I got: > > Warning: mkdir() [function.mkdir]: Permission denied in /var/www/html/file_linux.php on line 15 > Cannot create directory > > The original problem may just have been that the /usr/local file system was > mounted read-only after the power outage (perhaps due to some disk corruption > caused by the failure?). > > I have thought about that, and have restarted Apache that time, but somehow that did not work. I am not sure if that had been the right procedures of what I took. > > Since then you have reinstalled apache, but possibly > not in the place your PHP script expects it to be. That would be my first thing > to check... > > It appears to me that when I opened up the page with phpinfo(), it does display the accurate information. But from what you said here, are there other things I must do to check if it is working as it is? > > Thanks in advance. > ================================================== ==== > Alice Wei > MIS 2009 > School of Library and Information Science > Indiana University Bloomington > ajwei@indiana.edu > ________________________________________ I'm being a bit of an idiot, but I realised that the path in the error message is NOT the path being created, but the path of the script. Back to your first post - you posted some PHP which included something like: mkdir("/usr/local/apache/htdocs/test/$id", 0777) or die ("<p>Cannot create directory</p>"); The questions are these: is your /var/www/html/file_linux.php script trying to create /usr/local/apache/htdocs/test/$id ? And does the directory /usr/local/apache/htdocs/test/ exist on your server? -- Peter Ford phone: 01580 893333 Developer fax: 01580 893399 Justcroft International Ltd., Staplehurst, Kent |
|
|||
|
Wei, Alice J. wrote:
> ________________________________________ > From: Peter Ford [pete@justcroft.com] > Sent: Tuesday, July 15, 2008 7:28 AM > To: Wei, Alice J. > Cc: php-general@lists.php.net > Subject: Re: [php] mkdir permission errors > > Wei, Alice J. wrote: >> -----Original Message----- >> From: Peter Ford [mailto:pete@justcroft.com] >> Sent: Tuesday, July 15, 2008 4:06 AM >> To: php-general@lists.php.net >> Subject: Re: [php] mkdir permission errors >> >> Wei, Alice J. wrote: >>> Hi, Rob: >>> >>> I forgot to mention that I have been using yum install. >>> I have reinstalled the entire thing, put back all the packages, and then I went to /var and did a chmod -R 777 var, and then did a >>> >>> [root@localhost var]# chown -R apache:apache . >>> >>> Interestingly, I do not see anything different, and I still get this error that says my permission is denied. Here is my >>> >>> [root@localhost var]# ps awxu | grep -E 'apache|httpd' >>> root 31547 0.0 0.3 21268 6584 ? Ss 16:12 0:00 /usr/sbin/httpd >>> apache 31549 0.0 0.2 21400 5572 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31550 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31551 0.0 0.2 21400 4908 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31552 0.0 0.2 21400 4896 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31553 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31554 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31555 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> apache 31556 0.0 0.2 21268 4860 ? S 16:12 0:00 /usr/sbin/httpd >>> root 31708 0.0 0.0 4120 728 pts/1 R+ 16:30 0:00 grep -E apache|httpd >>> >>> Obviously, my last one has already changed the owner to apache already.Nevertheless, I am still denied even when I am now logged in as root. Is this anything with firewalls? >>> >> Hang on a minute: you're original message said the error was: >> >> Warning: chmod() [function.chmod]: Permission denied in >> /usr/local/apache/htdocs/file_linux.php on line 27 >> >> But you say you've re-installed, and done "chmod -R 777 var" and "chown -R >> apache:apache ." in /var >> >> A few things there: >> When you are changing permissions and ownerships on such a large scale, you >> should always use absolute paths to be sure you are doing the right thing - like >> "chmod -R 777 /var" and "chown -R apache:apache /var" >> >> Next, changing permission and ownership recursively on something like /var is >> likely to wreck your system in weird and wonderful ways, and is pretty difficult >> to undo - you might be looking at a total OS reinstall here (once you've solved >> your Apache problems) >> >> Finally, the error message refers to a file in /usr/local/apache/htdocs, but you >> then are changing permissions in /var - where is your web root?! It looks like >> your PHP code has the /usr/local/apache/htdocs path hard-coded, when your web >> files are actually in /var/something... >> >> I forgot to mention that I use Fedora on a Linux machine. I used yum install apache and yum install php to install my packages. Therefore, I don't have a /usr/local/apache/htdocs folder. The web root is now /var/www/html, which originally I do have /usr/local/apache/htdocs that I configured during previous installations. This is not there anymore after my reinstallations since yesterday. >> >> Do I really have to reinstall the entire Fedora? I hate to say that my scripts worked fine BEFORE yesterday until the power went out and nothing went right after I have restarted the entire system. >> >> Alice >> > > You don't *have* to reinstall Fedora (yet) - that was just a warning that > changing ownership and permissions on /var might cause some problems later... > > So the question is, does the error message say that it cannot change permissions on > /usr/local/apache/htdocs/file_linux.php > or > /var/www/html/file_linux.php > ? > > And does your PHP script have the correct path? > > The original problem may just have been that the /usr/local file system was > mounted read-only after the power outage (perhaps due to some disk corruption > caused by the failure?). Since then you have reinstalled apache, but possibly > not in the place your PHP script expects it to be. That would be my first thing > to check... > > This sounds really dumb, but it turned out that I have some inconsistencies going on in my httpd.conf file. Now I have changed both groups to daemon, and changed to owners as Rob suggested. Now it is finally working fine. Would I still need to change everything back to 0755? Or, should I ask, what is the appropriate permission I should be using here? > > Alice At least that explains why the problem arose from a power failure: you had some new settings in the configuration which needed an apache restart to make them happen, and when the server rebooted, apache picked up the new settings... The problem is that if you did "chmod -R 777 /var", you changed every file /var and ALL of its subdirectories to have 777 permissions, and there's not an easy way of knowing what the permissions were on all of those files and directories. While your system will probably work happily with everything in /var world-writeable, it's not very safe (in a security sense). If you also did something like "chown -R apache:apache /var" then you have lost the ownership settings of all those files too, again with no easy way of undoing that. In that case, setting ownership to 755 really will break things, because then anything not running as apache will not be able to write to /var ! Some programs check the ownership and file permissions of the files they use, and will refuse to work if they are wrong or insecure - that might be a problem if your machine is used for more than just a PHP development server. That's why I said you might need to re-install the OS. Of course, you could always just restore /var from your system backup ;) For now, I think that 777 permissions will probably be OK, but keep an eye out for hackers... -- Peter Ford, Developer phone: 01580 893333 fax: 01580 893399 Justcroft International Ltd. www.justcroft.com Justcroft House, High Street, Staplehurst, Kent TN12 0AH United Kingdom Registered in England and Wales: 2297906 Registered office: Stag Gates House, 63/64 The Avenue, Southampton SO17 1XS |
|
|||
|
On Tue, Jul 15, 2008 at 7:05 AM, Wei, Alice J. <ajwei@indiana.edu> wrote:
> > Do I really have to reinstall the entire Fedora? You may be a prime candidate for Windows. -- </Daniel P. Brown> Dedicated Servers - Intel 2.4GHz w/2TB bandwidth/mo. starting at just $59.99/mo. with no contract! Dedicated servers, VPS, and hosting from $2.50/mo. |