1:檢查80端口是否被占用。
2:安裝nginx
給nginx配置安裝目錄,就是nginx存放的目錄
我一般安裝軟件都是安裝在/usr/local下面的
mkdir /usr/local/nginx
進(jìn)入nginx目錄
cd /usr/local/nginx
使用wget命令下載nginx資源包
wget http://nginx.org/download/nginx-1.12.2.tar.gz
解壓
tar -zxvf nginx-1.5.9.tar.gz
執(zhí)行 ./configure命令
cd nginx-1.5.9
./configure
執(zhí)行./configure可能會存在一下錯誤,如果出現(xiàn)請執(zhí)行一下命令
錯誤1
/configure: error: the HTTP rewrite module requires the PCRE library.
解決方法
安裝pcre-devel解決問題
yum -y install pcre-devel
錯誤2
./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library. You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.
解決辦法:
yum -y install openssl openssl-devel
3.編譯
make 編譯 (make的過程是把各種語言寫的源碼文件,變成可執(zhí)行文件和各種庫文件)
cd /usr/local/nginx/nginx-1.5.9
make
4.make install安裝
make install 安裝 (make install是把這些編譯出來的可執(zhí)行文件和庫文件復(fù)制到合適的地方)
make install
5.啟動nginx服務(wù)
cd /usr/local/nginx/sbin
./nginx
6.看nginx服務(wù)是否啟動
ps -ef|grep nginx
我們看到服務(wù)已經(jīng)起來了,輸入ip即可訪問我們nginx目錄下面的html文件夾下面的index.html文件
=========================
nginx -s reload :修改配置后重新加載生效
nginx -s reopen :重新打開日志文件
關(guān)閉nginx:
nginx -s stop :快速停止nginx
quit :完整有序的停止nginx
其他的停止nginx 方式:
ps -ef | grep nginx
報錯
./configure: error: the HTTP gzip module requires the zlib library.
執(zhí)行這句話
yum install -y zlib-devel