博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CentOS 7 安装Nginx-1.9.2
阅读量:6838 次
发布时间:2019-06-26

本文共 14487 字,大约阅读时间需要 48 分钟。

  hot3.png

「个人记录,肯定有理解错误和理解不透的地方,小白总是有个成长的过程,希望大家多多指教。」

一、准备工作:

1、安装必备工具:

$ yum -y install gcc gcc-c++ autoconf automake$ yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
说明:

pcre: 用来作地址重写的功能。

zlib:nginx 的gzip模块,传输数据打包,省流量(但消耗资源)。

openssl:提供ssl加密协议。

2、新建一个系统级用户组和匿名用户,以及下面编译时使用

$ sudo groupadd -r nginx$ sudo useradd -s /sbin/nologin -g nginx -r nginx-user

二、Nginx编译安装:

1、下载Nginx:

2、解压编译:

$ tar -zxvf nginx-1.9.2.tar.gz$ cd nginx-1.9.2/$ ./configure \--prefix=/etc/nginx \--sbin-path=/usr/sbin/nginx \--conf-path=/etc/nginx/nginx.conf \--error-log-path=/var/log/nginx/error.log \--http-log-path=/var/log/nginx/access.log \--pid-path=/var/run/nginx.pid \--lock-path=/var/run/nginx.lock \--http-client-body-temp-path=/var/cache/nginx/client_temp \--http-proxy-temp-path=/var/cache/nginx/proxy_temp \--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \--http-scgi-temp-path=/var/cache/nginx/scgi_temp \--user=nginx \--group=nginx \--with-http_ssl_module \--with-http_realip_module \--with-http_addition_module \--with-http_sub_module \--with-http_dav_module \--with-http_flv_module \--with-http_mp4_module \--with-http_gunzip_module \--with-http_gzip_static_module \--with-http_random_index_module \--with-http_secure_link_module \--with-http_stub_status_module \--with-http_auth_request_module \--with-mail \--with-mail_ssl_module \--with-file-aio \--with-ipv6 \--with-http_spdy_module \--with-cc-opt='-O2 -g -pipe -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic'

上面的参数的作用可以通过--help来查看下文附加1中有提供

$ ./configure --help
编译日志:
checking for OS + Linux 3.10.0-229.4.2.el7.x86_64 x86_64checking for C compiler ... found + using GNU C compiler + gcc version: 4.8.3 20140911 (Red Hat 4.8.3-9) (GCC) checking for gcc -pipe switch ... foundchecking for gcc builtin atomic operations ... foundchecking for C99 variadic macros ... foundchecking for gcc variadic macros ... foundchecking for unistd.h ... foundchecking for inttypes.h ... foundchecking for limits.h ... foundchecking for sys/filio.h ... not foundchecking for sys/param.h ... foundchecking for sys/mount.h ... foundchecking for sys/statvfs.h ... foundchecking for crypt.h ... foundchecking for Linux specific featureschecking for epoll ... foundchecking for EPOLLRDHUP ... foundchecking for O_PATH ... foundchecking for sendfile() ... foundchecking for sendfile64() ... foundchecking for sys/prctl.h ... foundchecking for prctl(PR_SET_DUMPABLE) ... foundchecking for sched_setaffinity() ... foundchecking for crypt_r() ... foundchecking for sys/vfs.h ... foundchecking for poll() ... foundchecking for /dev/poll ... not foundchecking for kqueue ... not foundchecking for crypt() ... not foundchecking for crypt() in libcrypt ... foundchecking for F_READAHEAD ... not foundchecking for posix_fadvise() ... foundchecking for O_DIRECT ... foundchecking for F_NOCACHE ... not foundchecking for directio() ... not foundchecking for statfs() ... foundchecking for statvfs() ... foundchecking for dlopen() ... not foundchecking for dlopen() in libdl ... foundchecking for sched_yield() ... foundchecking for SO_SETFIB ... not foundchecking for SO_REUSEPORT ... foundchecking for SO_ACCEPTFILTER ... not foundchecking for TCP_DEFER_ACCEPT ... foundchecking for TCP_KEEPIDLE ... foundchecking for TCP_FASTOPEN ... not foundchecking for TCP_INFO ... foundchecking for accept4() ... foundchecking for eventfd() ... foundchecking for int size ... 4 byteschecking for long size ... 8 byteschecking for long long size ... 8 byteschecking for void * size ... 8 byteschecking for uint64_t ... foundchecking for sig_atomic_t ... foundchecking for sig_atomic_t size ... 4 byteschecking for socklen_t ... foundchecking for in_addr_t ... foundchecking for in_port_t ... foundchecking for rlim_t ... foundchecking for uintptr_t ... uintptr_t foundchecking for system byte ordering ... little endianchecking for size_t size ... 8 byteschecking for off_t size ... 8 byteschecking for time_t size ... 8 byteschecking for setproctitle() ... not foundchecking for pread() ... foundchecking for pwrite() ... foundchecking for sys_nerr ... foundchecking for localtime_r() ... foundchecking for posix_memalign() ... foundchecking for memalign() ... foundchecking for mmap(MAP_ANON|MAP_SHARED) ... foundchecking for mmap("/dev/zero", MAP_SHARED) ... foundchecking for System V shared memory ... foundchecking for POSIX semaphores ... not foundchecking for POSIX semaphores in libpthread ... foundchecking for struct msghdr.msg_control ... foundchecking for ioctl(FIONBIO) ... foundchecking for struct tm.tm_gmtoff ... foundchecking for struct dirent.d_namlen ... not foundchecking for struct dirent.d_type ... foundchecking for sysconf(_SC_NPROCESSORS_ONLN) ... foundchecking for openat(), fstatat() ... foundchecking for getaddrinfo() ... foundchecking for PCRE library ... foundchecking for PCRE JIT support ... foundchecking for OpenSSL library ... foundchecking for zlib library ... foundcreating objs/MakefileConfiguration summary  + using system PCRE library  + using system OpenSSL library  + md5: using OpenSSL library  + sha1: using OpenSSL library  + using system zlib library  nginx path prefix: "/usr"  nginx binary file: "/usr/sbin/nginx"  nginx configuration prefix: "/etc/nginx"  nginx configuration file: "/etc/nginx/nginx.conf"  nginx pid file: "/var/run/nginx/nginx.pid"  nginx error log file: "/var/log/nginx/error.log"  nginx http access log file: "/var/log/nginx/http.log"  nginx http client request body temporary files: "/var/tmp/nginx/client"  nginx http proxy temporary files: "/var/tmp/nginx/proxy"  nginx http fastcgi temporary files: "/var/tmp/nginx/fcgi"  nginx http uwsgi temporary files: "uwsgi_temp"  nginx http scgi temporary files: "scgi_temp"

好像很成功。

3、安装:

$ make && make install

4、启动:

$ nginx -c /etc/nginx/nginx.conf

如果提示缺什么包,直接用yum安装

$ yum install xxxxx
如果提示:
nginx: [emerg] mkdir() "/var/tmp/nginx/client_temp" failed (2: No such file or directory)

则用管理员去mkdir 创建文件夹后再启动。

对于nginx的操作,指令比较长,也不便于操作,因此可以使用脚本,教程中转:

附加1:

--help                             print this message  --prefix=PATH                      set installation prefix  --sbin-path=PATH                   set nginx binary pathname  --conf-path=PATH                   set nginx.conf pathname  --error-log-path=PATH              set error log pathname  --pid-path=PATH                    set nginx.pid pathname  --lock-path=PATH                   set nginx.lock pathname  --user=USER                        set non-privileged user for                                     worker processes  --group=GROUP                      set non-privileged group for                                     worker processes  --build=NAME                       set build name  --builddir=DIR                     set build directory  --with-select_module               enable select module  --without-select_module            disable select module  --with-poll_module                 enable poll module  --without-poll_module              disable poll module  --with-threads                     enable thread pool support  --with-file-aio                    enable file AIO support  --with-ipv6                        enable IPv6 support  --with-http_ssl_module             enable ngx_http_ssl_module  --with-http_spdy_module            enable ngx_http_spdy_module  --with-http_realip_module          enable ngx_http_realip_module  --with-http_addition_module        enable ngx_http_addition_module  --with-http_xslt_module            enable ngx_http_xslt_module  --with-http_image_filter_module    enable ngx_http_image_filter_module  --with-http_geoip_module           enable ngx_http_geoip_module  --with-http_sub_module             enable ngx_http_sub_module  --with-http_dav_module             enable ngx_http_dav_module  --with-http_flv_module             enable ngx_http_flv_module  --with-http_mp4_module             enable ngx_http_mp4_module  --with-http_gunzip_module          enable ngx_http_gunzip_module  --with-http_gzip_static_module     enable ngx_http_gzip_static_module  --with-http_auth_request_module    enable ngx_http_auth_request_module  --with-http_random_index_module    enable ngx_http_random_index_module  --with-http_secure_link_module     enable ngx_http_secure_link_module  --with-http_degradation_module     enable ngx_http_degradation_module  --with-http_stub_status_module     enable ngx_http_stub_status_module  --without-http_charset_module      disable ngx_http_charset_module  --without-http_gzip_module         disable ngx_http_gzip_module  --without-http_ssi_module          disable ngx_http_ssi_module  --without-http_userid_module       disable ngx_http_userid_module  --without-http_access_module       disable ngx_http_access_module  --without-http_auth_basic_module   disable ngx_http_auth_basic_module  --without-http_autoindex_module    disable ngx_http_autoindex_module  --without-http_geo_module          disable ngx_http_geo_module  --without-http_map_module          disable ngx_http_map_module  --without-http_split_clients_module disable ngx_http_split_clients_module  --without-http_referer_module      disable ngx_http_referer_module  --without-http_rewrite_module      disable ngx_http_rewrite_module  --without-http_proxy_module        disable ngx_http_proxy_module  --without-http_fastcgi_module      disable ngx_http_fastcgi_module  --without-http_uwsgi_module        disable ngx_http_uwsgi_module  --without-http_scgi_module         disable ngx_http_scgi_module  --without-http_memcached_module    disable ngx_http_memcached_module  --without-http_limit_conn_module   disable ngx_http_limit_conn_module  --without-http_limit_req_module    disable ngx_http_limit_req_module  --without-http_empty_gif_module    disable ngx_http_empty_gif_module  --without-http_browser_module      disable ngx_http_browser_module  --without-http_upstream_hash_module                                     disable ngx_http_upstream_hash_module  --without-http_upstream_ip_hash_module                                     disable ngx_http_upstream_ip_hash_module  --without-http_upstream_least_conn_module                                     disable ngx_http_upstream_least_conn_module  --without-http_upstream_keepalive_module                                     disable ngx_http_upstream_keepalive_module  --without-http_upstream_zone_module                                     disable ngx_http_upstream_zone_module  --with-http_perl_module            enable ngx_http_perl_module  --with-perl_modules_path=PATH      set Perl modules path  --with-perl=PATH                   set perl binary pathname  --http-log-path=PATH               set http access log pathname  --http-client-body-temp-path=PATH  set path to store                                     http client request body temporary files  --http-proxy-temp-path=PATH        set path to store                                     http proxy temporary files  --http-fastcgi-temp-path=PATH      set path to store                                     http fastcgi temporary files  --http-uwsgi-temp-path=PATH        set path to store                                     http uwsgi temporary files  --http-scgi-temp-path=PATH         set path to store                                     http scgi temporary files  --without-http                     disable HTTP server  --without-http-cache               disable HTTP cache  --with-mail                        enable POP3/IMAP4/SMTP proxy module  --with-mail_ssl_module             enable ngx_mail_ssl_module  --without-mail_pop3_module         disable ngx_mail_pop3_module  --without-mail_imap_module         disable ngx_mail_imap_module  --without-mail_smtp_module         disable ngx_mail_smtp_module  --with-stream                      enable TCP proxy module  --with-stream_ssl_module           enable ngx_stream_ssl_module  --without-stream_access_module     disable ngx_stream_access_module  --without-stream_upstream_hash_module                                     disable ngx_stream_upstream_hash_module  --without-stream_upstream_least_conn_module                                     disable ngx_stream_upstream_least_conn_module  --without-stream_upstream_zone_module                                     disable ngx_stream_upstream_zone_module  --with-google_perftools_module     enable ngx_google_perftools_module  --with-cpp_test_module             enable ngx_cpp_test_module  --add-module=PATH                  enable an external module  --with-cc=PATH                     set C compiler pathname  --with-cpp=PATH                    set C preprocessor pathname  --with-cc-opt=OPTIONS              set additional C compiler options  --with-ld-opt=OPTIONS              set additional linker options  --with-cpu-opt=CPU                 build for the specified CPU, valid values:                                     pentium, pentiumpro, pentium3, pentium4,                                     athlon, opteron, sparc32, sparc64, ppc64  --without-pcre                     disable PCRE library usage  --with-pcre                        force PCRE library usage  --with-pcre=DIR                    set path to PCRE library sources  --with-pcre-opt=OPTIONS            set additional build options for PCRE  --with-pcre-jit                    build PCRE with JIT compilation support  --with-md5=DIR                     set path to md5 library sources  --with-md5-opt=OPTIONS             set additional build options for md5  --with-md5-asm                     use md5 assembler sources  --with-sha1=DIR                    set path to sha1 library sources  --with-sha1-opt=OPTIONS            set additional build options for sha1  --with-sha1-asm                    use sha1 assembler sources  --with-zlib=DIR                    set path to zlib library sources  --with-zlib-opt=OPTIONS            set additional build options for zlib  --with-zlib-asm=CPU                use zlib assembler sources optimized                                     for the specified CPU, valid values:                                     pentium, pentiumpro  --with-libatomic                   force libatomic_ops library usage  --with-libatomic=DIR               set path to libatomic_ops library sources  --with-openssl=DIR                 set path to OpenSSL library sources  --with-openssl-opt=OPTIONS         set additional build options for OpenSSL  --with-debug                       enable debug logging

转载于:https://my.oschina.net/liucao/blog/470241

你可能感兴趣的文章
python Day1作业:用户三次登陆锁定
查看>>
镜像即代码:基于Packer构建阿里云镜像
查看>>
pg_dump 详解/使用举例
查看>>
云栖社区 测试技术社区大群 正式成立!还在等什么,快来加入我们 ...
查看>>
spring cloud微服务分布式云架构-Gateway入门
查看>>
python编程语言基础
查看>>
Java面试笔试题大汇总三(最全+详细答案)
查看>>
书籍:Python机器学习蓝图第2版 Python Machine Learning Blueprints 2nd - 2019.pdf
查看>>
Intellij IDEA 中无法下载 Cloud Toolkit 问题解决
查看>>
PostgreSQL何以支持丰富的NoSQL特性?
查看>>
高性能和可扩展的React-Redux
查看>>
组复制官方翻译五、Group Replication Security
查看>>
spring 注解试事物源码解析
查看>>
推荐一个非常好用的Chrome扩展应用,用于美化Json字符串
查看>>
模板方法模式
查看>>
CSS------当内容超出div宽度后自动换行和限制文字不超出div宽度和高度
查看>>
MySQL优化系列(二)--查找优化(1)(非索引设计)
查看>>
提高WPF程序性能的几条建议
查看>>
nginx常用功能全揭秘
查看>>
Spark(四) -- Spark工作机制
查看>>