Nginx命令安装完整教程-Linux

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.

1、 GCC

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

  • The ububtu platform compiler can use the following command

apt-get install build-essentialapt-get install libtool

  • CentOS platform compiler environment using the following command
    Install make:

yum -y install gcc automake autoconf libtool make

  • Install g++:

yum install gcc gcc-c++

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

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

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

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:

  • 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

  • 6 bootTo ensure that the 80 port system is not being used by another program, run the /usr/local/nginx/nginx command to start the Nginx,

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**

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,482评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,377评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,762评论 0 342
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,273评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,289评论 5 373
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,046评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,351评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 36,988评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,476评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,948评论 2 324
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,064评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,712评论 4 323
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,261评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,264评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,486评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,511评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,802评论 2 345

推荐阅读更多精彩内容