竞博体育 > 编程 > 设置nginx.pid文件的名字,  ssl 功能需要 openssl 库

设置nginx.pid文件的名字,  ssl 功能需要 openssl 库

源码编译安装Nginx

编译过程是通过configure命令配置的。这定义了有关系统的各个方面,包括nginx允许的处理连接数。最后会创建一个Makefile文件。configure命令支持下面的参数。

--prefix=path 定义保存服务器文件的目录。这个目录页被用于通过configure设置的和nginx.conf设置的相对路径。默认被设置为/usr/local/nginx目录。

--sbin-path=path 设置nginx可执行文件的名称。这个名字在安装的时候才会被使用。默认文件名字为prefix/sbin/nginx

--conf-path=path 设置nginx.conf配置文件的名称。如果需要的话,nginx可以使用-c file来指定一个不同的配置文件。默认文件名为prefix/conf/nginx.conf

--pid-path=path 设置nginx.pid文件的名字,存储着主进程的ID号。安装之后,文件名可以在nginx.conf文件里设置。默认文件名为prefix/logs/nginx.pid

--error-log-path=path 设置错误,警告和诊断的文件。在安装后,文件名可以在nginx.conf 文件里通过error_log指令改变。默认文件名字为prefix/logs/error.log

--http-log-path=path 设置HTTP服务器请求的日志文件名称。在安装之后,名字可以在nginx.conf文件里面使用access_log指令改变。默认文件名为prefix/logs/access.log

--user=name 设置worker进程的非特权用户。在安装之后,可以在nginx.conf文件里面使用user指令改变。默认用户名为nobody

--group=name 设置worker进程的组。安装之后可以在nginx。conf里面通过user指令改变。默认组名被设置为非特权用户的名字。

--with-select_module

--without-select_module 允许或禁止编译服务器使用select()方法工作。如果平台上没有合适的方法找到,例如kqueue,epoll,或者/dev/poll,那么这个模块会自动编译。

--with-poll_module

--without-poll_module 允许或禁止服务器工作在poll()方式。如果平台上没有合适的方法像kqueue,epoll或者/dev/poll,那么这个模块会自动编译。

--without-http_gzip_module 禁止编译压缩HTTP服务器回复的模块。要想编译和运行这么模块,那么需要zlib库的支持。

--without-http_rewrite_module 禁止编译HTTP重定向请求的模块。为了编译这个模块,PCRE库需要事先准备好。

--without-httpd_proxy_module 禁止编译HTTP服务器代理模块

--with-http_ssl_module 允许编译支持HTTPS协议的模块。默认没编译。为了编译和运行这个模块,OpenSSL库是需要的。

--with-pcre=path 设置PCRE源码的路径,这个库发需要从PCRE网站下载。这个库需要被正则表达式localtion指令支持。和ngx_http_rewrite_module。

--with-zlib=path 设置zlib库的源位置,这个库需要从官网下载这个库依靠http_gzip模块。

-with-ld-opt=parameters 设置在链接时候的额外的参数

案例:

./configure

  --sbin-path=/usr/local/nginx/nginx

  --conf-path=/usr/local/nginx/nginx.conf 

  --pid-path=/usr/local/nginx/nginx.pid

  --with-http_ssl_module

  --with-pcre=../pcre-4.4

  --with-zlib=../zlib-1.1.3

配置之后,nginx可以使用make编译和安装。

The build is configured using the configure command.It defines various aspects of the system, including the methods nginx isallowed to use for connection processing. At the end it creates aMakefile. The configure commandsupports the following parameters:

--prefix=path — defines a directorythat will keep server files. This same directory will also be used for allrelative paths set by configure (except for paths to librariessources) and in the nginx.conf configuration file. It is set to the /usr/local/nginx directoryby default.

--sbin-path=path — sets the name of annginx executable file. This name is used only during installation. By defaultthe file is named prefix/sbin/nginx.

--conf-path=path — sets the name of an nginx.conf configurationfile. If needs be, nginx can always be started with a different configurationfile, by specifying it in the command-line parameter -c file. Bydefault the file is named prefix/conf/nginx.conf.

--pid-path=path — sets the name of annginx.pid file that will store the process ID of the main process. Afterinstallation, the file name can always be changed in the nginx.confconfigurationfile using the pid directive.By default the file is named prefix/logs/nginx.pid.

--error-log-path=path — sets the nameof the primary error, warnings, and diagnostic file. After installation, thefile name can always be changed in the nginx.conf configuration fileusing the error_log directive.By default the file is named prefix/logs/error.log.

--http-log-path=path — sets the nameof the primary request log file of the HTTP server. After installation, thefile name can always be changed in the nginx.conf configuration fileusing the access_log directive.By default the file is named prefix/logs/access.log.

--user=name — sets the name of anunprivileged user whose credentials will be used by worker processes. Afterinstallation, the name can always be changed in the nginx.conf configurationfile using the user directive.The default user name is nobody.

--group=name — sets the name of agroup whose credentials will be used by worker processes. After installation,the name can always be changed in the nginx.conf configuration fileusing the user directive.By default, a group name is set to the name of an unprivileged user.

--with-select_module
--without-select_module — enables or disables building a module thatallows the server to work with the select() method. This module isbuilt automatically if the platform does not appear to support more appropriatemethods such as kqueue, epoll, or /dev/poll.

--with-poll_module
--without-poll_module — enables or disables building a module that allowsthe server to work with the poll() method. This module is builtautomatically if the platform does not appear to support more appropriatemethods such as kqueue, epoll, or /dev/poll.

--without-http_gzip_module — disablesbuilding a module that compressesresponses of an HTTP server. The zlib library is required tobuild and run this module.

--without-http_rewrite_module —disables building a module that allows an HTTP server toredirectrequests and change URI of requests. The PCRE library is required tobuild and run this module.

--without-http_proxy_module — disablesbuilding an HTTP server proxyingmodule.

--with-http_ssl_module — enablesbuilding a module that adds the HTTPSprotocol support to an HTTP server. This module is not built bydefault. The OpenSSL library is required to build and run this module.

--with-pcre=path — sets the path tothe sources of the PCRE library. The library distribution (version 4.4 —8.32) needs to be downloaded from the PCRE siteand extracted. The rest is done by nginx’s ./configure and make.The library is required for regular expressions support in the location directiveand for the ngx_竞博体育app下载 ,http_rewrite_module module.

--with-pcre-jit — builds the PCRElibrary with “just-in-time compilation” support (1.1.12, the pcre_jit directive).

--with-zlib=path — sets the path tothe sources of the zlib library. The library distribution (version 1.1.3 —1.2.7) needs to be downloaded from the zlib siteand extracted. The rest is done by nginx’s ./configure and make.The library is required for the ngx_http_gzip_modulemodule.

--with-cc-opt=parameters — setsadditional parameters that will be added to the CFLAGS variable. When using thesystem PCRE library under FreeBSD, --with-cc-opt="-I/usr/local/include"should be specified. If the number of files supportedby select() needs to be increased it can also be specified here suchas this: --with-cc-opt="-D FD_SETSIZE=2048".

--with-ld-opt=parameters — setsadditional parameters that will be used during linking. When using the systemPCRE library under FreeBSD, --with-ld-opt="-L /usr/local/lib" shouldbe specified.

Example of parameters usage (all of thisneeds to be typed in one line):

./configure

    --sbin-path=/usr/local/nginx/nginx

  --conf-path=/usr/local/nginx/nginx.conf

  --pid-path=/usr/local/nginx/nginx.pid

  --with-http_ssl_module

  --with-pcre=../pcre-4.4

  --with-zlib=../zlib-1.1.3

After configuration, nginx is compiled andinstalled using make.

CentOS 6.2实战部署Nginx+MySQL+PHP

使用Nginx搭建WEB服务器

搭建基于Linux6.3+Nginx1.2+PHP5+MySQL5.5的Web服务器全过程

CentOS 6.3下Nginx性能调优

CentOS 6.3下配置Nginx加载ngx_pagespeed模块

CentOS 6.4安装配置Nginx+Pcre+php-fpm

Nginx安装配置使用详细笔记

Nginx日志过滤 使用ngx_log_if不记录特定日志

Nginx 的详细介绍:请点这里
Nginx 的下载地址:请点这里

本文永久更新链接地址:

编译过程是通过configure命令配置的。这定义了有关系统的各个方面,包括nginx允许的处理连接数。最后会创建一个Makefil...

模块依赖性

  gzip 模块需要 zlib 库

  rewrite 模块需要 pcre 库

  ssl 功能需要 openssl 库

预先编译好的安装包

  Nginx在一些Linux发行版和BSD的各个变种版本的安装包仓库中都会有,通过各个系统自带的软件包管理方法即可安装。需要注意的是,很多预先编译好的安装包都比较陈旧,大多数情况下还是推荐直接从源码编译。

Ubuntu(Debian)软件包安装

  1. apt-get update  
  2. apt-get install nginx  

Ubuntu(Debian)源码编译安装

1. 官方源码下载 http://nginx.org

  1.  解压缩

  2. tar zxvf nginx-1.0.12.tar.gz  

  3. 编译安装

如:

  1. ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --with-http_ssl_module  

* Ubuntu10.04安装openssl
执行如下操作来安装openssl及其开发函数库:

  1. $ sudo apt-get install openssl  
  2. $ sudo apt-get install libssl0.9.8  
  3. $ sudo apt-get install libssl-dev  

PCRE库安装

  1. sudo apt-get update   
  2. sudo apt-get install libpcre3 libpcre3-dev   

编译参数说明:

  • --prefix=path — defines a directory that will keep server files. This same directory will also be used for all relative paths set byconfigure (except for paths to libraries sources) and in the nginx.conf configuration file. It is set to the /usr/local/nginx directory by default. 

    Nginx安装路径。如果没有指定,默认为 /usr/local/nginx。

  • --sbin-path=path — sets the name of an nginx executable file. This name is used only during installation. By default the file is namedprefix/sbin/nginx.

    Nginx可执行文件安装路径。只能安装时指定,如果没有指定,默认为<prefix>/sbin/nginx。

  • --conf-path=path — sets the name of an nginx.conf configuration file. If needs be, nginx can always be started with a different configuration file, by specifying it in the command-line parameter -c file. By default the file is named prefix/conf/nginx.conf.

    在没有给定-c选项下默认的nginx.conf的路径。如果没有指定,默认为<prefix>/conf/nginx.conf。

  • --pid-path=path — sets the name of an nginx.pid file that will store the process ID of the main process. After installation, the file name can always be changed in the nginx.conf configuration file using the pid directive. By default the file is namedprefix/logs/nginx.pid.

    指定nginx.pid的文件名,安装后该名字可以在nginx.cong文件中修改。如果没有指定,默认为 <prefix>/logs/nginx.pid。

  • --error-log-path=path — sets the name of the primary error, warnings, and diagnostic file. After installation, the file name can always be changed in the nginx.conf configuration file using the error_log directive. By default the file is namedprefix/logs/error.log.

    在nginx.conf中没有指定error_log指令的情况下,默认的错误日志的路径。如果没有指定,默认为 <prefix>/logs/error.log。

  • --http-log-path=path — sets the name of the primary request log file of the HTTP server. After installation, the file name can always be changed in the nginx.conf configuration file using the access_log directive. By default the file is namedprefix/logs/access.log.

  • --user=name — sets the name of an unprivileged user whose credentials will be used by worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. The default user name is nobody.

    在nginx.conf中没有指定user指令的情况下,默认的nginx使用的用户。如果没有指定,默认为 nobody。

  • --group=name — sets the name of a group whose credentials will be used by worker processes. After installation, the name can always be changed in the nginx.conf configuration file using the user directive. By default, a group name is set to the name of an unprivileged user.

    在nginx.conf中没有指定user指令的情况下,默认的nginx使用的组。如果没有指定,默认为 nobody。

  • --with-select_module
    --without-select_module — enables or disables building a module that allows the server to work with the select() method. This module is built automatically if the platform does not appear to support more appropriate methods such as kqueue, epoll, rtsig, or /dev/poll.

  • --with-poll_module
    --without-poll_module — enables or disables building a module that allows the server to work with the poll() method. This module is built automatically if the platform does not appear to support more appropriate methods such as kqueue, epoll, rtsig, or /dev/poll.

  • --without-http_gzip_module — disables building a module that compresses responses of an HTTP server. The zlib library is required to build and run this module.

  • --without-http_rewrite_module — disables building a module that allows an HTTP server to redirect requests and change URI of requests. The PCRE library is required to build and run this module. The module is experimental — its directives may change in the future.

    禁用 ngx_http_rewrite_module. 

  • --without-http_proxy_module — disables building an HTTP server proxying module.

  • --with-http_ssl_module — enables building a module that adds the HTTPS protocol support to an HTTP server. This module is not built by default. The OpenSSL library is required to build and run this module.

    开启HTTP SSL模块,使NGINX可以支持HTTPS请求。这个模块需要已经安装了OPENSSL

  • --with-pcre=path — sets the path to the sources of the PCRE library. The library distribution (version 4.4 — 8.21) needs to be downloaded from the PCRE site and extracted. The rest is done by nginx's ./configure and make. The library is required for regular expressions support in the location directive and for the ngx_http_rewrite_module module.

    指定PCRE库路径。(PCRE为正则表达式库)

  • --with-pcre-jit — builds the PCRE library with “just-in-time compilation” support.

  • --with-zlib=path — sets the path to the sources of the zlib library. The library distribution (version 1.1.3 — 1.2.5) needs to be downloaded from the zlib site and extracted. The rest is done by nginx's ./configure and make. The library is required for thengx_http_gzip_module module.

  • --with-cc-opt=parameters — sets additional parameters that will be added to the CFLAGS variable. When using the system PCRE library under FreeBSD, --with-cc-opt="-I /usr/local/include" should be specified. If the number of files supported by select()needs to be increased it can also be specified here such as this: --with-cc-opt="-D FD_SETSIZE=2048".

  • --with-ld-opt=parameters — sets additional parameters that will be used during linking. When using the system PCRE library under FreeBSD, --with-ld-opt="-L /usr/local/lib" should be specified.

示例:

  1. ./configure  
  2.     --sbin-path=/usr/local/nginx/nginx  
  3.     --conf-path=/usr/local/nginx/nginx.conf  
  4.     --pid-path=/usr/local/nginx/nginx.pid  
  5.     --with-http_ssl_module  
  6.     --with-pcre=../pcre-4.4  
  7.     --with-zlib=../zlib-1.1.3  

竞博体育app下载 1

下一篇:没有了
  • 首页
  • 电话
  • 软件