一、准备编译环境

  1. 系统为centos6.5最小安装,关闭selinux,关闭防火墙。

  2. 安装编译工具

    # yum -y install gcc gcc-c++ autoconf automake make

  3. 安装依赖软件包

    # yum -y install zlib zlib-devel openssl openssl-devel pcre pcre-devel

二、安装Nginx

  1. 添加运行nginx服务进程的用户

    # groupadd nginx

    # useradd -g nginx -s /sbin/nologin -M nginx

  2. 下载源码包解压编译

    # wget http://nginx.org/download/nginx-1.10.2.tar.gz

    # tar xvf nginx-1.10.2.tar.gz -C /usr/local/src

    # cd /usr/local/src/nginx-1.10.2

# ./configure \
--prefix=/usr/local/nginx \
--sbin-path=/usr/sbin/nginx \
--conf-path=/etc/nginx/nginx.conf \
--error-log-path=/var/log/nginx/error.log \
--http-log-path=/var/log/nginx/access.log \
--pid-path=/var/run/nginx.pid \
--lock-path=/var/run/nginx.lock \
--http-client-body-temp-path=/var/tmp/nginx/client \
--http-proxy-temp-path=/var/tmp/nginx/proxy \
--http-fastcgi-temp-path=/var/tmp/nginx/fcgi \
--http-uwsgi-temp-path=/var/tmp/nginx/uwsgi \
--http-scgi-temp-path=/var/tmp/nginx/scgi \
--user=nginx \
--group=nginx \
--with-pcre \
--with-http_v2_module \
--with-http_ssl_module \
--with-http_realip_module \
--with-http_addition_module \
--with-http_sub_module \
--with-http_dav_module \
--with-http_flv_module \
--with-http_mp4_module \
--with-http_gunzip_module \
--with-http_gzip_static_module \
--with-http_secure_link_module \
--with-http_stub_status_module \
--with-http_auth_request_module \
--with-mail \
--with-mail_ssl_module \
--with-file-aio \
--with-ipv6 \
--with-threads \
--with-stream \
--with-stream_ssl_module

    #  make && make install

三、安装后配置

  1. 添加系统启动脚本

    输入命令# vim /etc/init.d/nginx打开SysV启动脚本文件,然后在脚本文件中写下如下内容:

    

#!/bin/sh
#
# nginx - this script starts and stops the nginx daemon
#
# chkconfig: - 85 15
# description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server
# processname: nginx
# config: /etc/nginx/nginx.conf
# config: /etc/sysconfig/nginx
# pidfile: /var/run/nginx.pid
# Source function library.
. /etc/rc.d/init.d/functions
# Source networking configuration.
. /etc/sysconfig/network
# Check that networking is up.
[ "$NETWORKING" = "no" ] && exit 0
nginx="/usr/sbin/nginx"
prog=$(basename $nginx)
NGINX_CONF_FILE="/etc/nginx/nginx.conf"
[ -f /etc/sysconfig/nginx ] && . /etc/sysconfig/nginx
lockfile=/var/lock/subsys/nginx
start() {
[ -x $nginx ] || exit 5
[ -f $NGINX_CONF_FILE ] || exit 6
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
killall -9 nginx
}
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

    按下Esc键,然后输入:wq并回车以保存并关闭SysV启动脚本文件

  2. 赋予脚本执行权限

    # chmod +x /etc/init.d/nginx

  3. 添加至服务管理列表,设置开机自启

    # chkconfig  nginx on

  4. 启动服务

    # service nginx start

CentOS6.5 编译安装Nginx的更多相关文章

  1. Centos6.4 编译安装 nginx php

    一. 准备依赖库 安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc gcc-c++ 二. ...

  2. centos6.9编译安装nginx

    1.安装nginx所需的依赖包: yum -y install gcc gcc-c++ autoconf automake  zlib zlib-devel openssl openssl-devel ...

  3. Centos6.6 编译安装nginx

    一.基本环境 nginx 1.9版以后增加了一些新的特性,支持tcp负载均衡,不过这次还是用1.8.0,这里面有个memcached的代理模块,有时间再测试下 1.centos6.6 2.nginx1 ...

  4. centos6.5编译安装nginx

    系统64位 centos6.5 nginx官网:http://nginx.org/ 下载nginx源码包: wget  http://nginx.org/download/nginx-1.6.2.ta ...

  5. 【转】linux 编译安装nginx,配置自启动脚本

    linux 编译安装nginx,配置自启动脚本 本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装ng ...

  6. linux 编译安装nginx,配置自启动脚本

    本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装nginx,记录下安装过程: 参照这篇文章:Linu ...

  7. Linux.Centos6编译安装nginx

    环境 系统环境:CentOS release 6.7 (Final) 需求 centos6.7编译安装nginx1.x 准备 安装依赖 yum install -y gcc gcc-c++ autoc ...

  8. CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached

    声明:部分编译指令在博客编辑器里好像被处理了,如双横线变成单横线了等等,于是在本地生成了一个pdf版本,在下面地址可以下载. LNMP+Memcached CentOS是红帽发行的免费的稳定Linux ...

  9. CentOS6.3编译安装Nginx1.4.7 + MySQL5.5.25a + PHP5.3.28

    [准备工作] #在编译安装lnmp之前,首先先卸载已存在的rpm包. rpm -e httpd rpm -e mysql rpm -e php yum -y remove httpd yum -y r ...

随机推荐

  1. shell编程注意点

    1.标准输入输出转存不能随便用,例如: echo "export PATH=/home/huangmr/jdk/bin:\$PATH" >> /home/huangmr ...

  2. 脚本_查看当前系统每个IP的连接数

    #!bin/bash#作者:liusingbon#功能:查看当前系统每个IP的连接数netstat -n | awk '/^tcp/ {print $5}'| awk -F: '{print $1}' ...

  3. framebuffer测试程序

    /* framebuffer简单测试程序 网上转载 很多次 的程序 :-) */ #include <stdio.h> #include <stdlib.h> #include ...

  4. caffe py3 docker

    https://hub.docker.com/r/mapler/caffe-py3/ docker pull mapler/caffe-py3 docker run  -it  mapler/caff ...

  5. WPF 多个选项卡TabControl 页面分离

    此项目源码下载地址:https://github.com/lizhiqiang0204/TabControl-page-separation 每个页面的按键处理事件直接对应该页面下的cs文件 Main ...

  6. SpringBoot 1.x 之入门

    1 SpringBoot简介 SpringBoot简化Spring应用开发,约定大于配置,去繁从简,just run就能创建一个独立的,产品级别的应用. 背景: J2EE笨重的开发.繁多的配置.低下的 ...

  7. Linux系统无法启动故障解决方案

    Linux系统无法启动故障解决方案 2011-09-27 09:42 佚名 比特网 我要评论(0) 字号:T | T 不管你多么喜爱你的Linux系统机器,有时候你都必须恢复你的系统.是的,即使一台L ...

  8. <el-tree>文字显示不全解决办法(可以用省略号代替)

    地址: https://www.jianshu.com/p/229f96b794d3

  9. javascript(腾讯)

    var a={key:"1",value:2}; war b=a; b.value+=a.key, 打印b.value是多少,a.value呢? 答案:都是21.因为javascr ...

  10. c# 操作mysql数据库的时候会出现 插入中文汉字变成问号?

    场景: 在mysql ce里面执行时没有问题的. c#操作会出现问号. 原因是:  链接字符串的时候 要设置Charset=utf8; 不然就会按默认的服务器设置编码,通常会出问题. 检查: 1.创建 ...