Home >Backend Development >PHP Tutorial >nginx source code (2) running
Continued from the previous article
When running, an error occurs and the nginx.conf file cannot be found. This file is in the conf directory. For convenience, we change the default nginx prefix to the current directory and modify the PREFIX definition in the file auto/options as the current directory:
<code><span>if</span> [ <span>".<span>$PREFIX</span>"</span> = <span>"."</span> ]; <span>then</span> PREFIX=. <span>fi</span></code>
In the current Create new folders logs and html in the source code directory, create a new file index.html in the html directory, enter success
Remake clean, make, generate new nginx binary file, run sudo ./nginx
Check the process ps -ef|grep nginx
You can see that nginx has been started successfully. When you access http://localhost in the browser, the page returns success!
View log:
There are access records in logs/access.log
If an error occurs, there is an error message in logs/error.log.
logs/nginx.pid is the process number of the nginx process.
Note:
If run without root, an error will be reported:
2015/03/15 13:44:13 [emerg] 19240#0: bind() to 0.0.0.0:80 failed (13: Permission denied)
If If there is no html directory and the following index.html file, an error will be reported:
2015/03/15 13:47:55 [error] 19310#0: *1 “./html/” is not found (2: No such file or directory), client: 127.0.0.1, URL: /
Because I am building the simplest page without favicon.ico, so an error will be reported here:
2015/03/15 13:47 :55 [error] 19310#0: *1 open() “./html/favicon.ico” failed (2: No such file or directory), client: 127.0.0.1, URL: /favicon.ico
Run At this time, there are 4 processes in total:
root 19715 1144 0 14:04 ? 00:00:00 ./nginx
nobody 19716 19715 0 14:04 ? 00:00:00 ./nginx
nobody 19717 19715 0 14:04 ? 00:00:00 ./nginx
nobody 19718 19715 0 14:04 ? 00:00:00 ./nginx
The main process runs with root permissions, and the other three are work processes.
The above introduces the operation of nginx source code (2), including various aspects. I hope it will be helpful to friends who are interested in PHP tutorials.