linux服務(wù)器安裝nginx

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容