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 net-tools iotop bc zip unzip zlib-devel bash-completion nfs-utils automake libxml2 libxml2-devel libxslt libxslt-devel perl perl-ExtUtils-Embed
#创建用户
useradd -r -s /sbin/nologin nginx
#给nginx权限
chown nginx.nginx -R /apps/nginx/
#解压缩
tar xvf nginx-1.14.2.tar.gz
cd nginx-1.14.2/
#源码编译
./configure --prefix=/apps/nginx \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_v2_module \
--with-http_realip_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-pcre \
--with-stream \
--with-stream_ssl_module \
--with-stream_realip_module
make && make install
#配置变量环境
echo 'PATH=/apps/nginx/sbin/:$PATH' > /etc/profile.d/nginx.sh
. /etc/profile.d/nginx.sh
#此处由于nginx的二进制只有一个nginx,所以可以使用软链接的方式来配置:
#ln -s /apps/nginx/sbin/nginx /usr/sbin/