趁最近失業的這段空擋,來搭建一個本身的博客。 環境:阿里雲ECS雲服務器 OS:centos 64位 安裝方法:二進制包手動編譯安裝 新建用戶組php
groupadd -r nginx
新建用戶html
useradd -s /sbin/nologin -g nginx -r nginx
這裏有一個問題爲甚麼要新建用戶 下載 nginx-1.10.1 的二進制包 這裏是地址nginx
wget http://nginx.org/download/nginx-1.10.1.tar.gz
解壓到 tmp 目錄centos
tar -xvf nginx-1.10.1.tar.gz
x 是 extract 簡寫,提取 v 是 verbose 簡寫,展現文件壓縮或解壓縮的過程 f 是 file 簡寫,文件名 以上這些能夠查看手冊得知(tar --help 或 man tar) 進入解壓好的nginx-1.10.1文件夾服務器
cd nginx-1.10.1
開始預編譯ui
./configure
報錯,信息以下阿里雲
./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library statically from the source with nginx by using --with-pcre=<path> option.
裏面的信息提示說 HTTP 重寫模塊須要 PCRE 庫,系統給了三種解決方案.net
cd /tmp wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.37.tar.bz2
解壓code
tar -xvf pcre-8.37.tar.bz2
預編譯htm
cd pcre-8.37 ./configure
編譯 && 安裝
make && make install
清除編譯安裝後的垃圾文件
make clean
繼續預編譯 nginx-1.10.1
cd /tmp/nginx-1.10.1 ./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 下載 zlib
wget http://zlib.net/zlib-1.2.8.tar.gz
解壓
tar -xvf zlib-1.2.8.tar.gz
編譯安裝
cd zlib-1.2.8 ./configure make && make install make clean
繼續編譯 nginx-1.10.1
cd /tmp/nginx-1.10.1 ./configure
又報錯了,報錯信息以下
./configure: error: SSL modules require the OpenSSL library. You can either do not enable the modules, or install the OpenSSL library into the system, or build the OpenSSL library statically from the source with nginx by using --with-openssl=<path> option.
提示缺乏 openssl 庫 下載 openssl 官網地址
wget https://www.openssl.org/source/openssl-1.0.1t.tar.gz
解壓 安裝
tar -xvf openssl-1.0.1t.tar.gz cd openssl-1.0.1t ./config make depend
這裏安裝過程有些不同 再去編譯nginx-1.10.1 產生和上次同樣的報錯 無奈,嘗試屢次無果,因而用 yum 裝了一遍
yum -y install openssl openssl-devel
ok 繼續編譯ngnix-1.10.1
./configure \ --prefix=/usr \ --sbin-path=/usr/sbin/nginx \ --conf-path=/etc/nginx/nginx.conf \ --error-log-path=/var/log/nginx/error.log \ --pid-path=/var/run/nginx/nginx.pid \ --user=nginx \ --group=nginx \ --with-http_ssl_module \ --with-http_flv_module \ --with-http_gzip_static_module \ --http-log-path=/var/log/nginx/access.log \ --http-client-body-temp-path=/var/tmp/nginx/client \ --http-proxy-temp-path=/var/tmp/nginx/proxy \ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi \ --with-http_stub_status_module
ok沒報錯
make && make install
也ok
/usr/sbin/nginx
啓動失敗,報錯信息
/usr/sbin/nginx: error while loading shared libraries: libpcre.so.1: cannot open shared object file: No such file or directory
libpcore.so.1 打不開,解決辦法
ln -s /usr/local/lib/libpcre.so.1 /lib64
再次啓動
/usr/sbin/nginx
失敗,報錯信息
nginx: [emerg] mkdir() "/var/tmp/nginx/client" failed (2: No such file or directory)
建立"/var/tmp/nginx/client"文件夾失敗(權限不夠致使),解決辦法
mkdir -p /var/tmp/nginx/{client,proxy,fastcgi,uwsgi,scgi}
再次啓動
/usr/sbin/nginx
成功顯示 Wellcom to nginx! http://121.40.173.143/ 源碼包安裝最新 php-7.0.8 最新版 解壓 預編譯 安裝 配置
參考: http://blog.csdn.net/dazhi_100/article/details/17143213 http://www.nginx.cn/install http://www.cnblogs.com/suihui/archive/2013/04/13/3018557.html http://www.qttc.net/201208194.html http://www.tuicool.com/articles/uEre6fr