這次玩次狠得。除了編譯器使用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里加入****
[
](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>

](javascript:void(0); "復(fù)制代碼")
3.3 支持asp.net。在server里加入
[
](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>

](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 //快捷方式