Linux中nginx手动安装

本分类下有一个环境一键安装.那这背后发生了什么呢?咱们手动使用源码进行安装.
1.首先保证有一个能联网的centos.
2.百度 ningx 官网   点download  http://nginx.org/en/download.html  找到最新版的nginx下载地址. 发贴时最新的是1.12 http://nginx.org/download/nginx-1.12.0.tar.gz
3.进行centos  执行命令   

[Shell] 纯文本查看 复制代码
?
1
2
3
4
#安装wget
yum install wget -y
#安装gcc和c++编译器
yum install gcc gcc-c++ -y


4.新建临时目录  /temp  然后下载并解压. 命令如下

[Shell] 纯文本查看 复制代码
?
1
2
3
4
5
mkdir /temp ;
cd /temp ;
wget http: //nginx .org /download/nginx-1 .12.0. tar .gz
tar zxvf . /nginx-1 .12.0. tar .gz
cd /temp/nginx-1 .12.0


得到目录

[root@localhost nginx-1.12.0]# pwd
/temp/nginx-1.12.0
[root@localhost nginx-1.12.0]# ll
total 724
drwxr-xr-x. 6 1001 1001   4096 Apr 17 11:42 auto
-rw-r--r--. 1 1001 1001 277049 Apr 12 22:46 CHANGES
-rw-r--r--. 1 1001 1001 421985 Apr 12 22:46 CHANGES.ru
drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 conf
-rwxr-xr-x. 1 1001 1001   2481 Apr 12 22:46 configure
drwxr-xr-x. 4 1001 1001   4096 Apr 17 11:42 contrib
drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 html
-rw-r--r--. 1 1001 1001   1397 Apr 12 22:46 LICENSE
drwxr-xr-x. 2 1001 1001   4096 Apr 17 11:42 man
-rw-r--r--. 1 1001 1001     49 Apr 12 22:46 README
drwxr-xr-x. 9 1001 1001   4096 Apr 17 11:42 src


5.linux三大安装步骤   配置,编译,安装  第一步,配置
--prefix=/安装后的路径  注意这基本是所有安装程序的通用的配置属性
输入命令

[Shell] 纯文本查看 复制代码
?
1
. /configure --prefix= /usr/local/nginx-mytest



接下来会报错 如下

./configure: 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.


咱们需要安装一个这样的环境对能继续 . 根据上面的意思.咱们先安装 pcre 再指定路径 指定方法在上面就是 --with-pcre=<path>
6.安装pcre.百度这个词得到官网. 然后找到下载路径如下
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/  这里面有一些列表.咱们找到最新的即可 . 目前是
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz下载,解压,编译

[Shell] 纯文本查看 复制代码
?
1
2
3
4
mkdir /temp ;
cd /temp ;
wget ftp : //ftp .csx.cam.ac.uk /pub/software/programming/pcre/pcre-8 .39. tar .gz
tar zxvf pcre-8.39. tar .gz

到此得到了pcre的源码路径 为/temp/pcre-8.39
7.上一步得到安装路径/usr/local/pcre-8.39  接下来咱们从新编译 nginx 注意别忘记  --with-pcre=<path>

[Shell] 纯文本查看 复制代码
?
1
2
cd /temp/nginx-1 .12.0
. /configure --prefix= /usr/local/nginx-mytest   --with-pcre= /temp/pcre-8 .39



发现完成

如果报错Nginx编译安装错误error: the HTTP gzip module requires the zlib library

则需要安装“zlib-devel”即可。SSH执行以下命令:

 代码如下复制代码

yum install -y zlib-devel

然后再进行nginx的编译。表示问题即可解决。


第二个命令就是 make   也就是编译, 一般可以跟第三步一起执行,第三步是make install  .所以我们得到命令

[Shell] 纯文本查看 复制代码
?
1
make && make install



接下来去/usr/local/nginx-mytest看看吧.安装成功了

 

启动nginx:
/usr/local/nginx-mytest/sbin/nginx

转载于:https://www.cnblogs.com/ghjbk/p/6722291.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值