centos7編譯安裝nginx

安裝nginx編譯所需的lib庫

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel
yum -y install pcre pcre-devel

查看pcre(正則庫)版本

pcre-config --version

進入編譯目錄

cd /usr/local/src

官網(wǎng)下載最新的nginx(stable version穩(wěn)定版)

wget http://nginx.org/download/nginx-1.16.1.tar.gz

解壓nginx壓縮包

tar -zxvf nginx-1.16.1.tar.gz

進入解壓目錄

cd  nginx-1.16.1

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

./configure --prefix=/usr/local/nginx --with-http_addition_module --with-http_flv_module --with-http_gzip_static_module --with-http_realip_module --with-http_ssl_module --with-http_stub_status_module --with-http_sub_module --with-http_dav_module --with-http_v2_module

編譯安裝nginx

make && make install

nginx執(zhí)行命令軟鏈接到/usr/bin

ln -s /usr/local/nginx/sbin/nginx /usr/bin

啟動nginx

nginx

設(shè)置開機自啟動

echo "/usr/local/nginx/sbin/nginx" >> /etc/rc.d/rc.local
chmod +x /etc/rc.d/rc.local

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

執(zhí)行nginx -h查看相關(guān)命令

[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
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

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