资讯专栏INFORMATION COLUMN

Nginx 一点一滴 01 - 安装运行

FWHeart / 3492人阅读

摘要:这时才发现上面的配置错误,必须用绝对路径,不能用形如符号卸载重装的正确姿势查看当前版本版本信息这里要重定向才可以输出到文件哦之后,进程是重新创建了的里面保存的是的主进程号

GET THE CODE
ganiks ➜  nginx-1.8.0  wget http://nginx.org/download/nginx-1.8.0.tar.gz 
ganiks ➜  nginx-1.8.0  tar xzvf nginx-1.8.0.tar.gz
ganiks ➜  nginx-1.8.0  pwd
/home/ganiks/learn/nginx/nginx180_source/nginx_180_Compile/nginx-1.8.0
CONFIGURE
ganiks ➜  nginx-1.8.0  ./configure --prefix=~/home/ganiks/learn/nginx/Nginx
checking for OS
 + Linux 3.13.0-43-generic x86_64
checking for C compiler ... found
 + using GNU C compiler
 + gcc version: 4.8.2 (Ubuntu 4.8.2-19ubuntu1) 
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
bla bla bla ...
bla bla bla ...
bla bla bla ...
checking for sha1 in system OpenSSL crypto library ... found
checking for zlib library ... found
creating objs/Makefile 

Configuration summary  
  + using system PCRE library
  + OpenSSL library is not used
  + md5: using system crypto library
  + sha1: using system crypto library
  + using system zlib library

  nginx path prefix: "~/learn/nginx/Nginx"
  nginx binary file: "~/learn/nginx/Nginx/sbin/nginx"
  nginx configuration prefix: "~/learn/nginx/Nginx/conf"
  nginx configuration file: "~/learn/nginx/Nginx/conf/nginx.conf"
  nginx pid file: "~/learn/nginx/Nginx/logs/nginx.pid"
  nginx error log file: "~/learn/nginx/Nginx/logs/error.log"
  nginx http access log file: "~/learn/nginx/Nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
MAKE && MAKE INSTALL
ganiks ➜  nginx-1.8.0  make && sudo make install
  

这时才发现上面的--prefix配置错误, 必须用绝对路径,不能用形如~符号

MAKE CLEAN
ganiks ➜  nginx-1.8.0  sudo rm -rf ~
ganiks ➜  nginx-1.8.0  make clean
  

卸载重装Nginx的正确姿势

CONFIGURE && INSTALL AGAIN
ganiks ➜  nginx-1.8.0  ./configure --prefix=/home/ganiks/learn/nginx/Nginx

  nginx path prefix: "/home/ganiks/learn/nginx/Nginx"
  nginx binary file: "/home/ganiks/learn/nginx/Nginx/sbin/nginx"
  nginx configuration prefix: "/home/ganiks/learn/nginx/Nginx/conf"
  nginx configuration file: "/home/ganiks/learn/nginx/Nginx/conf/nginx.conf"
  nginx pid file: "/home/ganiks/learn/nginx/Nginx/logs/nginx.pid"
  nginx error log file: "/home/ganiks/learn/nginx/Nginx/logs/error.log"
  nginx http access log file: "/home/ganiks/learn/nginx/Nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

ganiks ➜  nginx-1.8.0  make; make install

ganiks ➜  nginx  tree Nginx
Nginx
├── conf
│   ├── fastcgi.conf
│   ├── fastcgi.conf.default
│   ├── fastcgi_params
│   ├── fastcgi_params.default
│   ├── koi-utf
│   ├── koi-win
│   ├── mime.types
│   ├── mime.types.default
│   ├── nginx.conf
│   ├── nginx.conf.default
│   ├── scgi_params
│   ├── scgi_params.default
│   ├── uwsgi_params
│   ├── uwsgi_params.default
│   └── win-utf
├── html
│   ├── 50x.html
│   └── index.html
├── logs
└── sbin
    └── nginx

ganiks ➜  Nginx  pwd
/home/ganiks/learn/nginx/Nginx
VERSION
  

查看当前Nginx版本版本信息

ganiks ➜  Nginx  ./sbin/nginx -V
nginx version: nginx/1.8.0
built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1)
configure arguments: --prefix=/home/ganiks/learn/nginx/Nginx

ganiks ➜  Nginx  ./sbin/nginx -V 2>&1 > some_file
  

这里要重定向才可以输出到文件哦

START NGINX
ganiks ➜  Nginx  ./sbin/nginx -p .
nginx: [emerg] bind() to 0.0.0.0:80 failed (13: Permission denied)
ganiks ➜  Nginx  vim conf/nginx.conf && listen 8765
ganiks ➜  Nginx  ./sbin/nginx -p .  
ganiks ➜  Nginx  sudo ps -ef | grep nginx             
ganiks   21174     1  0 15:32 ?        00:00:00 nginx: master process ./sbin/nginx -p .
ganiks   21175 21174  0 15:32 ?        00:00:00 nginx: worker process
ganiks   21182 20842  0 15:32 pts/4    00:00:00 grep nginx


ganiks ➜  Nginx  ./sbin/nginx -t
nginx: the configuration file /home/ganiks/learn/nginx/Nginx/conf/nginx.conf syntax is ok
nginx: configuration file /home/ganiks/learn/nginx/Nginx/conf/nginx.conf test is successful
ganiks ➜  Nginx  ./sbin/nginx -s reload
ganiks ➜  Nginx  sudo ps -ef | grep nginx
ganiks   21174     1  0 15:32 ?        00:00:00 nginx: master process ./sbin/nginx -p .
ganiks   21290 21174  0 15:35 ?        00:00:00 nginx: worker process
ganiks   21294 20842  0 15:35 pts/4    00:00:00 grep nginx
ganiks ➜  Nginx  ./sbin/nginx -s reload   
ganiks ➜  Nginx  sudo ps -ef | grep nginx 
ganiks   21174     1  0 15:32 ?        00:00:00 nginx: master process ./sbin/nginx -p .
ganiks   21308 21174  0 15:35 ?        00:00:00 nginx: worker process
ganiks   21313 20842  0 15:35 pts/4    00:00:00 grep nginx
  

nginx reload 之后, worker 进程是重新创建了的

ganiks ➜  Nginx  cat logs/nginx.pid
21174
  

nginx.pid 里面保存的是nginx的主进程号

文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。

转载请注明本文地址:https://www.ucloud.cn/yun/39191.html

相关文章

  • # Oracle APEX 系列文章8:如何从 APEX 5.1.4 升级到最新的 APEX 18.

    摘要:停止当前,服务。钢哥注如果想把里的替换成别的,比如,需要在先将重命名为,然后再跑命令完成安装和部署动作。输入对应的账号后,检查之前的应用也都能正常运行,完美结语以上就是如何从之前的升级到最新的版本的实操,希望老铁们喜欢。 showImg(https://segmentfault.com/img/remote/1460000015087005); 本文是钢哥的 Oracle APEX 系...

    Hancock_Xu 评论0 收藏0
  • 在 Docker 中构建基于 Puppet 的应用

    摘要:通过创建一个的来构建一个应用程序是非常容易的。我们将使用这个镜像来作为我们新的应用程序镜像的基础镜像。现在我们需要为我们的应用程序镜像创建另外一个。你可以重复这个步骤安装任何基于的应用或者是基础设施。 通过创建一个 Docker 的 Dockerfile 来构建一个应用程序是非常容易的。但是如果你已经有了大量的 Puppet 模块(或者是 Chef cookbooks),你想把这些模块...

    NoraXie 评论0 收藏0

发表评论

0条评论

最新活动
阅读需要支付1元查看
<