Why? Solution

Source: Internet
Author: User
Why? PHPcodefunctiondelDir ($ dir) {$ arr = getcTime ($ dir); asort ($ arr); // $ arr = array ('file name' = & gt; 'creation time') why?
PHP code
  Function delDir ($ dir) {$ arr = getcTime ($ dir); asort ($ arr ); // $ arr = array ('file name' => 'creation time'); // getDirSize ($ dir) is the function for obtaining the folder size based on the folder directory foreach ($ arr as $ key => $ value) {$ size = getDirSize ($ dir); if ($ size> 2048) {unlink ($ key) ;}else {break ;}}}


In win, it is OK. However, the following error occurs in linux.
Warning: unlink (/usr/local/lamp/test/2. text) [function. unlink]: Permission denied in/usr/local/lamp/apache2/htdocs/test. php on line 112
I checked on the Internet, and some said it was a permission issue, but I set the permission for the test folder to 777 ,,,
What are the reasons for this? It really hurts...


------ Solution --------------------
Use is_writable to check the permissions before unlink.

PHP may only use the user name (usually 'nobody') for running webserver to access the file.
------ Solution --------------------
Discussion

Reference:

Do you want to delete files other than the website?

No. this is just a test file to delete the log file.

------ Solution --------------------
Discussion

Reference:

Reference:

Reference:

Standard answer

Cut

2. the text permission is not correct. you can allocate xx to this file to the apache operation...


The account for running apache is root. Permission:-rwxrwxrwx root
I'm sure and sure ......


... The zookeeper of apache is root ?? So painful ......

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.