centos7安装nginx详细步骤
一、下载nginx安装包和所需依赖
groupadd -g 1002 nginx #创建nginx用户
useradd -g 1002 -u 1002 nginx
cd /usr/local #进入安装目录
wget https://nginx.org/download/nginx-1.16.1.tar.gz #下载nginx1.16安装包
tar xf nginx-1.16.1.tar.gz #解压
cd nginx-1.16.1/ #进入nginx目录
yum install -y vim lrzsz tree screen psmisc lsof tcpdump wget ntpdate gcc gcc-c++ glibc glibc-devel pcre pcre-devel openssl openssl-devel systemd-devel nettools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed
#安装依赖包
二、配置编译安装
./configure \
--user=nginx \
--group=nginx \
--with-threads \
--with-file-aio \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_xslt_module=dynamic \
--with-http_image_filter_module=dynamic \
--with-http_geoip_module=dynamic \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_auth_request_module \
--with-http_random_index_module \
--with-http_secure_link_module \
--with-http_degradation_module \
--with-http_slice_module \
--with-http_stub_status_module \
--with-stream=dynamic \
--with-stream_ssl_module \
--with-stream_realip_module \
--with-stream_geoip_module=dynamic \
--with-stream_ssl_preread_module \
--with-compat \
--with-pcre-jit #配置编译模块
make && make install #编译安装
vim /etc/profile #将下方内容写入环境变量
export /usr/local/nginx/sbin:$PATH
source /etc/profile #刷新环境变量使之生效
三、启动
nginx #启动nginx
nginx -s reload #重启nginx
nginx -s stop #停止nginx