linux安装nginx方法,lnmp安装之安装nginx

原来呢,我说我要出这个教程的,那么今天,教程来了linux安装nginx方法,lnmp安装之安装nginx,今天咱们实践一下,教一下这个手动搭建nginx方法。

大家还得记得这篇文章吗除了宝塔面板还有什么面板?linux面板都有那些? 那个时候我说过我要出一个教程,手工搭建lnmp环境方法,一直到现在,我才开始出教程,,以前我记得我学的挺好,但是前几天我搭建发现搭建不上,老是出一些问题,于是乎,我又看了一下书上的东西,现在呢,再次过来出这个教程。

linux安装nginx方法,lnmp安装之安装nginx插图

大家呢?如果有能力的可以跟着来搭建,本篇教程先教nginx搭建,咱们分好几篇去,一个一个教,之后再教php搭建,ftp 搭建什么的,现在先搭建这个nginx,过一段时间的我再分享一个一键搭建lnmp脚本,用那个可以一键搭建。

Nginx安装

Nginx的安装比较简单,首先通过wget命令从官网下载Nginx服务器安装包,如下所示。

[root@localhost-]# wget http://nginx.org/download/nginx-1.12.0.tar.gz
_-2018-07-20 01:11:17-- http://nginx.org/download/nginx-1.12.0.tar.gz
正在解析主机 ngix.org (ngimx.org).. 206.251.255.63,95.211.80.227,2001:laf8:4060:a004:21:e3...
正在连接 nginx.org(nginx.org)1206.251.255.631:80.已连接。
已发出 HTTP请求,正在等待回应...302 Found
位置:http://101.44.1.117/iles/1087000006B99A3C/nginx.org/download/nginx-1.12.0.tar-gz|跟随至新
的URL]
--2018-07-2001:11:18--
+ gcc version: 4.8.5 20150623 (Red Hat 4.8.5-16) (GCC)
checking for gec -pipe switch ... found
checking for -Wl,-E switch ... found
checking for gec builtin atomic operations .. found
checking for C99 variadic macros.. found
...…省略部分文字……
lconfigure; error; the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_ rewrite_module 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.

下载完成后,通过tar命令将压缩包解压,如下所示。

[root@localhost~]#tar -zxvf nginx-1.12.0.tar.gz

nginx-1.12.0/

nginx-1.12.0/auto/

nginx-1.12.0/conf/

nginx-1.12.0/contrib/

nginx-1.12.0/src/

nginx-1.12.0/configure nginx-1.12.0/LICENSE nginx-1.12.0/README

切换进入Nginx目录下,执行目录下的/configure文件检查系统环境,如果有缺少的软件,则需要我们进行安装,如下所示。

[root@localhost~]# cd nginx-1.12.0/

[root@localhost nginx-1.12.0]# ./configure

checking for OS

+ Linux 3.10.0-693.el7.x86_64 x86_64

checking for C compiler … found

+ using GNU C compiler

此时提示需要PCRE的库,如系统中没有安装,我们可以通过yum一次性安装多个依赖包,以防后续的提示,如下所示。

[root@localhost.nginx-1.12.01# yum -y install zlib zlib-devel openssl openssl–devel pere pere-devel

安装完成后重新执行,/configure,此时输出如下所示。

linux安装nginx方法,lnmp安装之安装nginx插图1

 

其中最下面显示了安装以后的路径,这个可以自行更改,这里采用默认的路径即可。随后通过make命令进行编译,如下所示。

 

[root@localhost nginx-1.12.0]# make
make -fobjs/Makefile
make[1]:进入目录“/root/nginx-1.12.0”
cc -c -pipe -O -W. -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/
event -I src/event/modules-I src/os/unix -lobjs |
-o objs/src/core/nginx.o \
src/core/nginx.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/
event -I sre/event/modules -I src/os/unix -I objs I
-o objs/src/core/ngx_log.o \
src/core/ngx_log.c
cc -c -pipe -O -W -Wall -Wpointer-arith -Wno-unused-parameter -Werror -g -I src/core -I src/
event -I src/event/modules -I src/os/unix -I objs I
-o objs/src/core/ngx_palloc.o |
src/core/ngx_palloc.c
……省略部分文字……
objs/src/http/modules/ngx_http_upstream_zone_module.ol
objs/ngx_modules.o I
-Idl -Ipthread -lerypt-lpcre -1z\
-Wl,-E
sed -e "sl%%PREFIX%%cl/usr/local/nginx/"\
-e "sl%%PID_PATH%%l/usr/local/nginx/logs/nginx.pid/"\
-e "sl%%eCONF_PATH%%V/usr/local/nginx/conf/nginx.confl"\
-e "sl%%ERROR_LOG_PATH%%/usr/local/nginx/logs/error.logl"4
< man/nginx.8 > objs/nginx.8
make[1]: 离开目录“/root/nginx-1.12.0°

编译完成后,可以执行安装命令了,同样通过make命令进行安装,make后添加上install执行安装,如下所示。

 

[root@localhost nginx-1.12.0]# make install
make -f objs/Makefile install
make[1]:进入目录“/root/nginx-1.12.0”
test -d'/usr/local/nginx' ll mkdir -p'/usr/local/nginx'
test -d'/usr/local/nginx/in'\
Il mkdir -p'/usr/local/nginx/in'test!-f'/usr/local/nginx/in/nginx'\Il mv'/usr/local/nginx/in/nginx"\
'/usr/ocal/nginx/in/nginx.old/cp objs/nginx'/usr/local/nginx/in/nginx test -d'/usr/ocal/nginx/conf\
Il mkdir -p'/usr/local/nginx/conf cp conf/koi-win '/usr/local/nginx/conf cp conf/koi-utf'/usr/local/nginx/conf"cp conf/win-utf '/usr/local/nginx/conf

安装完成后,执行Nginx的执行文件,如下所示。[root@localhost nginx-1.12.0}# /usr/local/nginx/in/nginx

现在已经能完成了,本教程我写的都有点迷糊,感觉弄的有点不对劲,我自己看的都迷糊,大家凑合着理解。

© 版权声明
THE END
喜欢就亲吻一下吧
分享
评论 抢沙发
头像
评论一下幻城的文章吧
提交
头像

昵称

取消
昵称代码图片

    暂无评论内容