`

ubuntu下编译安装nginx

阅读更多
First, we need to get the latest version of nginx :

> wget http://nginx.org/download/nginx-0.8.34.tar.gz
> tar xvzf nginx-0.8.34.tar.gz
> cd nginx-0.8.34
Next, configure it to support ssl, gzip, flv streaming and real-ip. I generally compile it to /opt/nginx-YYMMDD (change the —prefix setting if you want to put it somewhere else) :

> ./configure \
        --prefix=/opt/nginx-20100311 \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module
At this point I got an error about missing PCRE – this Ubuntu installation is basically fresh so there’s a lot of stuff missing.

./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
I had libpcre3 installed, but i needed libpcre3-dev as well.

> sudo aptitude install libpcre3-dev 
> ./configure \
        --prefix=/opt/nginx-20100311 \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module
We get a bit further this time, but still no luck.

./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
This time it’s libssl-dev that’s missing :

> sudo aptitude install libssl-dev
> ./configure \
        --prefix=/opt/nginx-20100311 \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_flv_module \
        --with-http_realip_module
.....
.....
.....

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + md5: using OpenSSL library
  + sha1 library is not used
  + using system zlib library
Now that we’ve successfully configured it, we can compile and install :

> make 
> sudo make install
Now, make a symlink so you can switch to newer versions easily :

> sudo ln -s /opt/nginx-20100311 /opt/nginx
Finally, we want to set up a startup script. Create the file /etc/init.d/nginx and paste the following in :

#! /bin/sh

### BEGIN INIT INFO
# Provides:          nginx
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: starts the nginx web server
# Description:       starts nginx using start-stop-daemon
### END INIT INFO

PATH=/opt/nginx/sbin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/opt/nginx/sbin/nginx
NAME=nginx
DESC=nginx

test -x $DAEMON || exit 0

# Include nginx defaults if available
if [ -f /etc/default/nginx ] ; then
	. /etc/default/nginx
fi

set -e

case "$1" in
  start)
	echo -n "Starting $DESC: "
	start-stop-daemon --start --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  stop)
	echo -n "Stopping $DESC: "
	start-stop-daemon --stop --quiet --pidfile /var/run/$NAME.pid \
		--exec $DAEMON
	echo "$NAME."
	;;
  restart|force-reload)
	echo -n "Restarting $DESC: "
	start-stop-daemon --stop --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON
	sleep 1
	start-stop-daemon --start --quiet --pidfile \
		/var/run/$NAME.pid --exec $DAEMON -- $DAEMON_OPTS
	echo "$NAME."
	;;
  reload)
      echo -n "Reloading $DESC configuration: "
      start-stop-daemon --stop --signal HUP --quiet --pidfile /var/run/$NAME.pid \
          --exec $DAEMON
      echo "$NAME."
      ;;
  *)
	N=/etc/init.d/$NAME
	echo "Usage: $N {start|stop|restart|reload|force-reload}" >&2
	exit 1
	;;
esac

exit 0
This allows you to start/stop the server easily (although I find stop a bit flakey) :

> /etc/init.d/nginx stop
> /etc/init.d/nginx start
Finally, we want to make sure nginx launches at startup :

> sudo update-rc.d nginx defaults
Now you should be able to load http://yourserver.com/ and see nginx.

The last thing to do is enable the flv streaming module. You’ll need to add a rule to your nginx.conf something like the following :

location ~ \.flv$ {
	flv;
	root /path/to/your/flv/files;
}
This will catch any request with a .flv extension, and stream it from the folder /path/to/your/flv/files .

Done!
分享到:
评论

相关推荐

    ubuntu20.04离线无网dpkg安装nginx按完整的deb包

    在本场景中,我们将关注如何在没有网络连接的情况下,使用`dpkg`工具安装Nginx服务器,以及可能需要的编译工具如GCC和Make。 首先,`dpkg`是Debian和基于Debian的系统(包括Ubuntu)中的包管理器,它允许用户安装、...

    ubuntu18.04下交叉编译nginx1.18.0源码(平台aarch64-linux-gnu)

    以上就是在Ubuntu 18.04上交叉编译Nginx 1.18.0以支持H265编码的RTMP推流和HTTP-FLV拉流的完整过程。这个过程涉及到了多个库的交叉编译和Nginx的模块化扩展,是实现高效、稳定音视频流服务的基础。在实际操作中,...

    ubuntu开机自启动nginx服务

    ubuntu开机自启动nginx服务

    linux操作系统下安装nginx步骤

    在Linux操作系统下安装Nginx是一项常见的任务,尤其对于服务器管理员和Web开发者而言。Nginx是一个高性能的HTTP和反向代理服务器,以其高效的性能、稳定性以及对高并发请求的处理能力而广受青睐。本教程将详细介绍在...

    Ubuntu下nginx1.6和sticky1.1安装配置资料 包

    配置完成后,运行`make`来编译Nginx,然后使用`make install`进行安装。在“nginx执行make命令编译成功之后的界面.png”和“nginx执行make install安装完成之后界面.png”中,你应该能看到编译和安装过程的截图。 ...

    Ubuntu下nginx编译安装参数配置

    在Ubuntu系统中,安装Nginx通常有两种方法:使用官方提供的包管理器(如`apt-get`)或者通过源代码编译安装。本教程将详细讲解后者,即编译安装Nginx,并介绍相关的参数配置和依赖库安装。 首先,确保系统已经更新...

    Ubuntu12.04 nginx python uwsgi Django安装步骤

    Ubuntu 12.04 下安装 Nginx、Python、uWSGI 和 Django 的步骤 在本文中,我们将介绍如何在 Ubuntu 12.04 环境下安装 Nginx、Python、uWSGI 和 Django。这些技术栈组合是非常流行的 Web 应用程序开发环境。 一、...

    Ubuntu中Nginx服务器安装配置教程

    Ubuntu 中 Nginx 服务器安装配置教程 本文将指导您在 Ubuntu 系统中安装和配置 Nginx 服务器,以便实现高性能的 HTTP 和反向代理服务器,同时也可以作为 IMAP/POP3/SMTP 代理服务器。 Nginx 简介 Nginx 是一个轻...

    ubunt下安装nginx web服务器

    本文将手把手指导您在 Ubuntu 下安装 Nginx Web 服务器,包括安装前提、Nginx 源码下载、目录结构认识、Nginx 的编译和安装、Nginx 的启动和简单使用。 安装前提 在安装 Nginx 之前,您需要满足以下条件: 1. ...

    linux下安装Nginx所需依赖包

    在Linux环境下安装Nginx,需要先确保系统已经准备好所有必要的依赖包,这样才能确保Nginx能够正常运行。 首先,我们要知道Linux发行版的不同会影响安装方式和依赖包的选择。常见的Linux发行版如Ubuntu/Debian和...

    Ubuntu16.04.1 安装Nginx的方法

    这些是编译Nginx所必需的,否则在编译过程中可能会遇到缺少依赖的问题。具体来说: - `gcc` 和 `g++` 是 GNU Compiler Collection 和 GNU C++ Compiler,用于编译源代码。 - `libtool` 是一个通用的库支持脚本,...

    内网安装nginx(离线)

    - 在内网服务器上,检查并安装编译Nginx所需的依赖库。通常包括pcre、openssl和zlib。例如,在Ubuntu系统上,可以运行: ``` sudo apt-get update sudo apt-get install build-essential libpcre3-dev libssl-...

    Linux离线安装nginx安装包

    同时,为了编译Nginx,我们还需要openssl和gcc这两个依赖项。openssl用于提供加密支持,而gcc是C编译器,用于编译Nginx源码。 1. **openssl的安装** - 首先,从openssl官网下载对应版本的源码,例如:`...

    nginx-1.26.0最新版本已完成编译可解压直接使用

    编译 Nginx 时,我们需要首先安装必要的依赖库,如 OpenSSL、PCRE 和 zlib。以下是在大多数 Linux 发行版上编译的步骤: 1. **安装依赖**: ``` sudo apt-get install build-essential libpcre3-dev libssl-dev ...

    arm架构nginx编译器安装

    本文将详细讲解在基于ARM架构的系统上编译安装Nginx的过程,这对于那些希望在嵌入式设备或基于ARM的服务器上运行高性能Web服务的用户来说至关重要。 首先,你需要确保你的ARM系统已经安装了必要的编译工具和依赖库...

    Nginx 1.22.0 Linux 版本,解压安装。

    Nginx 1.22.0 Linux 版本,解压安装。 Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,在BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力在同类型...

    Nginx1.22.0版本Linux已编译可直接使用

    在 Linux 环境中部署 Nginx,用户通常需要自行编译源代码,配置所需模块并安装。然而,这个“Nginx1.22.0 版本 Linux 已编译可直接使用”的压缩包提供了预编译的二进制文件,简化了部署过程,使得用户可以直接在 ...

    nignx 离线安装所需环境包及nginx离线包

    本资源提供了Nginx的离线安装所需环境包,这对于那些无法直接访问互联网或者需要在隔离环境中部署Nginx的场景尤其有用。下面我们将详细探讨Nginx的安装过程,以及"lib基础包"和"lib2 rpm文件"在其中的角色。 1. **...

    linux离线环境下nginx安装包-附带所有依赖环境和安装教程

    在这种环境下,要安装像Nginx这样的软件,就需要采用离线安装的方式。本文将详细介绍如何使用提供的Linux离线环境下Nginx安装包,包括所有必要的依赖环境和安装教程。 Nginx是一款高性能、轻量级的Web服务器和反向...

Global site tag (gtag.js) - Google Analytics