前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >CentOS6编译安装Nginx

CentOS6编译安装Nginx

作者头像
星哥玩云
发布2022-06-28 16:12:13
2270
发布2022-06-28 16:12:13
举报
文章被收录于专栏:开源部署

安装libunwind

64位操作系统请先安装libunwind库,32位操作系统不要安装。libunwind库为基于64位CPU和操作系统的程序提供了基本的堆栈辗转开解功能,其中包括用于输出堆栈跟踪的API、用于以编程方式辗转开解堆栈的API以及支持C++异常处理机制的API。

  1. [root@test software]# tar zxvf libunwind-1.1.tar.gz
  2. [root@test software]# cd libunwind-0.99-alpha
  3. [root@test libunwind-0.99-alpha]# CFLAGS=-fPIC ./configure
  4. [root@test libunwind-0.99-alpha]# make CFLAGS=-fPIC
  5. [root@test libunwind-0.99-alpha]# make CFLAGS=-fPIC install
代码语言:javascript
复制
[root@test software]# tar zxvf libunwind-1.1.tar.gz
[root@test software]# cd libunwind-0.99-alpha
[root@test libunwind-0.99-alpha]# CFLAGS=-fPIC ./configure
[root@test libunwind-0.99-alpha]# make CFLAGS=-fPIC
[root@test libunwind-0.99-alpha]# make CFLAGS=-fPIC install

安装google-perftools

  1. [root@test software]# tar -zxvf gperftools-2.1.tar.gz
  2. [root@test software]# cd gperftools-2.1
  3. [root@test gperftools-2.1]# ./configure
  4. [root@test gperftools-2.1]# make
  5. [root@test gperftools-2.1]# make install
  6. [root@test gperftools-2.1]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
  7. [root@test gperftools-2.1]# /sbin/ldconfig
代码语言:javascript
复制
[root@test software]# tar -zxvf gperftools-2.1.tar.gz
[root@test software]# cd gperftools-2.1
[root@test gperftools-2.1]# ./configure
[root@test gperftools-2.1]# make
[root@test gperftools-2.1]# make install
[root@test gperftools-2.1]# echo "/usr/local/lib" > /etc/ld.so.conf.d/usr_local_lib.conf
[root@test gperftools-2.1]# /sbin/ldconfig

安装nginx

  1. [root@test software]# tar -zxvf nginx-1.5.7.tar.gz
  2. [root@test software]# cd nginx-1.5.7
  3. [root@test nginx-1.5.7]# ./configure --prefix=/service/nginx --with-http_stub_status_module --with-google_perftools_module --with-pcre --with-http_ssl_module --lock-path=/service/nginx/nginx.lock --pid-path=/service/nginx/nginx.pid
  4. ........................
  5. Configuration summary
  6. + using PCRE library: /service/pcre
  7. + using system OpenSSL library
  8. + md5: using OpenSSL library
  9. + sha1: using OpenSSL library
  10. + using system zlib library
  11. nginx path prefix: "/service/nginx"
  12. nginx binary file: "/service/nginx/sbin/nginx"
  13. nginx configuration prefix: "/service/nginx/conf"
  14. nginx configuration file: "/service/nginx/conf/nginx.conf"
  15. nginx pid file: "/service/nginx/nginx.pid"
  16. nginx error log file: "/service/nginx/logs/error.log"
  17. nginx http access log file: "/service/nginx/logs/access.log"
  18. nginx http client request body temporary files: "client_body_temp"
  19. nginx http proxy temporary files: "proxy_temp"
  20. nginx http fastcgi temporary files: "fastcgi_temp"
  21. nginx http uwsgi temporary files: "uwsgi_temp"
  22. nginx http scgi temporary files: "scgi_temp"
  23. [root@test nginx-1.5.7]# make
  24. [root@test nginx-1.5.7]# make install
代码语言:javascript
复制
[root@test software]# tar -zxvf nginx-1.5.7.tar.gz
[root@test software]# cd nginx-1.5.7
[root@test nginx-1.5.7]# ./configure --prefix=/service/nginx --with-http_stub_status_module --with-google_perftools_module --with-pcre --with-http_ssl_module --lock-path=/service/nginx/nginx.lock --pid-path=/service/nginx/nginx.pid
........................
Configuration summary
  + using PCRE library: /service/pcre
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1: using OpenSSL library
  + using system zlib library

  nginx path prefix: "/service/nginx"
  nginx binary file: "/service/nginx/sbin/nginx"
  nginx configuration prefix: "/service/nginx/conf"
  nginx configuration file: "/service/nginx/conf/nginx.conf"
  nginx pid file: "/service/nginx/nginx.pid"
  nginx error log file: "/service/nginx/logs/error.log"
  nginx http access log file: "/service/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"

[root@test nginx-1.5.7]# make
[root@test nginx-1.5.7]# make install

测试nginx

  1. [root@test sbin]# ./nginx -t
  2. nginx: the configuration file /service/nginx/conf/nginx.conf syntax is ok
  3. nginx: configuration file /service/nginx/conf/nginx.conf test is successful
  4. [root@test sbin]# ./nginx -v
  5. nginx version: nginx/1.5.7
  6. [root@test sbin]#
代码语言:javascript
复制
[root@test sbin]# ./nginx -t
nginx: the configuration file /service/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /service/nginx/conf/nginx.conf test is successful
[root@test sbin]# ./nginx -v
nginx version: nginx/1.5.7
[root@test sbin]# 
  1. [root@test nginx]# /service/nginx/sbin/nginx
  2. [root@test nginx]# netstat -lanp|grep nginx
  3. tcp 0 0 0.0.0.0:81 0.0.0.0:* LISTEN 27889/nginx
  4. unix 3 [ ] STREAM CONNECTED 54224 27889/nginx
  5. unix 3 [ ] STREAM CONNECTED 54223 27889/nginx
  6. [root@test nginx]# ll
  7. total 40
  8. drwx------ 2 nobody root 4096 Nov 26 21:24 client_body_temp
  9. drwxr-xr-x 2 root root 4096 Nov 26 21:38 conf
  10. drwx------ 2 nobody root 4096 Nov 26 21:24 fastcgi_temp
  11. drwxr-xr-x 2 root root 4096 Nov 26 21:23 html
  12. drwxr-xr-x 2 root root 4096 Nov 26 21:24 logs
  13. -rw-r--r-- 1 root root 6 Nov 26 21:40 nginx.pid
  14. drwx------ 2 nobody root 4096 Nov 26 21:24 proxy_temp
  15. drwxr-xr-x 2 root root 4096 Nov 26 21:23 sbin
  16. drwx------ 2 nobody root 4096 Nov 26 21:24 scgi_temp
  17. drwx------ 2 nobody root 4096 Nov 26 21:24 uwsgi_temp
  18. [root@test nginx]# cat nginx.pid
  19. 27889
  20. [root@test nginx]# ps -ef|grep nginx
  21. root 27889 1 0 21:40 ? 00:00:00 nginx: master process /service/nginx/sbin/nginx
  22. nobody 27890 27889 0 21:40 ? 00:00:00 nginx: worker process
  23. root 27902 3729 0 21:40 pts/0 00:00:00 grep nginx
代码语言:javascript
复制
[root@test nginx]# /service/nginx/sbin/nginx
[root@test nginx]# netstat -lanp|grep nginx
tcp        0      0 0.0.0.0:81                  0.0.0.0:*                   LISTEN      27889/nginx         
unix  3      [ ]         STREAM     CONNECTED     54224  27889/nginx         
unix  3      [ ]         STREAM     CONNECTED     54223  27889/nginx         
[root@test nginx]# ll
total 40
drwx------ 2 nobody root 4096 Nov 26 21:24 client_body_temp
drwxr-xr-x 2 root   root 4096 Nov 26 21:38 conf
drwx------ 2 nobody root 4096 Nov 26 21:24 fastcgi_temp
drwxr-xr-x 2 root   root 4096 Nov 26 21:23 html
drwxr-xr-x 2 root   root 4096 Nov 26 21:24 logs
-rw-r--r-- 1 root   root    6 Nov 26 21:40 nginx.pid
drwx------ 2 nobody root 4096 Nov 26 21:24 proxy_temp
drwxr-xr-x 2 root   root 4096 Nov 26 21:23 sbin
drwx------ 2 nobody root 4096 Nov 26 21:24 scgi_temp
drwx------ 2 nobody root 4096 Nov 26 21:24 uwsgi_temp
[root@test nginx]# cat nginx.pid 
27889
[root@test nginx]# ps -ef|grep nginx
root     27889     1  0 21:40 ?        00:00:00 nginx: master process /service/nginx/sbin/nginx
nobody   27890 27889  0 21:40 ?        00:00:00 nginx: worker process    
root     27902  3729  0 21:40 pts/0    00:00:00 grep nginx

关闭Nginx

  1. /service/nginx/sbin/nginx -s stop
代码语言:javascript
复制
/service/nginx/sbin/nginx -s stop

访问81端口显示

Welcome to nginx!

If you see this page, the nginx web server is successfully installed and working. Further configuration is required.

For online documentation and support please refer to nginx.org. Commercial support is available at nginx.com.

Thank you for using nginx.

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • Welcome to nginx!
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档