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

** 轉(zhuǎn)自:http://www.programering.com/a/MzM4ETMwATU.html**

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末看靠,一起剝皮案震驚了整個(gè)濱河市摔桦,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌好芭,老刑警劉巖燃箭,帶你破解...
    沈念sama閱讀 218,858評(píng)論 6 508
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異舍败,居然都是意外死亡招狸,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,372評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門(mén)邻薯,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái)裙戏,“玉大人,你說(shuō)我怎么就攤上這事厕诡±郯瘢” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 165,282評(píng)論 0 356
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)壹罚。 經(jīng)常有香客問(wèn)我葛作,道長(zhǎng),這世上最難降的妖魔是什么猖凛? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 58,842評(píng)論 1 295
  • 正文 為了忘掉前任赂蠢,我火速辦了婚禮,結(jié)果婚禮上辨泳,老公的妹妹穿的比我還像新娘虱岂。我一直安慰自己,他們只是感情好菠红,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,857評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布第岖。 她就那樣靜靜地躺著,像睡著了一般途乃。 火紅的嫁衣襯著肌膚如雪绍傲。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 51,679評(píng)論 1 305
  • 那天耍共,我揣著相機(jī)與錄音烫饼,去河邊找鬼。 笑死试读,一個(gè)胖子當(dāng)著我的面吹牛杠纵,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播钩骇,決...
    沈念sama閱讀 40,406評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼比藻,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了倘屹?” 一聲冷哼從身側(cè)響起银亲,我...
    開(kāi)封第一講書(shū)人閱讀 39,311評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎纽匙,沒(méi)想到半個(gè)月后务蝠,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 45,767評(píng)論 1 315
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡烛缔,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,945評(píng)論 3 336
  • 正文 我和宋清朗相戀三年馏段,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片践瓷。...
    茶點(diǎn)故事閱讀 40,090評(píng)論 1 350
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡院喜,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出晕翠,到底是詐尸還是另有隱情喷舀,我是刑警寧澤,帶...
    沈念sama閱讀 35,785評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站元咙,受9級(jí)特大地震影響梯影,放射性物質(zhì)發(fā)生泄漏巫员。R本人自食惡果不足惜庶香,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,420評(píng)論 3 331
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望简识。 院中可真熱鬧赶掖,春花似錦、人聲如沸七扰。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 31,988評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)颈走。三九已至膳灶,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間立由,已是汗流浹背轧钓。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 33,101評(píng)論 1 271
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留锐膜,地道東北人毕箍。 一個(gè)月前我還...
    沈念sama閱讀 48,298評(píng)論 3 372
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像道盏,于是被迫代替她去往敵國(guó)和親而柑。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 45,033評(píng)論 2 355

推薦閱讀更多精彩內(nèi)容