nginx安装
来源:互联网 发布:淘宝店售假还能救活吗 编辑:程序博客网 时间:2024/06/05 07:11
安装编译工具包、zlib、openssl、pcre
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel
下载nginx:
wget http://nginx.org/download/nginx-1.4.7.tar.gz
解压nginx:
tar -zxvf nginx-1.4.7.tar.gz
切换到nginx-1.4.7目录
cd nginx-1.4.7
创建系统组nginx
groupadd -r nginx
创建匿名系统用户nginx
useradd -s /sbin/nologin -g nginx -r nginx
查看nginx用户信息
id nginx
模块配置
./configure \
--prefix=/usr \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--pid-path=/var/run/nginx/nginx.pid \
--lock-path=/var/lock/nginx.lock \
--user=nginx \
--group=nginx \
--with-http_ssl_module \
--with-http_flv_module \
--with-http_gzip_static_module \
--http-log-path=/var/log/nginx/access.log \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/fcgi \
--with-http_stub_status_module \
--with-http_mp4_module \
--without-http_rewrite_module
编译并安装
make && make install
创建临时文件夹
mkdir /var/tmp/nginx/client -pv
启动nginx
/usr/sbin/nginx -c /etc/nginx/nginx.conf
查看nginx服务是否启动
ps -ef | grep nginx
检测nginx配置文件语法
nginx -t -c /etc/nginx/nginx.conf
取消80端口防火墙
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
清空防火墙策略
iptables -F
保存对防火墙策略的修改
service iptables save
复制rpm安装生成的nginx文件到/etc/init.d/目录下
cp nginx /etc/init.d/nginx
添加可执行权限
chmod a+x /etc/init.d/nginx
添加nginx为系统服务
chkconfig --add nginx
显示nginx服务的运行状态信息
chkconfig --list nginx
启动nginx
service nginx start
重启nginx
service nginx restart
重新加载nginx配置文件
service nginx reload
停止nginx服务
service nginx stop
安装完成。
rpm安装nginx生成的“nginx”文件内容:
#!/bin/sh
#
# nginx Startup script for nginx
#
# chkconfig: - 85 15
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# description: nginx is an HTTP and reverse proxy server
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: start and stop nginx
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ -f /etc/sysconfig/nginx ]; then
. /etc/sysconfig/nginx
fi
prog=nginx
nginx=${NGINX-/usr/sbin/nginx}
conffile=${CONFFILE-/etc/nginx/nginx.conf}
lockfile=${LOCKFILE-/var/lock/nginx.lock}
pidfile=${PIDFILE-/var/run/nginx/nginx.pid}
SLEEPMSEC=100000
RETVAL=0
start() {
echo -n $"Starting $prog: "
daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
RETVAL=$?
echo
[ $RETVAL = 0 ] && touch ${lockfile}
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
}
reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
}
upgrade() {
oldbinpidfile=${pidfile}.oldbin
configtest -q || return 6
echo -n $"Staring new master $prog: "
killproc -p ${pidfile} ${prog} -USR2
RETVAL=$?
echo
/bin/usleep $SLEEPMSEC
if [ -f ${oldbinpidfile} -a -f ${pidfile} ]; then
echo -n $"Graceful shutdown of old $prog: "
killproc -p ${oldbinpidfile} ${prog} -QUIT
RETVAL=$?
echo
else
echo $"Upgrade failed!"
return 1
fi
}
configtest() {
if [ "$#" -ne 0 ] ; then
case "$1" in
-q)
FLAG=$1
;;
*)
;;
esac
shift
fi
${nginx} -t -c ${conffile} $FLAG
RETVAL=$?
return $RETVAL
}
rh_status() {
status -p ${pidfile} ${nginx}
}
# See how we were called.
case "$1" in
start)
rh_status >/dev/null 2>&1 && exit 0
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
configtest -q || exit $RETVAL
stop
start
;;
upgrade)
upgrade
;;
condrestart|try-restart)
if rh_status >/dev/null 2>&1; then
stop
start
fi
;;
force-reload|reload)
reload
;;
configtest)
configtest
;;
*)
echo $"Usage: $prog {start|stop|restart|condrestart|try-restart|force-reload|upgrade|reload|status|help|configtest}"
RETVAL=2
esac
exit $RETVAL
- nginx笔记:nginx安装
- Nginx-----源码安装nginx
- 【nginx】nginx的安装
- 安装Nginx
- nginx安装
- 安装 nginx
- 安装nginx
- 安装 Nginx
- nginx安装
- Nginx安装
- 安装Nginx
- 安装nginx
- nginx安装
- 安装nginx
- Nginx安装
- nginx安装
- nginx安装
- nginx 安装
- openURL的使用方法
- 关于安卓入门的一些提示
- 词频统计
- Eclipse快捷键大全(转载)
- oracle常用函数汇总
- nginx安装
- Deep Learning 教程翻译
- HTML错误代码详细说明
- POJ1860(Bellman-Ford思想)
- SN_Write_tool 为手机写IMEI图文详解
- Android实现点击两次返回键退出
- UVa 465 - Overflow
- hust训练-计算几何之 pick定理
- cocos2d纹理像素格式