1. 建立編譯環境
→ apt-get install build-essential
→ apt-get install libncurses5-dev
→ apt-get install mysql-client
2. 安裝nginx 相依套件 (pcre、zlib、openssl)
開啟下載存放資料夾
→ cd /usr/local/src
下載 pcre、zlib、openssl ※可根據所需要版本調整
→ wget http://ncu.dl.sourceforge.net/project/pcre/pcre/8.37/pcre-8.37.tar.gz
→ wget http://www.zlib.net/zlib-1.2.11.tar.gz
→ wget http://www.openssl.org/source/openssl-1.0.2a.tar.gz
解壓縮 pcre
3、zlib、openssl (於 /usr/local/src)
→ tar xfz pcre-8.37.tar.gz
→ tar xfz zlib-1.2.11.tar.gz
→ tar xfz openssl-1.0.2a.tar.gz
安裝 pcre-8.37
→ cd /usr/local/src
→ cd pcre-8.37
→ ./configure
→ make && make install
安裝 zlib-1.2.11
→ cd /usr/local/src
→ cd zlib-1.2.11
→ ./configure
→ make && make install
openssl 不用編譯,但是編譯nginx時,需要configure 傳路徑去
3.安裝 nginx 1.9.12
→ cd /usr/local/src (下載路徑)
→ wget http://nginx.org/download/nginx-1.9.12.tar.gz
→ tar xfz nginx-1.9.12.tar.gz
→ cd nginx-1.9.12
→ ./configure --sbin-path=/usr/local/nginx/nginx --conf-path=/usr/local/nginx/nginx.conf --pid-path=/usr/local/nginx/nginx.pid --with-http_ssl_module --with-pcre=/usr/local/src/pcre-8.37 --with-zlib=/usr/local/src/zlib-1.2.11 --with-openssl=/usr/local/src/openssl-1.0.2a
→ make&&make install
啟動 nginx
→ /usr/local/nginx/nginx
查看 nginx 哪個 config 啟動
→ ps -ef | grep nginx
查看 nginx 版本 ※根據config 路徑查看版本
→ cd /usr/local/nginx/
→ ./nginx -v
→ ./nginx -V