nginx安裝教程(linux)

安裝nginx:

1.正式開始前,編譯環境gcc g++ 開發庫之類的需要提前裝好.

安裝make
yum -y install gcc automake autoconf libtool make
安裝g++:
yum install gcc gcc-c++

一般我們都需要先裝pcre, zlib,前者爲了重寫rewrite,後者爲了gzip壓縮。
2.安裝PCRE庫
cd /data/server
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.40.tar.gz 獲取tar包
tar -zxvf pcre-8.40.tar.gz
cd pcre-8.40/
./configure && make && make install

3.安裝zlib
cd /data/server
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
cd zlib-1.2.11/
./configure && make && make install

4.安裝openssl
cd /data/server
wget http://www.openssl.org/source/openssl-fips-2.0.10.tar.gz
tar zxvf openssl-fips-2.0.10.tar.gz
 cd openssl-fips-2.0.10
 ./config && make && make install

 注:1-4 步可以用下面命令代理
 yum -y install make zlib zlib-devel gcc-c++ libtool  openssl openssl-devel
 
 5.安裝nginx  
 cd /data/server  
 wget http://nginx.org/download/nginx-1.10.2.tar.gz
 tar -zxvf nginx-1.10.2.tar.gz
cd nginx-1.10.2/
配置命令:
./configure --prefix=/data/server/nginx 
--prefix=/data/server/nginx  nginx的安裝目錄
執行結果:
nginx path prefix: "/data/server/nginx"
  nginx binary file: "/data/server/nginx/sbin/nginx"
  nginx modules path: "/data/server/nginx/modules"
  nginx configuration prefix: "/data/server/nginx/conf"
  nginx configuration file: "/data/server/nginx/conf/nginx.conf"
  nginx pid file: "/data/server/nginx/logs/nginx.pid"
  nginx error log file: "/data/server/nginx/logs/error.log"
  nginx http access log file: "/data/server/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"
編譯安裝: 
make && make install 
 

nginx啓動:

進入啓動目錄sbin:cd /data/server/nginx/sbin/

./nginx                      # 啓動 Nginx
./nginx -s reload            # 重新載入配置文件
./nginx -s reopen            # 重啓 Nginx
./nginx -s stop              # 停止 Nginx

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章