Nginx學(xué)習(xí)之搭建

Nginx搭建環(huán)境centos7

1、安裝C++相關(guān)依賴環(huán)境
yum install gcc-c++

異常1:
已加載插件:fastestmirror, langpacks
Loading mirror speeds from cached hostfile
http://mirror.centos.org/centos/7/os/x86_64/repodata/repomd.xml: [Errno 14] curl#6 - "。。。

原因:沒(méi)有網(wǎng)絡(luò),無(wú)法啟動(dòng)YUM安裝
解決方案:

1,vi /etc/sysconfig/network-scripts/ifcfg-ens33修改網(wǎng)卡,修改onboot 屬性為yes
2,重啟網(wǎng)絡(luò)服務(wù)systemctl restart network.service

異常2:
提示正在yum正在被使用。
原因:可能是在后臺(tái)進(jìn)行yum進(jìn)行處理,所以這里直接關(guān)掉yum進(jìn)程就好
解決方案:

rm -f /var/run/yum.pid

2、安裝PCRE庫(kù)

yum install -y pcre pcre-devel

3、安裝zlib

yum install -y zlib zlib-devel

4、安裝 OpenSSL 庫(kù)

yum install -y openssl openssl-devel

5、下載.tar.gz安裝包

wget -c https://nginx.org/download/nginx-1.10.1.tar.gz

6、解壓

tar -zxvf nginx-1.10.1.tar.gz

7、配置Nginx

./configure --user=nobody --group=nobody --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_gzip_static_module --with-http_realip_module --with-http_sub_module --with-http_ssl_module

8、編譯安裝

make && make install

9、使用

/usr/local/nginx/sbin/nginx

異常:
nginx: [emerg] invalid socket number "/usr/local/nginx" in NGINX environment variable, ignoring

問(wèn)題:自作自受,把NGINX添加到了環(huán)境變量,而NGINX本身也會(huì)增加一個(gè)名為NGINX的變量,所以這里把環(huán)境變量中的NGINX換成NGINX_HOME即可

修改環(huán)境變量方便后期訪問(wèn)

 1、vi ~/.bash_profile

 2、 export NGINX_HOME=/usr/local/nginx
    
    PATH=$PATH:$HOME/bin
    
    export PATH=$NGINX_HOME/bin:$PATH
    
 3、source .bash_profile

環(huán)境搭建結(jié)束,可以使用Nginx了,如有其它問(wèn)題,請(qǐng)留言

最后編輯于
?著作權(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)容

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