Install Nginx in Ubuntu

Source: Internet
Author: User
Module-dependent gzip module requires zlib library rewrite module requires pcre Library ssl function requires openssl library pre-compiled installation package Nginx will be available in some Linux releases and BSD variant versions of the installation package repository, you can use the software package management method that comes with each system to install it. Note that many pre-compiled installation packages are outdated. In most cases, it is recommended to compile them directly from the source code. Ubuntu (Deb Module dependencyThe gzip module requires the zlib library rewrite module, and the pcre Library ssl function requires the openssl library. Precompiled installation package

Nginx is available in the installation package repositories of some Linux distributions and different BSD variants. you can install Nginx by using the software package management method provided by each system. Note that many pre-compiled installation packages are outdated. In most cases, it is recommended to compile them directly from the source code.

Install the Ubuntu (Debian) Software Package

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

Ubuntu (Debian) source code compilation and Installation

1. Official source download http://nginx.org

2. Extract

  1. Tar zxvf nginx-1.0.12.tar.gz
3. Compile and install

For example:

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

*Ubuntu10.04 install openssl
Perform the following operations to install openssl and its development function library:

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

Install the PCRE Library

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

Compilation parameter description:

  • --prefix=path-Defines a directory that will keep server files. This same directory will also be used for all relative paths setconfigure(Could t for paths to libraries sources) and innginx.confConfiguration file. It is set to/usr/local/nginxDirectory by default.

    Nginx installation path. If not specified, the default value is/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 Executable File Installation path. It can only be specified during installation. If it is not specified, the default value is /Sbin/nginx.

  • --conf-path=path -Sets the name ofnginx.confConfiguration 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 namedprefix/conf/nginx.conf.

    The default nginx. conf path is not given with the-c option. If not specified, the default value is /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 innginx.confConfiguration file using the pid directive. By default the file is namedprefix/logs/nginx.pid.

    Specify the nginx. pid file name. After installation, the name can be modified in the nginx. cong file. If not specified, the default value is /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 innginx.confConfiguration file using the error_log directive. By default the file is namedprefix/logs/error.log.

    If the error_log command is not specified in nginx. conf, the default Error Log Path is used. If not specified, the default value is /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 innginx.confConfiguration 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 innginx.confConfiguration file using the user directive. The default user name is nobody.

    If no user command is specified in nginx. conf, the default nginx user is used. If not specified, the default value is 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 innginx.confConfiguration file using the user directive. By default, a group name is set to the name of an unprivileged user.

    If no user command is specified in nginx. conf, the default group used by nginx is used. If not specified, the default value is nobody.

  • --with-select_module
    --without-select_module-Enables or disables building a module that allows the server to work withselect()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 withpoll()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.

    Disable 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.

    Enable the http ssl module so that NGINX can support HTTPS requests. OPENSSL must be installed for this module.

  • --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.

    Specifies the path of the PCRE Library. (PCRE is the Regular Expression Library)

  • --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"Shocould be specified. If the number of files supportedselect()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"Shocould be specified.


Example:

  1. ./Configure
  2. -- Sbin-path =/usr/local/nginx
  3. -- Conf-path =/usr/local/nginx. conf
  4. -- Pid-path =/usr/local/nginx. pid
  5. With-http_ssl_module
  6. -- With-pcre = ../pcre-4.4
  7. -- With-zlib = ../zlib-1.1.3

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.