A Debug Project
ThinkPHP3.2 + PHP5.6 + Nginx1.8
Bug description
File upload error 404. the file cannot be found.
Debug process
"I upload files. why is it 404? Is the request link wrong ?"
Debugging
Operation: directly copy the link to the browser for access. Result: the status code is 200 OK.
"The link is okay. Is there a problem with the initialization tool class ?"
Debugging
Operation: in the tool class constructor, print data and terminate. Result: the value is still 404, which is irrelevant to the tool class.
"Is it a framework Bug ?"
Debugging
Operation: create a project and write an upload test file using native code. Result: the error code is still 404, which is irrelevant to the framework.
"Since it has nothing to do with the program, it is a problem with the server and PHP. Is there any PHP Upload control parameter that is disabled by default, and I didn't open it? It doesn't make sense. even if it is, it shouldn't prompt 404. it should be a server problem, but direct access to the link is valid. if it is 404 for uploading files, will it be a permission? This is the most likely thing. in linux, the permission control is very strict. to upload a file, you must convert it into a temporary file in a directory, and then use the copy function to move it to the specified directory to upload the file successfully, if the program does not have the upload permission for the temporary folder, it is entirely possible to report 404. The problem is where is the temporary file? Which file will be uploaded ?"
Debugging
Operation: google + baidu result: there is no desired content for all the things written.
"**, Do I need to flip files one by one? By the way, is there a log? First, check whether the server log has any information"
Debugging
Operation: Open the nginx log file and the result is: the/***/temp directory is clearly written. The permission is insufficient!
The rest is simple, and a permission statement is complete.
Conclusion: 1. when a bug occurs, you must first find out which part of the problem will occur, and then check the running log file. Generally, there will be a prompt. if you do not understand what it means, copy google, generally, you will find a solution to the problem, unless your bug has reached the level of depth that is not involved. 2. the degree of understanding of the program can effectively improve the debugging troubleshooting time. if you change to a Cainiao, it is estimated that it is difficult to write a native Upload, not to mention, read the log and go over google, 3. the speed of Debug can be improved through troubleshooting experience and program understanding. the correct Debug solution can be obtained through the guidance of our predecessors. 4. more summaries, more sharing, and active learning are often more effective than passive learning!