• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

nginx 源码(2)运行

php 搞代码 3年前 (2022-01-23) 25次浏览 已收录 0个评论

接上一篇文章
运行时报错,找不到nginx.conf文件,这个文件在conf目录下,为了方便我们把默认的nginx前缀改成当前目录,修改文件auto/options中PREFIX定义为当前目录:

<code><span>if</span> [ <span>".<span>$PREFIX</span>"</span> = <span>"."</span> ]; <span>then</span>    PREFIX=.<span>fi</span></code>

在当前的源码目录下新建文件夹logs 和 html,在html目录下新建文件index.html, 里面输入
success
重新make clean,make,生成新的nginx二进制文件,运行
sudo ./nginx
查看进程
ps -ef|grep nginx
能看到nginx已经成功启动,在浏览器中访问http://localhost,页面返回sucess!
查看日志:
logs/access.log中有访问记录
如果出错,logs/error.log中有报错信息。
logs/nginx.pid中是nginx进程的进程号。

注意:
如果不使用root运行,则会报错:

2015/03/15 13:44:13 [emerg] 19240#0: bind() to 0.0.0.0:80 failed (13: Permission denied)

如果没有html目录和下面的index.html文件,则会报错:

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: /

因为我建的是一个最简单的页面,没有favicon.ico,所以这里会报错:

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

运行时,一共有4个进程:

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

root权限运行的是主进程,其他3个是work进程。

<script type=”text/javascript”> $(function () { $(‘pre.prettyprint code’).each(function () { var lines = $(this).text().split(‘\n’).length; var $numbering = $(‘

    ‘).addClass(‘pre-numbering’).hide(); $(this).addClass(‘has-numbering’).parent().append($numbering); for (i = 1; i <= lines; i++) { $numbering.append($('

  • ‘).text(i)); }; $numbering.fadeIn(1700); }); }); </script> 本文来源gao@!dai!ma.com搞$$代^@码!网!搞gaodaima代码

    以上就介绍了nginx 源码(2)运行,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。


    搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
    转载请注明原文链接:nginx 源码(2)运行

    喜欢 (0)
    [搞代码]
    分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址