: This article describes how to run nginx source code (2). If you are interested in the PHP Tutorial, refer to it. Next Article
An error occurred while running. nginx cannot be found. conf file, which is in the conf Directory. to make it easier for us to change the default nginx PREFIX to the current directory, modify the PREFIX in the file auto/options to the current directory:
if [ ".$PREFIX" = "." ]; then PREFIX=.fi
Create the logs and HTML folders in the source code directory, and create the file index.html in the HTML Directory. enter
success
Re-make clean and make to generate a new nginx binary file and run
sudo ./nginx
View processes
ps -ef|grep nginx
We can see that nginx has been successfully started. visit http: // localhost in the browser, and the page returns sucess!
View logs:
Access records in logs/access. log
If an error occurs, logs/error. log reports an error.
In logs/nginx. pid, it is the process number of the nginx process.
Note:
If root is not used for running, an error is returned:
13:44:13 [emerg] 19240 #0: bind () to 0.0.0.0: 80 failed (13: Permission denied)
If there is no HTML directory or index.html file, an error is returned:
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 created a simple page without favicon. ico, the following error occurs:
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
A total of four processes are running:
Root 19715 1144 0? 00:00:00./nginx
Nobody 19716 19715 0? 00:00:00./nginx
Nobody 19717 19715 0? 00:00:00./nginx
Nobody 19718 19715 0? 00:00:00./nginx
The root permission runs the main process, and the other three are the work process.