centos7編譯安裝nginx

安裝nginx編譯所需的lib庫html

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
yum -y install pcre pcre-devel
複製代碼

查看pcre(正則庫)版本nginx

pcre-config --version
複製代碼

進入編譯目錄c++

cd /usr/local/src
複製代碼

官網下載最新的nginx(stable version穩定版)shell

wget http://nginx.org/download/nginx-1.16.1.tar.gz
複製代碼

解壓nginx壓縮包bash

tar -zxvf nginx-1.16.1.tar.gz
複製代碼

進入解壓目錄ui

cd  nginx-1.16.1
複製代碼

運行配置腳本(--prefix參數指定nginx安裝的目錄,默認安裝在/usr/local/nginx )this

./configure --prefix=/usr/local/nginx
複製代碼

編譯安裝nginxspa

make && make install
複製代碼

nginx執行命令軟連接到/usr/bincode

ln -s /usr/local/nginx/sbin/nginx /usr/bin
複製代碼

啓動nginxhtm

nginx
複製代碼

設置開機自啓動

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local
複製代碼

以上就是整個安裝過程...

執行nginx -h查看相關命令

[root@localhost ~]# nginx -h
nginx version: nginx/1.16.1
Usage: nginx [-?hvVtTq] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
  -?,-h         : this help
  -v            : show version and exit
  -V            : show version and configure options then exit
  -t            : test configuration and exit
  -T            : test configuration, dump it and exit
  -q            : suppress non-error messages during configuration testing
  -s signal     : send signal to a master process: stop, quit, reopen, reload
  -p prefix     : set prefix path (default: /usr/local/nginx/)
  -c filename   : set configuration file (default: conf/nginx.conf)
  -g directives : set global directives out of configuration file
複製代碼

查看nginx安裝目錄

whereis nginx
複製代碼
相關文章
相關標籤/搜索