Linux centos7環境下安裝Nginx的步驟詳解nginx
一、 首先到Nginx官網下載Nginx安裝包centos
http://nginx.org/download/nginx-1.5.9.tar.gz瀏覽器
下載好後會見到相似下面的一份文件服務器
建立nginx-src目錄而且去到nginx-src目錄裏運行以下命令便可:網絡
mkdir nginx-src && cd nginx-srcui
固然也能夠在Linux底下運行如下命令進行下載Nginx安裝包centos7
wget http://nginx.org/download/nginx-1.5.9.tar.gz3d
2、解壓nginx-1.5.9.tar.gz文件blog
tar -zxvf nginx-1.5.9.tar.gzip
3、刪除安裝包文件命令
rm -f nginx-1.5.9.tar.gz
4、配置安裝運行命令
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=<path> option.
安裝pcre-devel解決問題(須要有網絡下運行而且是超級管理員身份)
yum -y install pcre-devel
yum -y install openssl openssl-devel
要切換爲root超級管理員身份: su
如今進行從新配置
./configure --prefix=/usr/local/nginx
若是從新配置也不成功這時須要安裝gcc
yum –y install gcc
安裝好gcc以後再次進行配置
五、編譯命令
Make
六、安裝命令
make install
七、安裝完畢,啓動nginx
cd /usr/local/nginx/sbin
./nginx
若是啓動不成功多是防火牆問題致使
這時須要關閉防火牆
systemctl stop firewalld.service
八、訪問nginx
九、若是要精簡一下配置文件
從新加載配置文件
運行命令: nginx -s reload
到這裏博主我就成功的在Linux Centos7下安裝了Nginx服務器
而且已經成功的在瀏覽器上經過IP地址訪問到nginx。
感謝各位博友對個人支持! 很是感謝你們。