1.依赖项和必要组件
yum install -y make cmake gcc gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
或者分开安装
yum install -y make cmake gcc gcc-c++ yum install -y pcre pcre-devel yum install -y zlib zlib-devel yum install -y openssl openssl-devel
2.下载安装nginx
wget http://nginx.org/download/nginx-1.12.2.tar.gz
* 可以根据需要下载不同版本。官网:http://nginx.org/en/download.html
3.解压
tar zxvf nginx-1.12.2.tar.gz && cd nginx-1.12.2
4.编译配置
./configure && make && make install
执行完本命令将会在 /usr/local/nginx 生成相应的可执行文件、配置、默认站点等文件
5.创建全局命令
ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
或者一键执行:
wget http://nginx.org/download/nginx-1.12.2.tar.gz && tar zxvf nginx-1.12.2.tar.gz && cd nginx-1.12.2 && ./configure && make && make install && ln -s /usr/local/nginx/sbin/nginx /usr/bin/nginx
命令:
启动:nginx
修改配置后重新启动:nginx -t 然后再 nginx -s reload