在Linux上安装nginx

bab*_*ak6 6 nginx

我从它的linux网站下载了nginx(我使用的是ubuntu 10.4).我提取了nginx-1.0.6.tar.gz并且该目录中有一个配置文件.所以我在shell中输入了"./configure"命令.它似乎配置正确.在我输入"make"命令后,它说了这个错误:

make -f objs/Makefile
make[1]: Entering directory `/usr/local/nginx'
cd ./auto/lib/pcre/ \
    && if [ -f Makefile ]; then make distclean; fi \
    && CC="gcc" CFLAGS="-O2 -fomit-frame-pointer -pipe " \
    ./configure --disable-shared
/bin/sh: ./configure: not found
make[1]: *** [auto/lib/pcre//Makefile] Error 127
make[1]: Leaving directory `/usr/local/nginx'
make: *** [build] Error 2
Run Code Online (Sandbox Code Playgroud)

我现在应该怎么做?

Vam*_*a B 5

你必须安装依赖项.通常这些就足够了

libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
Run Code Online (Sandbox Code Playgroud)

所以你可以先安装它们

sudo apt-get install libpcre3 libpcre3-dev libpcrecpp0 libssl-dev zlib1g-dev
Run Code Online (Sandbox Code Playgroud)

然后编译..还要确保以root身份运行make命令.


小智 5

Nginx的./configure程序要查找共享库以动态链接来构建Nginx,或者要分别找到openssl prce和zlib的源。当您使用错误的选项调用../nginx/configure时,会发生上述错误。

--with-pcre=/path/to/lib         # where libpcre.a resides
--with-openssl=/path/to/lib      # where libssl.a resides
--with-zlib=/path/to/lib         # where libz.a resides
Run Code Online (Sandbox Code Playgroud)

是错误的,尤其是当ld.so不了解这些库时

如果您构建nginx的静态链接版本,请尝试

    --with-pcre=/path/to/src/of/pcre         
    --with-openssl=/path/to/src/of/openssl     
    --with-zlib=/path/to/src/of/zlib

e.g.
--with-pcre=../pcre-8.36 --with-openssl=../openssl-1.0.2 --with-zlib=../zlib-1.2.8
Run Code Online (Sandbox Code Playgroud)

  • 可以说这是最好的答案-其他包括解决方案,这说明了正在发生的事情。 (2认同)