tony_nginx的安装和配置
yum安装nginx
Centos默认的yum源里没有nginx,需要手动添加源,有两种方法:
使用nginx提供的一个源设置安装包
nginx下载页面:http://nginx.org/en/download.html
nginx提供4个版本的系统的源:
我选择Centos6,文件名为:nginx-release-centos-6-0.el6.ngx.noarch.rpm。
在服务器上安装:
rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm
之后便可以使用yum快速安装了:
yum install nginx
手动添加nginx源
cd /etc/yum.repos.d vim nginx.repo #内容为:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=
enabled=
baseurl中centos和6可以更改为自己的版本,比如redhat 5版本的链接为:
baseurl=http://nginx.org/packages/rhel/5/$basearch/
详情可以自己看nginx的下载页面,包括其他系统的源安装方法。
相关路径
nginx可执行文件:/usr/sbin/nginx
nginx配置目录:/etc/nginx
nginx log目录:/var/log/nginx
编译安装nginx
我的nginx编译安装代码:
yum install perl-ExtUtils-Embed.x86_64 pcre-devel.x86_64
#根据自己的需求,选择参数,可用的参数可以使用./configure --help命令查看
./configure --prefix=/opt/nginx
--with-http_gzip_static_module
--with-http_perl_module
--with-pcre
--with- rtsig_module
--with-select_module
--with-poll_module
--with-file-aio make
make install

为编译安装的nginx配置init脚本:
vim /etc/init.d/nginx
#内容取自yum安装的nginx后,生成的文件,改下里面的路径即可使用了
#!/bin/sh
#
# nginx Startup script for nginx
#
# chkconfig: -
# processname: nginx
# config: /opt/nginx/conf/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /opt/nginx/logs/nginx.pid
# description: nginx is a 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:
# Default-Stop:
# 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-/opt/nginx/sbin/nginx}
conffile=${CONFFILE-/opt/nginx/conf/nginx.conf}
lockfile=${LOCKFILE-/var/lock/subsys/nginx}
pidfile=${PIDFILE-/opt/nginx/logs/nginx.pid}
SLEEPMSEC=
RETVAL= start() {
echo -n $"Starting $prog: " daemon --pidfile=${pidfile} ${nginx} -c ${conffile}
RETVAL=$?
echo
[ $RETVAL = ] && touch ${lockfile}
return $RETVAL
} stop() {
echo -n $"Stopping $prog: "
killproc -p ${pidfile} ${prog}
RETVAL=$?
echo
[ $RETVAL = ] && rm -f ${lockfile} ${pidfile}
} reload() {
echo -n $"Reloading $prog: "
killproc -p ${pidfile} ${prog} -HUP
RETVAL=$?
echo
} upgrade() {
oldbinpidfile=${pidfile}.oldbin configtest -q || return
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
fi
} configtest() {
if [ "$#" -ne ] ; then
case "$1" in
-q)
FLAG=$
;;
*)
;;
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 >& && exit
start
;;
stop)
stop
;;
status)
rh_status
RETVAL=$?
;;
restart)
configtest -q || exit $RETVAL
stop
start
;;
upgrade)
upgrade
;;
condrestart|try-restart)
if rh_status >/dev/null >&; 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=
esac exit $RETVAL
使用chkconfig安装为安装启动项
chkconfig --add nginx
chkconfig nginx on nginx命令:
启动:nginx
停止:nginx -s stop
重置生效:nginx -s reload
tony_nginx的安装和配置的更多相关文章
- JDK安装与配置
JDK安装与配置 一.下载 JDK是ORACLE提供免费下载使用的,官网地址:https://www.oracle.com/index.html 一般选择Java SE版本即可,企业版的选择Java ...
- Node.js 教程 01 - 简介、安装及配置
系列目录: Node.js 教程 01 - 简介.安装及配置 Node.js 教程 02 - 经典的Hello World Node.js 教程 03 - 创建HTTP服务器 Node.js 教程 0 ...
- 烂泥:redis3.2.3安装与配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 前一段时间写过一篇codis集群的文章,写那篇文章主要是因为当时的项目不支持redis自 ...
- mysql源码包手动安装、配置以及测试(亲测可行)
笔记编者:小波/qq463431476博客首页:http://www.cnblogs.com/xiaobo-Linux/ 记下这篇mysql笔记,望日后有用! redhat6采用centos yum源 ...
- 环境搭建系列-系统安装之centos 6.5安装与配置
按照国际惯例,系列目录先奉上: 系列一:系统安装之centos 6.5安装与配置 系列二:准备工作之Java环境安装 系列三:数据为先之MySQL读写集群搭建 系列四:谈分布式之RabbitMQ集群搭 ...
- ZooKeeper安装与配置
一. 单机安装.配置: 1. 下载zookeeper二进制安装包下载地址:http://apache.dataguru.cn/zookeeper/zookeeper-3.4.3/zookeeper-3 ...
- mac 下JDK 与 tomcat 的安装与配置
一.Mac下JDK的安装 1.先检测Mac是否已经安装过JDK,在终端中输入java 或者 javac 显示说明,表明已经安装过JDK,JDK版本查询终端键入java -version,终端会返回JD ...
- 烂泥:zabbix3.0安装与配置
本文由ilanniweb提供友情赞助,首发于烂泥行天下 想要获得更多的文章,可以关注我的微信ilanniweb 这个月又快过完了,最近也比较忙,没时间写文章,今天挤点时间把zabbix3.0安装与配置 ...
- Jenkins入门系列之——02第二章 Jenkins安装与配置
2014-12-08:已不再担任SCM和CI的职位,Jenkins的文章如无必要不会再维护. 写的我想吐血,累死了. 网页看着不爽的,自己去下载PDF.有问题请留言! Jenkins入门系列之——03 ...
随机推荐
- thinkpad win8.1 无线连接受限
把博通的驱动回滚到6.30.223.102就好了
- small test on 5.30 night T2
(题面写错了,应该是一条从b -> a 的边) 让我们设状态 (a,b,c) 表示存在一个点k,使得 dist(k,b) - dist(k,a) * 2 + 3 = c,显然这里的第三维可以压 ...
- 【DFS】Gym - 101142C - CodeCoder vs TopForces
就按照题意建出有向图来(n个点,2n-2条边),然后从按随便一个rating排序,从最后一个开始dfs,用vis数组防止重复访问,因为每次之前的肯定能访问之后的(及之后的能访问的),所以不会有重复.就 ...
- 【动态规划】【记忆化搜索】CODEVS 1011 数的计算 2001年NOIP全国联赛普及组
设答案为f(n),我们显然可以暴力地递归求解: f(n)=f(1)+f(2)+……+f(n/2). 但是n=1000,显然会超时. 考虑状态最多可能会有n种,经过大量的重复计算,所以可以记忆下来,减少 ...
- 【三维偏序】【分块】bzoj3262 陌上花开
裸的三维偏序. 对x坐标排序,y.z坐标分块.复杂度O(n*sqrt(n*log(n))).代码很短. #include<cstdio> #include<cmath> #in ...
- 使用jQuery操作dom(追加和删除样式-鼠标移入移出)练习
1.实现鼠标移入则添加背景色,鼠标移出则删除背景色 <!DOCTYPE html> <html> <head> <title>test1.html< ...
- iOS开发中几种常见的存储方式
1.archive 归档 数据的保存 1: let result = NSKeyedArchiver.archiveRootObject(contacts, toFile: path as Strin ...
- 在WinRT程序中使用MEF
今天试了一下在WinRT中使用MEF,这里简单的介绍一下步骤. 首先,使用NuGet安装MEF 然后,就可以使用MEF组装插件了,简单的示例如下: interface ILogger { ...
- Jmeter调用Webapi介绍
一.介绍 JMeter主要用于压力测试,使用Java编写,由Apache基金会管理 官方网站:http://jmeter.apache.org/index.html 下载地址: ...
- inline-block空隙总结
如果inline-block,宽度都是50%会留有空隙,解决方法如下 1.标签之间不留空格 (1)直接不留空 <div></div><div></div> ...