菜单

Nginx命令安装完整教程

2019年8月5日 - 4166m金沙

下载nginx-0.8.54.tar.gz,解压并编译安装

nginx是一个http和反向代理服务器,在高并发环境下性能要比apache好,所以我们也在ubuntu下安装。 

Nginx can use the platform default package to install, this paper is to
introduce the use of source code compiler installation, including
compiling parameters of concrete information.

相关阅读:Nginx 0.8.54
发布下载修复三个bug

 

1、 GCC

Before the official start, the compiler environment GCC g+ + to develop
library, advance installed, here you have it installed by default.

apt-get install build-essentialapt-get install libtool

yum -y install gcc automake autoconf libtool make

yum install gcc gcc-c++

命令说明:

下载nginx-0.8.54.tar.gz,解压并编译安装 

2、PCRE

Following a formal start,We all need to install PCRE, zlib, the former
to override the rewrite, the latter for gzip compression.

1 selected source directory
Can be any directory, this paper selected is/usr/local/src

cd /usr/local/src

2 install the PCRE Library
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/
Download the latest PCRE source package, use the following command to
compile and install the PCRE package download:

cd /usr/local/src
wget
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.34.tar.gz
tar -zxvf pcre-8.34.tar.gz
cd pcre-8.34./configure
make
make install

tar(z-用 gzip
对存档压缩或解压;x-从存档展开文件;v-详细显示处理的文件;f-指定存档或设备)

命令说明: 

3、ZLIB

** install the zlib Library**
http://zlib.net/Zlib-1.2.8.tar.gz
download the latest zlib source package, use the following command to
compile and install the zlib package download:

cd /usr/local/src
wget
http://zlib.net/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gzcd zlib-1.2.8./configure
make
make install

tar –zxvf nginx-0.8.54.tar.gz

tar(z-用 gzip
对存档压缩或解压;x-从存档展开文件;v-详细显示处理的文件;f-指定存档或设备) 

4、SSL

installation SSL (some default VPS no SSL)

cd /usr/local/src
wget
http://www.openssl.org/source/openssl-1.0.1c.tar.gz
tar -zxvf openssl-1.0.1c.tar.gz

进入相关目录

Java代码  

5、Nginx

Installing nginx 5
Nginx generally has two versions, which are stable and development, you
can according to your purpose to select the two version of the one, the
following is to install Nginx on the detailed steps under the
/usr/local/nginx directory:

  • 1
    cd /usr/local/src
    wget
    http://nginx.org/download/nginx-1.4.2.tar.gz
    tar -zxvf nginx-1.4.2.tar.gz
    cd nginx-1.4.2

  • 2
    ./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=/usr/local/src/pcre-8.34
    –with-zlib=/usr/local/src/zlib-1.2.
    –with-openssl=/usr/local/src/openssl-1.0.1c

  • 3
    make
    make install

  • 4
    –with-pcre=/usr/src/Pcre-8.34 refers to the source path
    pcre-8.34.
    –with-zlib=/usr/src/Zlib-1.2.7 refers to the source path
    zlib-1.2.7.

After the success of the installation directory /usr/local/nginx

fastcgi.conf koi-win nginx.conf.default
fastcgi.conf.default logs scgi_params
fastcgi_params mime.types scgi_params.default
fastcgi_params.default
mime.types.default
uwsgi_params
html nginx uwsgi_params.default
koi-utf nginx.conf win-utf

netstat -ano|grep 80

If the implementation does not check the results, this step is ignored
(Ubuntu must use sudo to start, otherwise can only run in the
foreground)

sudo /usr/local/nginx/nginx

Open a browser to access this IP machine, if the browser Welcome to
nginx! That Nginx is installed and running successful.

Here nginx is installed, if only handle static HTML will not continue
the installation
If you need to deal with PHP script, you also need to install the
php-fpm.

The following installation debugging
Attached: possible error and some help information
1.1 compiler PCRE error

libtool: compile: unrecognized option
-DHAVE_CONFIG_H'libtool: compile: Trylibtool –help’ for more
information.make[1]: *** [pcrecpp.lo] Error 1make[1]: Leaving
directory `/usr/local/src/pcre-8.34’make: *** [all] Error 2

Solution: install the g+ +, don’t forget to configure

apt-get install g++apt-get install build-essentialmake
clean./configuremake

1.2 make error

make: *** No rule to make target build', needed bydefault’.
Stop../configure: error: SSL modules require the OpenSSL library.You
can either do not enable the modules, or install the OpenSSL
libraryinto the system, or build the OpenSSL library statically from
the sourcewith nginx by using –with-openssl=<path> option.

According to the installation or fourth step methodUbuntu

apt-get install opensslapt-get install libssl-dev

CentOS

yum -y install openssl openssl-devel

The 2.nginx compile option
Make is used to compile the instruction, which are read from the
Makefile, then compile.
Make install is used to install, also it reads the instructions from the
Makefile to the specified location, the installation.
The configure command is used to detect the target characteristics of
your installation platform. It defines the various aspects of the
system, including the nginx allowed connecting method of processing
using, for example, it will detect your Is it right? With CC or GCC, not
CC or GCC, which is a shell script, at the end of the execution, it will
create a Makefile file. The nginx configure command to support the
following parameters:

--prefix=path defines a directory, to store the file on the server, the installation of the directory is nginx. Use the default /usr/local/nginx.
The path to the
 --sbin-path=path setup nginx executable file, the default is prefix/sbin/nginx.
--conf-path=path settings in the nginx.conf configuration file path. Nginx allows the use of different configuration file to start, through the command line -c options. The default is prefix/conf/nginx.conf.
--pid-path=path set nginx.pid file, the main process of storage process of no.. After the installation is complete, can change the file name, use the PID command in the nginx.conf configuration file. By default, the file name prefix/logs/nginx.pid.
--error-log-path=path set the main errors, warnings, and diagnostic file name. After the installation is complete, can change the file name, use the nginx.conf configuration file in error_log instruction. By default, the file name prefix/logs/error.log.
The name 
--http-log-path=path set the main request the HTTP server log file. After the installation is complete, can change the file name, use the nginx.conf configuration file in access_log instruction. By default, the file name prefix/logs/access.log.
--user=name sets the nginx worker process user. After the installation is complete, the name can be changed at any time using in the nginx.conf configuration file in user instruction. The default user name is nobody.
User group 
--group=name set the nginx worker process. After the installation is complete, the name can be changed at any time using in the nginx.conf configuration file in user instruction. The default for non privileged users.
--with-select_module --without-select_module enable or disable the construction of a module to allow the server to use Select () method. This module will automatically set up, if the platform does not support kqueue, epoll, or rtsig/dev/poll.
--with-poll_module --without-poll_module enable or disable the construction of a module to allow the server to use poll () method. This module will automatically set up, if the platform does not support kqueue, epoll, or rtsig/dev/poll.
--without-http_gzip_module — Response module does not compile the compression of the HTTP server. Compile and run this module, zlib Library.
--without-http_rewrite_module does not compile the rewrite module. Compile and run the module requires PCRE library support.
--without-http_proxy_module — Does not compile the http_proxy module.
--with-http_ssl_module — Use the HTTPS protocol module. By default, this module is not construction. The establishment and operation of this module of the OpenSSL library is required.
--with-pcre=path — The source path set PCRE Library. PCRE library source code (version 4.4 - 8.30) need to be downloaded from the PCRE web site and decompression. The rest of the work is the Nginx / configure and make to complete the. Regular expressions are used in the location command and ngx_http_rewrite_module module.
--with-pcre-jit —Compile PCRE contains "just-in-time compilation" (1.1. 12, pcre_jit directive).
--with-zlib=path —The source path set zlib library. To download from the zlib (version 1.1.3 - 1.2.5) and decompression. The rest of the work is the Nginx / configure and make. The ngx_http_gzip_module module using zlib .
--with-cc-opt=parameters — Set additional parameters will be added to the CFLAGS variable. For example, need to use when you use the PCRE library on the FreeBSD: 
--with-cc-opt=" -I /usr/local/include. Such as the need to increase the select. (the number of) supported file: 
--with-cc-opt="-D FD_SETSIZE=2048".
--with-ld-opt=parameters —Set additional parameters, which will be used in the link during the. For example, when using the system in the FreeBSD PCRE library, should be specified:
 --with-ld-opt="-L /usr/local/lib".

Typical examples (here in order to show the need to write in a multi
line, implementation content needs to be on the same 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

**
转自:http://www.programering.com/a/MzM4ETMwATU.html\*\*

./configure

tar –zxvf nginx-0.8.54.tar.gz  

make

 

sudo make install

进入相关目录 

你要运气好的话,一切ok,不过相信没有人运气好的,哈哈。Ubuntu默认的策略是什么库都不装,依赖的库都需要自已手工安装搞定。估计CentOS等linux会好一些。

Java代码  

一般都会出错的,那么我们来看看可能出现的问题。

./configure  

常见问题解决

make  

缺少pcre library

sudo make install  

./configure: error: the HTTP rewrite module requires the PCRE library.

 

You can either disable the module by using
–without-http_rewrite_module

你要运气好的话,一切ok,不过相信没有人运气好的,哈哈。Ubuntu默认的策略是什么库都不装,依赖的库都需要自已手工安装搞定。估计CentOS等linux会好一些。 

option, or install the PCRE library into the system, or build the PCRE
library

一般都会出错的,那么我们来看看可能出现的问题。 

statically from the source with nginx by using –with-pcre=<path>
option.

 

解决方法:下载安装pcre-8.12解决问题,解压后对pcre进行如下操作

常见问题解决 

./configure

 

make

缺少pcre library 

sudo make install

./configure: error: the HTTP rewrite module requires the PCRE library. 

运气好一次通过,运气不好,make pcre时会出错

You can either disable the module by using
–without-http_rewrite_module 

缺少gcc-c++和libtool,也就是c++编译包

option, or install the PCRE library into the system, or build the PCRE
library 

libtool: compile: unrecognized option `-DHAVE_CONFIG_H’

statically from the source with nginx by using –with-pcre=<path>
option. 

libtool: compile: Try `libtool –help’ for more information.

 

make[1]: *** [pcrecpp.lo] Error 1

解决方法:下载安装pcre-8.12解决问题,解压后对pcre进行如下操作 

make[1]: Leaving directory `/home/guangbo/work/pcre-8.12′

Java代码  

make: *** [all] Error 2

./configure  

www.linuxidc.com@linuxidc-laptop:~/work/pcre-8.12$ libtool -help
-DHAVE_CONFIG_H

make  

The program ‘libtool’ is currently not installed.  You can install it by
typing:

sudo make install  

sudo apt-get install libtool

 

www.linuxidc.com@linuxidc-laptop:~/work/pcre-8.12$

运气好一次通过,运气不好,make pcre时会出错 

解决方法:需要先安装libtool和gcc-c++

 

sudo apt-get install libtool

缺少gcc-c++和libtool,也就是c++编译包 

sudo apt-get install gcc-c++

libtool: compile: unrecognized option `-DHAVE_CONFIG_H’ 

安装 gcc-c++出错

libtool: compile: Try `libtool –help’ for more information. 

www.linuxidc.com@linuxidc-laptop:~/soft/pcre-8.12$ sudo apt-get install
gcc-c++

make[1]: *** [pcrecpp.lo] Error 1    www.2cto.com 

Reading package lists… Done

make[1]: Leaving directory `/home/guangbo/work/pcre-8.12′ 

Building dependency tree

make: *** [all] Error 2 

Reading state information… Done

[email protected]:~/work/pcre-8.12$
libtool -help -DHAVE_CONFIG_H 

E: Couldn’t find package gcc-c

The program ‘libtool’ is currently not installed.  You can install it by
typing: 

解决办法:更新源,重新安装gcc-c++。

sudo apt-get install libtool 

sudo apt-get install build-essential

[email protected]:~/work/pcre-8.12$ 

sudo apt-get update #更新源

 

sudo apt-get install gcc-c++

解决方法:需要先安装libtool和gcc-c++ 

upgrade更新的话会花很长时间,如果不报错,可以不进行。

Java代码  

sudo apt-get upgrade #更新已安装的包,更新会很久

sudo apt-get install libtool  

缺少openssl库

sudo apt-get install gcc-c++  

./configure: error: the HTTP cache module requires md5 functions

 

from OpenSSL library.  You can either disable the module by using

安装 gcc-c++出错 

相关文章

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图