Debian 9.2 安裝 Nginx

這次玩次狠得。除了編譯器使用yum安裝,其他全部手動(dòng)編譯。哼~

看似就Nginx、PHP、MySql三個(gè)東東,但是它們太尼瑪依賴別人了。

沒(méi)辦法,想用它們就得老老實(shí)實(shí)給它們提供想要的東西。

首先的一些模塊依賴一些lib庫(kù),

如果你是懶人,就順著下面的命令分別輸入就行了。然后直接看配置篇。(不過(guò)這樣安裝的可不是最新版本的喲)

一、準(zhǔn)備工作


1.1 更新系統(tǒng)安裝包列表

沒(méi)啥,就他喵想用個(gè)最新的。

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># apt update</pre>

1.2 必須軟件包

下面都是編譯nginx必須的,提前安裝好。

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># apt install gcc make

apt install libpcre3 libpcre3-dev //【正則表達(dá)式庫(kù)】 官網(wǎng)http://www.pcre.org/

apt install openssl libssl-dev //【openssl庫(kù)】 官網(wǎng)https://www.openssl.org/

apt install zlib1g-dev</pre>

1.3 創(chuàng)建需要使用的目錄

創(chuàng)建目錄source和web,分別用來(lái)放源碼和編譯后的文件。

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># mkdir /source/

mkdir /web/</pre>

二、安裝nginx


2.1 安裝nginx

[官方網(wǎng)站] http://nginx.org/

命令流程:

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># cd /source/

wget http://nginx.org/download/nginx-1.13.5.tar.gz

tar -zxf nginx-1.13.5.tar.gz

cd nginx-1.13.5 # ./configure --prefix=/web/nginx --with-http_ssl_module

make && make install</pre>

--with-http_ssl_module //打開(kāi)https

三、配置nginx


****3.1 打開(kāi)nginx.conf****

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;">vim nginx.conf</pre>

****3.2 支持php。在server里加入****

[
復(fù)制代碼

](javascript:void(0); "復(fù)制代碼")

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 #
location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}</pre>

[
復(fù)制代碼

](javascript:void(0); "復(fù)制代碼")

3.3 支持asp.net。在server里加入

[
復(fù)制代碼

](javascript:void(0); "復(fù)制代碼")

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"> location / {
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection keep-alive;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_cache_bypass $http_upgrade;
}</pre>

[
復(fù)制代碼

](javascript:void(0); "復(fù)制代碼")

3.4 防火墻添加80、443端口(可選,需要外網(wǎng)訪問(wèn)的)

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># firewall-cmd --zone=public --add-port=80/tcp --permanent //--permanent永久生效,沒(méi)有此參數(shù)重啟后失效

firewall-cmd --reload //重新載入</pre>

附、常用命令


nginx常用命令

<pre style="margin: 0px; padding: 0px; white-space: pre-wrap; word-wrap: break-word; font-family: "Courier New" !important; font-size: 12px !important;"># ln -s /web/nginx/sbin/nginx /usr/local/bin //快捷方式

/web/nginx/sbin/nginx //啟動(dòng)nginx

/web/nginx/sbin/nginx -s reload //重啟nginx

/web/nginx/sbin/nginx -s stop //關(guān)閉nginx</pre>

文章地址:https://www.cnblogs.com/project/p/6942593.html

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

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

  • 第一章 Nginx簡(jiǎn)介 Nginx是什么 沒(méi)有聽(tīng)過(guò)Nginx?那么一定聽(tīng)過(guò)它的“同行”Apache吧!Ngi...
    JokerW閱讀 33,028評(píng)論 24 1,002
  • I/O模型Nginx介紹Nginx的安裝和目錄結(jié)構(gòu)Nginx的配置Nginx的編譯安裝 一、I/O模型 (一)I/...
    哈嘍別樣閱讀 978評(píng)論 0 4
  • 1.簡(jiǎn)介: ? Nginx:engine X ,2002年,開(kāi)源,商業(yè)版? http協(xié)議:web服務(wù)器(類似于ht...
    尛尛大尹閱讀 2,017評(píng)論 0 3
  • 備孕快三個(gè)月,一心想要個(gè)小猴子.上個(gè)月咳嗽咳得整晚睡不著,經(jīng)常夢(mèng)中咳醒喘不過(guò)氣,有幾天幾乎發(fā)不出聲音...上班時(shí)一...
    小賊喵閱讀 219評(píng)論 0 0
  • 流浪 在北京流浪 藍(lán)的天下紅的墻 片綠不掛的樹(shù)丫 陰冷 卻執(zhí)拗的張揚(yáng) 北海成冰 在霞光里燦如天堂 盡頭 那不是家 ...
    綠手帕閱讀 585評(píng)論 0 1

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