Linux centos7環(huán)境下安裝Nginx的步驟詳解
1、首先到Nginx官網(wǎng)下載Nginx安裝包
http://nginx.org/download/nginx-1.5.9.tar.gz
下載好后會(huì)見(jiàn)到類(lèi)似下面的一份文件
創(chuàng)建nginx-src目錄并且去到nginx-src目錄里運(yùn)行如下命令即可:
mkdir nginx-src && cd nginx-src
當(dāng)然也可以在Linux底下運(yùn)行以下命令進(jìn)行下載Nginx安裝包
wget http://nginx.org/download/nginx-1.5.9.tar.gz
2、解壓nginx-1.5.9.tar.gz文件
tar -zxvf nginx-1.5.9.tar.gz
3、刪除安裝包文件命令
rm -f nginx-1.5.9.tar.gz
4、配置安裝運(yùn)行命令
cd nginx-1.5.9/
./configure --prefix=/usr/local/nginx
也許是提示缺包:
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=
安裝pcre-devel解決問(wèn)題(需要有網(wǎng)絡(luò)下運(yùn)行并且是超級(jí)管理員身份)
yum -y install pcre-devel
yum -y install openssl openssl-devel
要切換為root超級(jí)管理員身份: su
現(xiàn)在進(jìn)行重新配置
./configure --prefix=/usr/local/nginx
如果重新配置也不成功這時(shí)需要安裝gcc
yum –y install gcc
安裝好gcc之后再次進(jìn)行配置
5、編譯命令
Make
6、安裝命令
make install
7、安裝完畢,啟動(dòng)nginx
cd /usr/local/nginx/sbin
./nginx
如果啟動(dòng)不成功可能是防火墻問(wèn)題導(dǎo)致
這時(shí)需要關(guān)閉防火墻
systemctl stop firewalld.service
8、訪問(wèn)nginx
http://IP地址
9、如果要精簡(jiǎn)一下配置文件
重新加載配置文件
運(yùn)行命令: nginx -s reload
到這里博主我就成功的在Linux Centos7下安裝了Nginx服務(wù)器
并且已經(jīng)成功的在瀏覽器上通過(guò)IP地址訪問(wèn)到nginx。
感謝各位博友對(duì)我的支持! 非常感謝大家。