无法在configuration脚本中从源代码安装nginx

我正在使用Vagrant为我的一个项目构build可重复的虚拟机。 这个虚拟机需要一个基本的LEMP堆栈,并且在创build之后使用一个shell脚本来configuration它。

我遇到麻烦的部分是从源安装nginx。 configuration脚本如下所示:

#!/bin/bash # nginx settings NGINX_VERSION=1.4.7 NGINX_SOURCE=http://nginx.org/download/nginx-$NGINX_VERSION.tar.gz echo "==> Installing required packages and upgrading" apt-get -u update apt-get install make echo "==> Checking if nginx is installed" if [ ! -e /opt/nginx-$NGINX_VERSION ] then echo "==> nginx not installed, installing nginx $NGINX_VERSION" # Download nginx to /usr/src and cd into the extracted directory cd /usr/src wget $NGINX_SOURCE tar xf nginx-$NGINX_VERSION.tar.gz cd nginx-$NGINX_VERSION # Configure nginx ./configure --with-pcre --with-http_ssl_module --with-http_spdy_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_stub_status_module --prefix=/opt/nginx-$NGINX_VERSION # Make nginx and install it make make install fi 

该进程在makemake install步骤失败,产生以下错误:

 make: *** No rule to make target `build', needed by `default'. Stop. make: *** No rule to make target `install'. Stop. 

我不得不在脚本的开始安装使用apt-get ,因为我使用的图像尚未安装。 该映像是Ubuntu Server 12.04 64位映像。

我已经validation了nginx在脚本运行后通过检查usr/src目录被成功下载和解压缩。

使用search错误不会返回任何有用的东西,我可以使用,因为它们都是特定于安装我不使用的软件。

有任何想法吗?

有些图书馆缺失时会发生这种情况。 正如我所看到的,这是一种尝试和错误的情况。

例如:您需要为Nginx安装PCRE库进行编译。 尝试这个:

 apt-get install libpcre3 libpcre3-dev apt-get install openssl apt-get install libssl-dev 

如果它不起作用,还有其他东西丢失…就像我的情况一样。

编辑:也请确保你已经安装了zlib

 apt-get install --reinstall zlibc zlib1g zlib1g-dev 

此外,我切换到最新版本的nginx,然后我能够编译。

我没有看到你为什么要从源代码安装NginX的原因,因为你没有说任何理由。 所以我只是从官方网站上离开这里:

对于Ubuntu,将codenamereplacecodename Ubuntu发行代号,并将以下内容添加到/etc/apt/sources.list文件的末尾:

 deb http://nginx.org/packages/mainline/ubuntu/ codename nginx deb-src http://nginx.org/packages/mainline/ubuntu/ codename nginx 

对于Debian / Ubuntu,然后运行以下命令:

 apt-get update apt-get install nginx 

Ubuntu的:

 Version Codename Supported Platforms 12.04 precise x86_64, i386 14.04 trusty x86_64, i386, aarch64/arm64 16.04 xenial x86_64, i386, ppc64el, aarch64/arm64 16.10 yakkety x86_64, i386