分享

CentOS6.5安装配置Nginx1.11.5

 WindySky 2016-11-28

一、安装pcre

查看是否已经安装了pcre

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. rpm -qa | grep pcre  

如果存在,则删除已经安装的pcre(最好不要用系统自带的pcre)

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. rpm -e --nodeps pcre-7.8-6.el6.x86_64  

安装pcre

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. yum install pcre*  

二、安装openssl

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. yum -y install openssl*  

三、下载Nginx编译安装包

下载地址:http:///en/download.html

下载完成后解压在服务器的某个目录;

然后进度Nginx的解压目录:

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. cd /home/software/nginx-1.11.5  

执行安装前的配置检查(增加prefix参数,是为了提供nginx的安装目录)

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. ./configure --prefix=/home/nginx-1.11.5 --with-http_ssl_module --with-http_v2_module --with-http_stub_status_module --with-pcre  
执行结束,如果没有发现error信息,则可以看到系统打印出:

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. ......  
  2. checking for rlim_t ... found  
  3. checking for uintptr_t ... uintptr_t found  
  4. checking for system byte ordering ... little endian  
  5. checking for size_t size ... 8 bytes  
  6. checking for off_t size ... 8 bytes  
  7. checking for time_t size ... 8 bytes  
  8. checking for AF_INET6 ... found  
  9. checking for setproctitle() ... not found  
  10. checking for pread() ... found  
  11. checking for pwrite() ... found  
  12. checking for pwritev() ... found  
  13. checking for sys_nerr ... found  
  14. checking for localtime_r() ... found  
  15. checking for posix_memalign() ... found  
  16. checking for memalign() ... found  
  17. checking for mmap(MAP_ANON|MAP_SHARED) ... found  
  18. checking for mmap("/dev/zero", MAP_SHARED) ... found  
  19. checking for System V shared memory ... found  
  20. checking for POSIX semaphores ... not found  
  21. checking for POSIX semaphores in libpthread ... found  
  22. checking for struct msghdr.msg_control ... found  
  23. checking for ioctl(FIONBIO) ... found  
  24. checking for struct tm.tm_gmtoff ... found  
  25. checking for struct dirent.d_namlen ... not found  
  26. checking for struct dirent.d_type ... found  
  27. checking for sysconf(_SC_NPROCESSORS_ONLN) ... found  
  28. checking for openat(), fstatat() ... found  
  29. checking for getaddrinfo() ... found  
  30. checking for PCRE library ... found  
  31. checking for PCRE JIT support ... not found  
  32. checking for OpenSSL library ... found  
  33. checking for zlib library ... found  
  34. creating objs/Makefile  
  35.   
  36. Configuration summary  
  37.   + using system PCRE library  
  38.   + using system OpenSSL library  
  39.   + using system zlib library  
  40.   
  41.   nginx path prefix: "/home/nginx-1.11.5"  
  42.   nginx binary file: "/home/nginx-1.11.5/sbin/nginx"  
  43.   nginx modules path: "/home/nginx-1.11.5/modules"  
  44.   nginx configuration prefix: "/home/nginx-1.11.5/conf"  
  45.   nginx configuration file: "/home/nginx-1.11.5/conf/nginx.conf"  
  46.   nginx pid file: "/home/nginx-1.11.5/logs/nginx.pid"  
  47.   nginx error log file: "/home/nginx-1.11.5/logs/error.log"  
  48.   nginx http access log file: "/home/nginx-1.11.5/logs/access.log"  
  49.   nginx http client request body temporary files: "client_body_temp"  
  50.   nginx http proxy temporary files: "proxy_temp"  
  51.   nginx http fastcgi temporary files: "fastcgi_temp"  
  52.   nginx http uwsgi temporary files: "uwsgi_temp"  
  53.   nginx http scgi temporary files: "scgi_temp"  

然后进行编译,当前目录执行make命令

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. make  

编译结束后,如果没有错误,则正常结束,如下图

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. ......  
  2.         objs/src/http/ngx_http_write_filter_module.o \  
  3.         objs/src/http/ngx_http_header_filter_module.o \  
  4.         objs/src/http/modules/ngx_http_chunked_filter_module.o \  
  5.         objs/src/http/v2/ngx_http_v2_filter_module.o \  
  6.         objs/src/http/modules/ngx_http_range_filter_module.o \  
  7.         objs/src/http/modules/ngx_http_gzip_filter_module.o \  
  8.         objs/src/http/ngx_http_postpone_filter_module.o \  
  9.         objs/src/http/modules/ngx_http_ssi_filter_module.o \  
  10.         objs/src/http/modules/ngx_http_charset_filter_module.o \  
  11.         objs/src/http/modules/ngx_http_userid_filter_module.o \  
  12.         objs/src/http/modules/ngx_http_headers_filter_module.o \  
  13.         objs/src/http/ngx_http_copy_filter_module.o \  
  14.         objs/src/http/modules/ngx_http_not_modified_filter_module.o \  
  15.         objs/src/http/v2/ngx_http_v2.o \  
  16.         objs/src/http/v2/ngx_http_v2_table.o \  
  17.         objs/src/http/v2/ngx_http_v2_huff_decode.o \  
  18.         objs/src/http/v2/ngx_http_v2_huff_encode.o \  
  19.         objs/src/http/v2/ngx_http_v2_module.o \  
  20.         objs/src/http/modules/ngx_http_static_module.o \  
  21.         objs/src/http/modules/ngx_http_autoindex_module.o \  
  22.         objs/src/http/modules/ngx_http_index_module.o \  
  23.         objs/src/http/modules/ngx_http_auth_basic_module.o \  
  24.         objs/src/http/modules/ngx_http_access_module.o \  
  25.         objs/src/http/modules/ngx_http_limit_conn_module.o \  
  26.         objs/src/http/modules/ngx_http_limit_req_module.o \  
  27.         objs/src/http/modules/ngx_http_geo_module.o \  
  28.         objs/src/http/modules/ngx_http_map_module.o \  
  29.         objs/src/http/modules/ngx_http_split_clients_module.o \  
  30.         objs/src/http/modules/ngx_http_referer_module.o \  
  31.         objs/src/http/modules/ngx_http_rewrite_module.o \  
  32.         objs/src/http/modules/ngx_http_ssl_module.o \  
  33.         objs/src/http/modules/ngx_http_proxy_module.o \  
  34.         objs/src/http/modules/ngx_http_fastcgi_module.o \  
  35.         objs/src/http/modules/ngx_http_uwsgi_module.o \  
  36.         objs/src/http/modules/ngx_http_scgi_module.o \  
  37.         objs/src/http/modules/ngx_http_memcached_module.o \  
  38.         objs/src/http/modules/ngx_http_empty_gif_module.o \  
  39.         objs/src/http/modules/ngx_http_browser_module.o \  
  40.         objs/src/http/modules/ngx_http_upstream_hash_module.o \  
  41.         objs/src/http/modules/ngx_http_upstream_ip_hash_module.o \  
  42.         objs/src/http/modules/ngx_http_upstream_least_conn_module.o \  
  43.         objs/src/http/modules/ngx_http_upstream_keepalive_module.o \  
  44.         objs/src/http/modules/ngx_http_upstream_zone_module.o \  
  45.         objs/src/http/modules/ngx_http_stub_status_module.o \  
  46.         objs/ngx_modules.o \  
  47.         -ldl -lpthread -lcrypt -lpcre -lssl -lcrypto -ldl -lz \  
  48.         -Wl,-E  
  49. sed -e "s|%%PREFIX%%|/home/nginx-1.11.5|" \  
  50.                 -e "s|%%PID_PATH%%|/home/nginx-1.11.5/logs/nginx.pid|" \  
  51.                 -e "s|%%CONF_PATH%%|/home/nginx-1.11.5/conf/nginx.conf|" \  
  52.                 -e "s|%%ERROR_LOG_PATH%%|/home/nginx-1.11.5/logs/error.log|" \  
  53.                 < man/nginx.8 > objs/nginx.8  
  54. make[1]: Leaving directory `/home/nginx'  

执行安装命令 make install

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. make install  

运行结束后,可以看到输出如下:

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. ......  
  2. test -f '/home/nginx-1.11.5/conf/mime.types' \  
  3.                 || cp conf/mime.types '/home/nginx-1.11.5/conf'  
  4. cp conf/mime.types '/home/nginx-1.11.5/conf/mime.types.default'  
  5. test -f '/home/nginx-1.11.5/conf/fastcgi_params' \  
  6.                 || cp conf/fastcgi_params '/home/nginx-1.11.5/conf'  
  7. cp conf/fastcgi_params \  
  8.                 '/home/nginx-1.11.5/conf/fastcgi_params.default'  
  9. test -f '/home/nginx-1.11.5/conf/fastcgi.conf' \  
  10.                 || cp conf/fastcgi.conf '/home/nginx-1.11.5/conf'  
  11. cp conf/fastcgi.conf '/home/nginx-1.11.5/conf/fastcgi.conf.default'  
  12. test -f '/home/nginx-1.11.5/conf/uwsgi_params' \  
  13.                 || cp conf/uwsgi_params '/home/nginx-1.11.5/conf'  
  14. cp conf/uwsgi_params \  
  15.                 '/home/nginx-1.11.5/conf/uwsgi_params.default'  
  16. test -f '/home/nginx-1.11.5/conf/scgi_params' \  
  17.                 || cp conf/scgi_params '/home/nginx-1.11.5/conf'  
  18. cp conf/scgi_params \  
  19.                 '/home/nginx-1.11.5/conf/scgi_params.default'  
  20. test -f '/home/nginx-1.11.5/conf/nginx.conf' \  
  21.                 || cp conf/nginx.conf '/home/nginx-1.11.5/conf/nginx.conf'  
  22. cp conf/nginx.conf '/home/nginx-1.11.5/conf/nginx.conf.default'  
  23. test -d '/home/nginx-1.11.5/logs' \  
  24.                 || mkdir -p '/home/nginx-1.11.5/logs'  
  25. test -d '/home/nginx-1.11.5/logs' \  
  26.                 || mkdir -p '/home/nginx-1.11.5/logs'  
  27. test -d '/home/nginx-1.11.5/html' \  
  28.                 || cp -R html '/home/nginx-1.11.5'  
  29. test -d '/home/nginx-1.11.5/logs' \  
  30.                 || mkdir -p '/home/nginx-1.11.5/logs'  
  31. make[1]: Leaving directory `/home/nginx'  

开启Nginx进程(注意应该输入自己的安装目录,题主此处为/home/nginx-1.11.5/)

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. /home/nginx-1.11.5/sbin/nginx  

可以通过查看进行中是否有nginx来判断nginx是否启动成功:

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. ps -ef | grep nginx  

如果发现结果中有nginx的进程,则认为已经启动:

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. root      6088     1  0 18:05 ?        00:00:00 nginx: master process /home/nginx-1.11.5/sbin/nginx  
  2. nobody    6089  6088  0 18:05 ?        00:00:00 nginx: worker process          
  3. root      6125  1198  0 18:06 pts/0    00:00:00 grep nginx  

Nginx的重启或者关闭(s参数代表signal,向nginx主进程发送信号):

[plain] view plain copy
在CODE上查看代码片派生到我的代码片
  1. /home/nginx-1.11.5/sbin/nginx -s reload  
  2. /home/nginx-1.11.5/sbin/nginx -s stop  

浏览器输入IP,即可访问到Nginx的欢迎界面:



    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多