• Nginx安装搭建之源码方式(Centos7)


    本文以Centos为例,其实和Ubantu安装是一样的。

    官网下载链接:nginx: download

    压缩包下载到服务器中:

    wget https://nginx.org/download/nginx-1.18.0.tar.gz

    解压文件:

    进入解压后的文件:

    查看./configure文件支持哪些参数:

    1. [keepmoving@192 nginx-1.18.0]$ ./configure --help
    2. --help print this message
    3. --prefix=PATH set installation prefix
    4. --sbin-path=PATH set nginx binary pathname
    5. --modules-path=PATH set modules path
    6. --conf-path=PATH set nginx.conf pathname
    7. --error-log-path=PATH set error log pathname
    8. --pid-path=PATH set nginx.pid pathname
    9. --lock-path=PATH set nginx.lock pathname
    10. --user=USER set non-privileged user for
    11. worker processes
    12. --group=GROUP set non-privileged group for
    13. worker processes
    14. --build=NAME set build name
    15. --builddir=DIR set build directory
    16. --with-select_module enable select module
    17. --without-select_module disable select module
    18. --with-poll_module enable poll module
    19. --without-poll_module disable poll module
    20. --with-threads enable thread pool support
    21. --with-file-aio enable file AIO support
    22. --with-http_ssl_module enable ngx_http_ssl_module
    23. --with-http_v2_module enable ngx_http_v2_module
    24. --with-http_realip_module enable ngx_http_realip_module
    25. --with-http_addition_module enable ngx_http_addition_module
    26. --with-http_xslt_module enable ngx_http_xslt_module
    27. --with-http_xslt_module=dynamic enable dynamic ngx_http_xslt_module
    28. --with-http_image_filter_module enable ngx_http_image_filter_module
    29. --with-http_image_filter_module=dynamic
    30. enable dynamic ngx_http_image_filter_module
    31. --with-http_geoip_module enable ngx_http_geoip_module
    32. --with-http_geoip_module=dynamic enable dynamic ngx_http_geoip_module
    33. --with-http_sub_module enable ngx_http_sub_module
    34. --with-http_dav_module enable ngx_http_dav_module
    35. --with-http_flv_module enable ngx_http_flv_module
    36. --with-http_mp4_module enable ngx_http_mp4_module
    37. --with-http_gunzip_module enable ngx_http_gunzip_module
    38. --with-http_gzip_static_module enable ngx_http_gzip_static_module
    39. --with-http_auth_request_module enable ngx_http_auth_request_module
    40. --with-http_random_index_module enable ngx_http_random_index_module
    41. --with-http_secure_link_module enable ngx_http_secure_link_module
    42. --with-http_degradation_module enable ngx_http_degradation_module
    43. --with-http_slice_module enable ngx_http_slice_module
    44. --with-http_stub_status_module enable ngx_http_stub_status_module
    45. --without-http_charset_module disable ngx_http_charset_module
    46. --without-http_gzip_module disable ngx_http_gzip_module
    47. --without-http_ssi_module disable ngx_http_ssi_module
    48. --without-http_userid_module disable ngx_http_userid_module
    49. --without-http_access_module disable ngx_http_access_module
    50. --without-http_auth_basic_module disable ngx_http_auth_basic_module
    51. --without-http_mirror_module disable ngx_http_mirror_module
    52. --without-http_autoindex_module disable ngx_http_autoindex_module
    53. --without-http_geo_module disable ngx_http_geo_module
    54. --without-http_map_module disable ngx_http_map_module
    55. --without-http_split_clients_module disable ngx_http_split_clients_module
    56. --without-http_referer_module disable ngx_http_referer_module
    57. --without-http_rewrite_module disable ngx_http_rewrite_module
    58. --without-http_proxy_module disable ngx_http_proxy_module
    59. --without-http_fastcgi_module disable ngx_http_fastcgi_module
    60. --without-http_uwsgi_module disable ngx_http_uwsgi_module
    61. --without-http_scgi_module disable ngx_http_scgi_module
    62. --without-http_grpc_module disable ngx_http_grpc_module
    63. --without-http_memcached_module disable ngx_http_memcached_module
    64. --without-http_limit_conn_module disable ngx_http_limit_conn_module
    65. --without-http_limit_req_module disable ngx_http_limit_req_module
    66. --without-http_empty_gif_module disable ngx_http_empty_gif_module
    67. --without-http_browser_module disable ngx_http_browser_module
    68. --without-http_upstream_hash_module
    69. disable ngx_http_upstream_hash_module
    70. --without-http_upstream_ip_hash_module
    71. disable ngx_http_upstream_ip_hash_module
    72. --without-http_upstream_least_conn_module
    73. disable ngx_http_upstream_least_conn_module
    74. --without-http_upstream_random_module
    75. disable ngx_http_upstream_random_module
    76. --without-http_upstream_keepalive_module
    77. disable ngx_http_upstream_keepalive_module
    78. --without-http_upstream_zone_module
    79. disable ngx_http_upstream_zone_module
    80. --with-http_perl_module enable ngx_http_perl_module
    81. --with-http_perl_module=dynamic enable dynamic ngx_http_perl_module
    82. --with-perl_modules_path=PATH set Perl modules path
    83. --with-perl=PATH set perl binary pathname
    84. --http-log-path=PATH set http access log pathname
    85. --http-client-body-temp-path=PATH set path to store
    86. http client request body temporary files
    87. --http-proxy-temp-path=PATH set path to store
    88. http proxy temporary files
    89. --http-fastcgi-temp-path=PATH set path to store
    90. http fastcgi temporary files
    91. --http-uwsgi-temp-path=PATH set path to store
    92. http uwsgi temporary files
    93. --http-scgi-temp-path=PATH set path to store
    94. http scgi temporary files
    95. --without-http disable HTTP server
    96. --without-http-cache disable HTTP cache
    97. --with-mail enable POP3/IMAP4/SMTP proxy module
    98. --with-mail=dynamic enable dynamic POP3/IMAP4/SMTP proxy module
    99. --with-mail_ssl_module enable ngx_mail_ssl_module
    100. --without-mail_pop3_module disable ngx_mail_pop3_module
    101. --without-mail_imap_module disable ngx_mail_imap_module
    102. --without-mail_smtp_module disable ngx_mail_smtp_module
    103. --with-stream enable TCP/UDP proxy module
    104. --with-stream=dynamic enable dynamic TCP/UDP proxy module
    105. --with-stream_ssl_module enable ngx_stream_ssl_module
    106. --with-stream_realip_module enable ngx_stream_realip_module
    107. --with-stream_geoip_module enable ngx_stream_geoip_module
    108. --with-stream_geoip_module=dynamic enable dynamic ngx_stream_geoip_module
    109. --with-stream_ssl_preread_module enable ngx_stream_ssl_preread_module
    110. --without-stream_limit_conn_module disable ngx_stream_limit_conn_module
    111. --without-stream_access_module disable ngx_stream_access_module
    112. --without-stream_geo_module disable ngx_stream_geo_module
    113. --without-stream_map_module disable ngx_stream_map_module
    114. --without-stream_split_clients_module
    115. disable ngx_stream_split_clients_module
    116. --without-stream_return_module disable ngx_stream_return_module
    117. --without-stream_upstream_hash_module
    118. disable ngx_stream_upstream_hash_module
    119. --without-stream_upstream_least_conn_module
    120. disable ngx_stream_upstream_least_conn_module
    121. --without-stream_upstream_random_module
    122. disable ngx_stream_upstream_random_module
    123. --without-stream_upstream_zone_module
    124. disable ngx_stream_upstream_zone_module
    125. --with-google_perftools_module enable ngx_google_perftools_module
    126. --with-cpp_test_module enable ngx_cpp_test_module
    127. --add-module=PATH enable external module
    128. --add-dynamic-module=PATH enable dynamic external module
    129. --with-compat dynamic modules compatibility
    130. --with-cc=PATH set C compiler pathname
    131. --with-cpp=PATH set C preprocessor pathname
    132. --with-cc-opt=OPTIONS set additional C compiler options
    133. --with-ld-opt=OPTIONS set additional linker options
    134. --with-cpu-opt=CPU build for the specified CPU, valid values:
    135. pentium, pentiumpro, pentium3, pentium4,
    136. athlon, opteron, sparc32, sparc64, ppc64
    137. --without-pcre disable PCRE library usage
    138. --with-pcre force PCRE library usage
    139. --with-pcre=DIR set path to PCRE library sources
    140. --with-pcre-opt=OPTIONS set additional build options for PCRE
    141. --with-pcre-jit build PCRE with JIT compilation support
    142. --with-zlib=DIR set path to zlib library sources
    143. --with-zlib-opt=OPTIONS set additional build options for zlib
    144. --with-zlib-asm=CPU use zlib assembler sources optimized
    145. for the specified CPU, valid values:
    146. pentium, pentiumpro
    147. --with-libatomic force libatomic_ops library usage
    148. --with-libatomic=DIR set path to libatomic_ops library sources
    149. --with-openssl=DIR set path to OpenSSL library sources
    150. --with-openssl-opt=OPTIONS set additional build options for OpenSSL
    151. --with-debug enable debug logging

    一般情况下只需要配置--prefix(安装路径)即可:

    ./configure --prefix=/home/keepmoving/Nginx/nginx_install

     上述报错是缺少库,安装即可:

    yum -y install pcre-devel

     继续执行上述安装命令:

    这次报错仍然是缺少库,还是需要安装:

    yum install -y zlib-devel

    继续执行上述安装命令:

    接下来执行make命令

    再执行make install命令进行安装:

     此时安装完成,可以到安装路径去查看配置信息:

    启动nginx:

    此时可以在网页上进行访问:

     从上面进行中可以看到启动了一个worker进程,可以在配置文件中进行设置:

    参考博文:

    在CentOS上源码安装Nginx - 万博云计算 - 博客园

  • 相关阅读:
    基于Python+Html+Django+MySQL的数据库测试管理与构建平台 论文文档+毕业答辩PPT+项目源码及数据库文件
    原生IP是什么?如何测试代理是不是原生IP?
    UI设计原则背后的认知心理学 优漫动游
    网络网络层之(1)IPv4地址
    iOS中UIColor,CGColor,CIColor详解
    C#WPF视频播放器实例
    排序算法之归并排序
    【BP回归预测】改进的鲸鱼算法优化BP神经网络回归预测(多输入单输出)【含Matlab源码 2184期】
    市场渗透率不到1%,低代码产品未来发展趋势如何?
    Win11远程协助灰色无法勾选?Win11远程协助不能选择的解决方法
  • 原文地址:https://blog.csdn.net/weixin_44799217/article/details/128174776