Centos6.5(Linux)安裝Nginx

來源:互聯網
上載者:User

1、安裝nginx依賴的庫pcre
:http://sourceforge.net/projects/pcre/

2、解壓pcre
zip解壓方式:unzip pcre-xxx
tar解壓方式:tar -xzvf pcre-xxx

3、運行configure
cd prce-xxx
./configure
如果運行出錯:You need a C++ compiler for C++ support
則需要安裝C++編譯環境:yum install -y gcc gcc-c++

4、安裝和編譯prce
make && make install


5、解壓nginx
tar -xzvf nginx-xxx

6、運行configure
cd nginx-xxx
./configure
如果運行出錯:./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.
則需要安裝zlib庫:yum install zlib-devel

7、安裝nginx
make && make install



8、啟動nginx
/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
啟動出錯:/usr/local/nginx/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory

解決辦法:ldd /usr/local/nginx/sbin/nginx =====>查看連結庫是否正常

linux-vdso.so.1 => (0x00007fff1e3ff000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003ea5800000)
libcrypt.so.1 => /lib64/libcrypt.so.1 (0x0000003eb0400000)
libpcre.so.1 => not found
libz.so.1 => /lib64/libz.so.1 (0x0000003ea6800000)
libc.so.6 => /lib64/libc.so.6 (0x0000003ea5000000)
/lib64/ld-linux-x86-64.so.2 (0x0000003ea4c00000)
libfreebl3.so => /lib64/libfreebl3.so (0x0000003eb1000000)
libdl.so.2 => /lib64/libdl.so.2 (0x0000003ea5400000)

9、ln -s libpcre.so.0.0.1 libpcre.so.1




10、再次啟動nginx

./usr/local/nginx/sbin/nginx

11、ps -ef | grep nginx
查看nginx是否啟動成功

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.