nginx的编译安装
发表于:2026-11-02 作者:千家信息网编辑
千家信息网最后更新 2026年11月02日,1、安装编译环境yum -y install gcc gcc-c++ make ncurses ncurses-devel2、安装pcre软件包(使nginx支持http rewrite模块)yum
千家信息网最后更新 2026年11月02日nginx的编译安装
1、安装编译环境yum -y install gcc gcc-c++ make ncurses ncurses-devel
2、安装pcre软件包(使nginx支持http rewrite模块)yum install -y pcre pcre-devel
3、安装openssl-devel(使nginx支持ssl)yum install -y openssl openssl-devel
4、安装zlibyum install -y zlib zlib-devel
5、创建用户nginx
groupadd nginxuseradd -r -g nginx -s /sbin/nologin nginx6、安装nginx
[root@localhost ~]# wget http://nginx.org/download/nginx-1.16.0.tar.gz[root@localhost ~]# tar xzf nginx-1.16.0.tar.gz -C /usr/local/[root@localhost ~]# cd /usr/local/nginx-1.16.0/[root@localhost nginx-1.16.0]# ./configure --prefix=/usr/local/nginx --group=nginx --user=nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --http-client-body-temp-path=/tmp/nginx/client_body --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --pid-path=/var/run/nginx.pid --lock-path=/var/lock/nginx --with-http_stub_status_module --with-http_ssl_module --with-http_gzip_static_module --with-pcre --with-http_realip_module --with-stream[root@localhost nginx-1.16.0]# make && make install[root@localhost nginx-1.16.0]#cd /tmp/[root@dabing tmp]#mkdir nginx[root@dabing sbin]# cd /usr/local/nginx/sbin (/usr/local/nginx/sbin/nginx开启nginx)[root@dabing sbin]# ./nginx [root@dabing sbin]# ss -antpl[root@dabing sbin]# vim /etc/init.d/nginx #开机自动开启脚本
#!/bin/sh . /etc/rc.d/init.d/functions. /etc/sysconfig/network[ "$NETWORKING" = "no" ] && exit 0 nginx="/usr/local/nginx/sbin/nginx"prog=$(basename $nginx) NGINX_CONF_FILE="/etc/nginx/nginx.conf"[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginxlockfile=/var/lock/nginxmake_dirs() { user=`nginx -V 2>&1 | grep "configure arguments:" | sed 's/[^*]*--user=\([^ ]*\).*/\1/g' -` options=`$nginx -V 2>&1 | grep 'configure arguments:'` for opt in $options; do if [ `echo $opt | grep '.*-temp-path'` ]; then value=`echo $opt | cut -d "=" -f 2` if [ ! -d "$value" ]; then # echo "creating" $value mkdir -p $value && chown -R $user $value fi fi done} start() { [ -x $nginx ] || exit 5 [ -f $NGINX_CONF_FILE ] || exit 6 make_dirs echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq 0 ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq 0 ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop sleep 1 start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo} force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null 2>&1 } case "$1" in start) rh_status_q && exit 0 $1 ;; stop) rh_status_q || exit 0 $1 ;; restart|configtest) $1 ;; reload) rh_status_q || exit 7 $1 ;; force-reload) force_reload ;; status) rh_status ;; condrestart|try-restart) rh_status_q || exit 0 ;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}" exit 2 esac[root@dabing sbin]# chmod +x /etc/init.d/nginx (实现nginx的开机自起)
[root@dabing sbin]# systemctl daemon-reload
[root@dabing sbin]# systemctl start nginx
[root@dabing sbin]# /sbin/chkconfig nginx on
[root@dabing sbin]# systemctl status nginx
支持
编译
模块
环境
用户
脚本
软件
软件包
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
科技互联网
互联网科技公司
广州百单互联网科技有限公司
A股互联网金融科技公司
互联网与科技发展
深圳科技互联网
善班互联网科技
互联网科技作文
未来的互联网科技
睿民互联网科技
小米互联网科技园设置
随着互联网科技发展
银川新华互联网科技职业技术培训学校图片
贵州叶脉互联网科技有限公司所属行业
互联网保险科技创业
工业互联网等科技实现智能化赋能
互联网风格科技公司名称
互联网科技手机排行榜
湖北辰鑫科技互联网
青岛互联网科技园
疫情对互联网科技公司影响
碳银互联网科技
银优互联网科技有限公司
顺玮阁互联网科技
新华互联网科技2019
恒银科技与互联网金融
银川新华互联网科技学校联系电话
互联网时代的科技公司
同城互联网络科技
利用互联网等科技手段