您的位置:首页 > 运维架构 > Nginx

Linux安装nginx

2015-11-15 14:27 513 查看
安装PCRE:

http://sourceforge.net/projects/pcre/files/pcre/

这里下载最新的PRCE 

然后进行安装:

解压到opt下的pcre 文件夹中

tar -xf  pcre-8.37.tar 

然后再 /usr/local/下创建软链

ln -s /opt/pcre/pcre-8.37 pcre

然后再pcre中创建

vim cc.sh

./configure --prefix=/usr/local/pcre ##pcre的安装路径

然后执行cc.sh

如果执行的时候提示 configure: error: You need a C++ compiler for C++ support.

那么执行 

yum install -y gcc gcc-c++

显示安装信息:
pcre-8.37 configuration summary:

    Install prefix .................. : /usr/local/pcre
    C preprocessor .................. : gcc -E
    C compiler ...................... : gcc
    C++ preprocessor ................ : g++ -E
    C++ compiler .................... : g++
    Linker .......................... : /usr/bin/ld -m elf_x86_64
    C preprocessor flags ............ :
    C compiler flags ................ : -g -O2 -fvisibility=hidden
    C++ compiler flags .............. : -O2 -fvisibility=hidden -fvisibility-inlines-hidden
    Linker flags .................... :
    Extra libraries ................. :

    Build 8 bit pcre library ........ : yes
    Build 16 bit pcre library ....... : no
    Build 32 bit pcre library ....... : no
    Build C++ library ............... : yes
    Enable JIT compiling support .... : no
    Enable UTF-8/16/32 support ...... : no
    Unicode properties .............. : no
    Newline char/sequence ........... : lf
    \R matches only ANYCRLF ......... : no
    EBCDIC coding ................... : no
    EBCDIC code for NL .............. : n/a
    Rebuild char tables ............. : no
    Use stack recursion ............. : yes
    POSIX mem threshold ............. : 10
    Internal link size .............. : 2
    Nested parentheses limit ........ : 250
    Match limit ..................... : 10000000
    Match limit recursion ........... : MATCH_LIMIT<
4000
/span>
    Build shared libs ............... : yes
    Build static libs ............... : yes
    Use JIT in pcregrep ............. : no
    Buffer size for pcregrep ........ : 20480
    Link pcregrep with libz ......... : no
    Link pcregrep with libbz2 ....... : no
    Link pcretest with libedit ...... : no
    Link pcretest with libreadline .. : no
    Valgrind support ................ : no
    Code coverage ................... : no
然后执行make&&make install
PCRE安装完成
===========================================

然后执行:
yum -y install pcre-devel openssl openssl-devel

然后
再nginx目录下
设置 vim cc.sh

./configure --prefix=/usr/local/nginx

 

make

 

make install

这时候 再nginx sbin目录启动nginx
如果提示error log不存在,nginx.pid不存在的话

[root@localhost nginx]# /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

 

使用nginx -c的参数指定nginx.conf文件的位置

 

[root@localhost nginx]# cd logs/

[root@localhost logs]# ll

总用量 12

-rw-r--r-- 1 root root 1246 12月  9 18:10 access.log

-rw-r--r-- 1 root root  516 12月 10 15:39 error.log

-rw-r--r-- 1 root root    5 12月 10 15:38 nginx.pid

q
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()
这个报错的处理 

[emerg]: bind() to 0.0.0.0:80 failed (98: Address already in use)
如果遇到这个问题 ,那么就把 nginx端口号先禁止掉 然后再启动一下就可以了
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: