Nginx编译安装
2016-06-08 16:29
471 查看
一、安装nginx时必须先安装相应的编译工具
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
1.cd /usr/local/src/
2.wget http://nginx.org/download/nginx-1.6.2.tar.gz
3.tar zxvf nginx-1.6.2.tar.gz
4.cd nginx-1.6.2
./configure --prefix=/usr/local/nginx --with-pcre
[yum install -y pcre-devel]
make
make install
5.启动nginx:
/usr/local/nginx/sbin/nginx
6. 编写nginx启动脚本
vim /etc/init.d/nginx //加入如下内容
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
configtest(){
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
保存后,执行
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
yum -y install gcc gcc-c++ autoconf automake
yum -y install zlib zlib-devel openssl openssl-devel pcre-devel
1.cd /usr/local/src/
2.wget http://nginx.org/download/nginx-1.6.2.tar.gz
3.tar zxvf nginx-1.6.2.tar.gz
4.cd nginx-1.6.2
./configure --prefix=/usr/local/nginx --with-pcre
[yum install -y pcre-devel]
make
make install
5.启动nginx:
/usr/local/nginx/sbin/nginx
6. 编写nginx启动脚本
vim /etc/init.d/nginx //加入如下内容
#!/bin/bash
# chkconfig: - 30 21
# description: http service.
# Source Function Library
. /etc/init.d/functions
# Nginx Settings
NGINX_SBIN="/usr/local/nginx/sbin/nginx"
NGINX_CONF="/usr/local/nginx/conf/nginx.conf"
NGINX_PID="/usr/local/nginx/logs/nginx.pid"
RETVAL=0
prog="Nginx"
start() {
echo -n $"Starting $prog: "
mkdir -p /dev/shm/nginx_temp
daemon $NGINX_SBIN -c $NGINX_CONF
RETVAL=$?
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -TERM
rm -rf /dev/shm/nginx_temp
RETVAL=$?
echo
return $RETVAL
}
reload(){
echo -n $"Reloading $prog: "
killproc -p $NGINX_PID $NGINX_SBIN -HUP
RETVAL=$?
echo
return $RETVAL
}
restart(){
stop
start
}
configtest(){
$NGINX_SBIN -c $NGINX_CONF -t
return 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
restart
;;
configtest)
configtest
;;
*)
echo $"Usage: $0 {start|stop|reload|restart|configtest}"
RETVAL=1
esac
exit $RETVAL
保存后,执行
chmod 755 /etc/init.d/nginx
chkconfig --add nginx
chkconfig nginx on
相关文章推荐
- Nginx 负载均衡
- 负载均衡器技术Nginx和F5的优缺点对比
- nginx出现的403错误
- nginx/php-fpm及网站目录的权限设置
- 通过nginx实现内网hadoop、hbase集群对外访问web界面
- nginx could not build the server_names_hash错误
- keepalived+nginx实现高可用双机热备+负载均衡架构
- Mac上安装Nginx
- Nginx 进程间的关系
- lamp+nginx代理+discuz+wordpress+phpmyadmin
- 源码安装nginx服务器
- nginx 配置rewrite
- Nginx配置实战
- 绝对详细!Nginx基本配置、性能优化指南
- 为什么Nginx的性能要比Apache高很多?
- 超详细的django1.8处理centos下nginx上处理静态文件步骤!
- Nginx和Apache比较
- Ubuntu下nginx+php+mysql配置
- Nginx return 关键字配置小技巧
- Nginx的命令行控制