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
复制代码
相关文章
相关标签/搜索