CentOS6.5 编译安装Nginx
一、准备编译环境
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的更多相关文章
- Centos6.4 编译安装 nginx php
一. 准备依赖库 安装make: yum -y install gcc automake autoconf libtool make 安装g++: yum install gcc gcc-c++ 二. ...
- centos6.9编译安装nginx
1.安装nginx所需的依赖包: yum -y install gcc gcc-c++ autoconf automake zlib zlib-devel openssl openssl-devel ...
- Centos6.6 编译安装nginx
一.基本环境 nginx 1.9版以后增加了一些新的特性,支持tcp负载均衡,不过这次还是用1.8.0,这里面有个memcached的代理模块,有时间再测试下 1.centos6.6 2.nginx1 ...
- centos6.5编译安装nginx
系统64位 centos6.5 nginx官网:http://nginx.org/ 下载nginx源码包: wget http://nginx.org/download/nginx-1.6.2.ta ...
- 【转】linux 编译安装nginx,配置自启动脚本
linux 编译安装nginx,配置自启动脚本 本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装ng ...
- linux 编译安装nginx,配置自启动脚本
本文章来给各位同学介绍一篇关于linux 编译安装nginx,配置自启动脚本教程,希望有需要了解的朋友可一起来学习学习哦. 在公司的suse服务器装nginx,记录下安装过程: 参照这篇文章:Linu ...
- Linux.Centos6编译安装nginx
环境 系统环境:CentOS release 6.7 (Final) 需求 centos6.7编译安装nginx1.x 准备 安装依赖 yum install -y gcc gcc-c++ autoc ...
- CentOS6.6 32位 Minimal版本纯编译安装Nginx Mysql PHP Memcached
声明:部分编译指令在博客编辑器里好像被处理了,如双横线变成单横线了等等,于是在本地生成了一个pdf版本,在下面地址可以下载. LNMP+Memcached CentOS是红帽发行的免费的稳定Linux ...
- 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 ...
随机推荐
- urllib urllib2学习笔记
Python的urllib和urllib2模块都做与请求URL相关的操作,但他们提供不同的功能.他们两个最显着的差异如下: urllib2可以接受一个Request对象,并以此可以来设置一个URL的h ...
- Java并发编程实战 第16章 Java内存模型
什么是内存模型 JMM(Java内存模型)规定了JVM必须遵循一组最小保证,这组保证规定了对变量的写入操作在何时将对其他线程可见. JMM为程序中所有的操作定义了一个偏序关系,称为Happens-Be ...
- docker 部署springboot项目【转载】
https://www.cnblogs.com/ityouknow/p/8599093.html
- MySQL优化建议与使用规范
适用场景:并发量大.数据量大的互联网业务;可以先阅读必须掌握的MySQL优化指南 一.基础规范 (1)必须使用InnoDB存储引擎 解读:支持事务.行级锁.并发性能更好.CPU及内存缓存页优化使得资源 ...
- 关于Python你不得不知道的Python语言特点
首先什么是语言?什么是编程? 准确来说是:定义计算机程序的语言,用来向计算机发送指令 个人理解: 语言:是一种交流的工具或者方式.比如我们的汉语普通话.各地的方言.外语中的英语.俄语.日语等.我们 ...
- 有关pip报错的问题
错误消息:“Fatal error in launcher: Unable to create process using '"' 解决办法: python3解决方案:python3 -m ...
- CodeForces-1167C
链接: https://vjudge.net/problem/CodeForces-1167C 题意: In some social network, there are n users commun ...
- mysql57 在windows 下无法修改 大小写设置
参考: https://blog.csdn.net/ceciliawanghenan/article/details/82916662 清空data文件,我的data文件在programdata\My ...
- SpringBoot的项目构建
手动构建SpringBoot项目 一.手动构建一个Maven,选择...webapp或者选择快速骨架生成,然后命名并生成项目: 二. 在pom.xml中,进行三处配置: 设置父模块,子模块就可以继承 ...
- Python 爬虫十六式 - 第七式:正则的艺术
RE:用匹配来演绎编程的艺术 学习一时爽,一直学习一直爽 Hello,大家好,我是 Connor,一个从无到有的技术小白.上一次我们说到了 pyquery 今天我们将迎来我们数据匹配部分的最后一位 ...