阿里雲輕量應用服務器ubuntu 16.04鏡像html
http://nginx.org/en/download.html下選擇合適的版本:(Mainline version:開發版本,最新版本;Stable version:穩定版本;Legacy versions:歷史版本)nginx
cd /usr/local/src/(進入到src目錄下)c++
wget http://nginx.org/download/nginx-1.12.1.tar.gz(此處下載的是最新的穩定版本)ubuntu
tar -zxvf nginx-1.12.1.tar.gz(解壓文件)瀏覽器
nginx依賴pcre,zlib,openssl,先下載並解壓服務器
1.下載pcre包阿里雲
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.41.tar.gz.net
tar -zxvf pcre-8.41.tar.gzhtm
2.下載zlib包blog
wget http://zlib.net/zlib-1.2.11.tar.gz
tar -zxvf zlib-1.2.11.tar.gz
3.下載openssl包
wget https://www.openssl.org/source/openssl-1.0.2l.tar.gz
tar -zxvf openssl-1.0.2l.tar.gz
4.安裝(http://nginx.org/en/docs/configure.html查看配置參數)
cd nginx-1.12.1/(進入到nginx目錄下)
./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=../pcre-8.41 --with-zlib=../zlib-1.2.11 --with-openssl=../openssl-1.0.2l
make
make時出現錯誤configure: error: You need a C++ compiler for C++ support則先安裝gcc 和gcc-c++
yum -y install gcc
yum -y install gcc-c++
再make
make install
在ll /usr/local/nginx下有以下文件表示安裝成功
敲/usr/local/nginx/nginx啓動nginx
在瀏覽器中輸入服務器ip能夠看到