1. 程式人生 > >Linux下安裝nginx詳細教程

Linux下安裝nginx詳細教程

一、進入home目錄建立目錄 nginx

二、準備nginx安裝相關的元件

 1.下載nginx:wget http://nginx.org/download/nginx-1.10.2.tar.gz

2.下載openssl:wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz

3.下載zlib:wget http://zlib.net/zlib-1.2.11.tar.gz

4.下載pcre:wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz

 

5.如果安裝了c++的環境就可跳過,如未安裝:yum install gcc-c++ (點選y即可)

安裝結尾顯示complete,即代表安裝完成

三、以上檔案準備好開始安裝:

  1.安裝openssl

   tar -zxvf openssl-fips-2.0.10.tar.gz 

  cd openssl-fips-2.0.10

  ./config && make && make install   進入檔案執行安裝程式

 

 2.安裝pcre

tar -zxvf pcre-8.40.tar.gz

cd pcre-8.40

./configure && make && make install

3.安裝zlib

tar -zxvf zlib-1.2.11.tar.gz

cd zlib-1.2.11

./configure && make && make install

 

4.安裝nginx:

 

tar zxvf nginx-1.10.2.tar.gz

cd nginx-1.10.2

./configure && make && make install

 

5.啟動nginx

 1.檢視nginx安裝的地址(whereis)

2.  cd /usr/local/nginx/     

   /usr/local/nginx/sbin/nginx

啟動成功後檢視是否啟動成功:ps  -ef | grep nginx

 

如果啟動失敗:error while loading shared libraries:libpcre.so.1.......

[[email protected] nginx]# whereis libpcre.so.1
libpcre.so: /lib64/libpcre.so.0 /usr/local/lib/libpcre.so.1 /usr/local/lib/libpcre.so
[[email protected] nginx]# ln -s /usr/local/lib/libpcre.so.1 /lib64
[[email protected] nginx]# sbin/nginx 
[[email protected] nginx]# ps -aux | grep nginx
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.8/FAQ
root      12007  0.0  0.0  20296   628 ?        Ss   13:28   0:00 nginx: master process sbin/nginx
nobody    12008  0.0  0.1  20716  1220 ?        S    13:28   0:00 nginx: worker process
root      12010  0.0  0.0 103244   836 pts/0    S+   13:29   0:00 grep nginx

3.安裝是否成功:

新增80埠:

firewall-cmd --zone=public --add-port=80/tcp --permanent    (--permanent永久生效,沒有此引數重啟後失效)

重啟防火牆

firewall-cmd --reload

檢視80埠是否新增成功:

firewall-cmd --list-ports

 

瀏覽器輸入地址(伺服器ip加埠號80即可):47.99.106.88:80

出現以下介面,表示安裝成功nginx詳細安裝教程 centos完美安裝nginx