ubuntu 16.04通过源码方式安装nginx
1.下载nginx源码包
wget http://nginx.org/download/nginx-1.11.12.tar.gz
2.解压该tar包
tar zxvf nginx-1.11.12.tar.gz
3.编译参数说明
--prefix=path 定义一个目录来保存你的nginx的提供功能的文件夹,就这好比我们安装软件的时候软件存放的目录,如果我们在编译的不指定安装位置,那么默认的位置/usr/local/nginx 目录
--sbin-path=path 设置nginx执行脚本的位置,这里如果设置在path变量里面,就可以在bash环境下,任意使用nginx命令,默认位置prefix/sbin/nginx 注意这里的prefix是在配置文件里面配置的路径
--conf-path=path 配置nginx配置文件的路径,如果不指定这个选项,那么配置文件的默认路径就会是 prefix/conf/nginx.conf
--pid-path =path 配置nginx.pid file的路径,一般来说,进程在运行的时候的时候有一个进程id,这个id会保存在pid file里面,默认的pid file的放置位置是prefix/logs/nginx.pid
--error-log-path=path 设置错误日志的存放路径,如果不指定,就默认 prefix/logs/error.log
--http-log-path= path 设置http访问日志的路径,如果不指定,就默认 prefix/logs/access.log
--user=name 设置默认启动进程的用户,如果不指定,就默认 nobody
--group=name 设置这个用户所在的用户组,如果不指定,依然是nobody
这些是我们常用的编译选项,其他的可以均保持默认,如需特殊指定,可上nginx官网查阅 http://nginx.org/en/docs/configure.html
下面是一些不常用的选项
--with-http_ssl_module -开启HTTP SSL模块,使NGINX可以支持HTTPS请求。需要安装了OPENSSL
--with-http_flv_module
--with-http_stub_status_module - 启用 "server status" 页(可有可无)
--without-http_gzip_module - 禁用 ngx_http_gzip_module. 如果启用,需要 zlib 。
--without-http_ssi_module - 禁用 ngx_http_ssi_module
--without-http_referer_module - 禁用 ngx_http_referer_module
--without-http_rewrite_module - 禁用 ngx_http_rewrite_module. 如果启用需要 PCRE 。
--without-http_proxy_module - 禁用 ngx_http_proxy_module
--without-http_fastcgi_module - 禁用 ngx_http_fastcgi_module
--without-http_memcached_module - 禁用 ngx_http_memcached_module
--without-http_browser_module - 禁用 ngx_http_browser_module
--http-proxy-temp-path=PATH - Set path to the http proxy temporary files
--http-fastcgi-temp-path=PATH - Set path to the http fastcgi temporary files
--without-http - 禁用 HTTP server(用作代理或反向代理)
--with-mail - 启用 IMAP4/POP3/SMTP 代理模块
--with-mail_ssl_module - 启用 ngx_mail_ssl_module
--with-openssl=DIR - Set path to OpenSSL library sources
4.源码编译步骤
a.切换到解压目录
cd nginx-1.11.12
b.执行configure命令
sudo ./configure
c.执行make命令
sudo make
d.执行安装命令
sudo make install
注意:
如果编译过程出现the HTTP rewrite module requires the PCRE library.的错误
需要安装以下插件
安装pcre
sudo apt install libpcre3 libpcre3-dev
安装 openssl
sudo apt-get intall openssl libssl-dev
5.使用sysv-rc-conf(chkconfig)的方式管理nginx服务
安装sysv-rc-conf:sudo apt-get install sysv-rc-conf
a.首先添加nginx服务管理的脚本
sudo vim /etc/init.d/nginx
#! /bin/sh
# chkconfig: 2345 55 25
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'update-rc.d -f nginx defaults', or use the appropriate command on your
# distro. For CentOS/Redhat run: 'chkconfig --add nginx'
### 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
# Author: licess
# website: http://lnmp.org
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=nginx
NGINX_BIN=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/$NAME.conf
PIDFILE=/usr/local/nginx/logs/$NAME.pid
case "$1" in
start)
echo -n "Starting $NAME... "
if netstat -tnpl | grep -q nginx;then
echo "$NAME (pid `pidof $NAME`) already running."
exit 1
fi
$NGINX_BIN -c $CONFIGFILE
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
stop)
echo -n "Stoping $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi
$NGINX_BIN -s stop
if [ "$?" != 0 ] ; then
echo " failed. Use force-quit"
exit 1
else
echo " done"
fi
;;
status)
if netstat -tnpl | grep -q nginx; then
PID=`pidof nginx`
echo "$NAME (pid $PID) is running..."
else
echo "$NAME is stopped"
exit 0
fi
;;
force-quit)
echo -n "Terminating $NAME... "
if ! netstat -tnpl | grep -q nginx; then
echo "$NAME is not running."
exit 1
fi
kill `pidof $NAME`
if [ "$?" != 0 ] ; then
echo " failed"
exit 1
else
echo " done"
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
reload)
echo -n "Reload service $NAME... "
if netstat -tnpl | grep -q nginx; then
$NGINX_BIN -s reload
echo " done"
else
echo "$NAME is not running, can't reload."
exit 1
fi
;;
configtest)
echo -n "Test $NAME configure files... "
$NGINX_BIN -t
;;
*)
echo "Usage: $0 {start|stop|force-quit|restart|reload|status|configtest}"
exit 1
;;
esac
b.给脚本添加执行权限
sudo chmod +x /etc/init.d/nginx
sudo sysv-rc-conf --list #查看一下list中有没有刚刚加进去的这个nginx管理脚本
c.添加到开机自启动
sudo sysv-rc-conf nginx on(这一步实际上就是实现了一个链接)
d.加载安装服务
sudo systemctl enable nginx(如果不愿意重启的话)
e.启动nginx服务
sudo service nginx start
f.测试nginx
curl localhost
ubuntu 16.04通过源码方式安装nginx的更多相关文章
- Ubuntu 16.04通过源码安装QUEM虚拟机
下载编译安装: wget http://download.qemu-project.org/qemu-2.9.0.tar.xz tar xvJf qemu-2.9.0.tar.xz cd qemu-2 ...
- 通过源码编译安装VIM
开发中使用的是Ubuntu 12.04 LTS,通过sudo apt-get install vim安装的版本较低,不支持YCM,所以,用源码编译并安装最新的Vim. 卸载旧版本的Vim: sudo ...
- Ubuntu 16.04下EasyOpenJTAG+OpenOCD的安装和使用【转】
本文转载自:http://www.linuxdiyf.com/linux/24086.html Ubuntu 16.04下EasyOpenJTAG+OpenOCD的安装和使用 发布时间:2016-09 ...
- ubuntu 16.04 anaconda 4.2.0 安装tensorflow 报错
ubuntu 16.04 anaconda 4.2.0 安装tensorflow 报错. 安装pyenv后,在pyenv环境内安装 anaconda,然后再安装tensorflow不再报错,比较奇怪, ...
- ubuntu 16.04上源码编译和安装cgal并编写CMakeLists.txt | compile and install cgal on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/39ab7ed9/,欢迎阅读最新内容! compile and install cgal on ubuntu 16.04 Guide ...
- Ubuntu 16.04上源码编译和安装pytorch教程,并编写C++ Demo CMakeLists.txt | tutorial to compile and use pytorch on ubuntu 16.04
本文首发于个人博客https://kezunlin.me/post/54e7a3d8/,欢迎阅读最新内容! tutorial to compile and use pytorch on ubuntu ...
- ubuntu 16.04上 mysql 5.7 安装笔记
一 安装 ubuntu 采用APT安装方式,可参考: Ubuntu 安装mysql和简单操作 Ubuntu 16.04安装MySQL(5.7.18) A Quick Guide to Using th ...
- Windows 10+Ubuntu 16.04在MBR分区上安装双系统(转)
以下内容转自这篇博客: http://www.cnblogs.com/Duane/p/5424218.html http://www.cnblogs.com/Duane/p/6776302.html( ...
- Linux下通过源码编译安装程序
本文简单的记录了下,在linux下如何通过源码安装程序,以及相关的知识.(大神勿喷^_^) 一.程序的组成部分 Linux下程序大都是由以下几部分组成: 二进制文件:也就是可以运行的程序文件 库文件: ...
随机推荐
- 命令行传递参数并排序 AS实现加法
题目:从命令行输入参数并进行排序 1.实验准备 Integer提供了能在 int 类型和 String 类型之间互相转换的方法,还提供了处理 int 类型时非常有用的其他一些常量和方法. static ...
- EBS报错FRM-92095:Oracle JInitiator版本太旧,请安装版本1.1.8.2或更高版本
EBS打开报错FRM-92095:Oracle JInitiator版本太旧,请安装版本1.1.8.2或更高版本 打开EBS的form,系统报错,中文提示信息是:FRM-92095:oracle ji ...
- mdadm 软RAID
mdadm是linux下用于创建和管理软件RAID的命令,是一个模式化命令.但由于现在服务器一般都带有RAID阵列卡,并且RAID阵列卡也很廉价,且由于软件RAID的自身缺陷(不能用作启动分区.使用C ...
- leetcode 回文数
判断一个整数是否是回文数.回文数是指正序(从左向右)和倒序(从右向左)读都是一样的整数. 示例 1: 输入: 121 输出: true 示例 2: 输入: -121 输出: false 解释: 从左向 ...
- Katalon Studio简单使用(一)
官网地址:https://www.katalon.com/ katalon 目前有两种产品 一个是studio 另外一个是katalon analytics,此处先来学习studio部分. 文章学习内 ...
- AGC007C Pushing Balls
题目链接 题意:\(N\)个坑,\(N+1\)个球,相间分布,距离为以\(d_1\)为首项,\(x\)为公差的等差数列.对于每次操作,随机选择一个未入坑的球,随机选择向左或向右,掉入第一个没有球的坑, ...
- mysql主从报错截图
1.首先确认报错的binlog和last event. 2.然后去主的机器上查看该报错的内容和报错的的位置,如果是结尾报错的,可以直接从新的binlog进行同步. #/mysql/logs# ../b ...
- Java中运算符“|”和“||”以及“&”和“&&”区别
1.“|”运算符:不论运算符左侧为true还是false,右侧语句都会进行判断,下面代码 int a =1,b=1; if(a++ == 1 | ++b == 2) System.out.printl ...
- 图解JVM内存分配和回收
一.简介 JVM采用分代垃圾回收.在JVM的内存空间中把堆空间分为年老代和年轻代.将大量(据说是90%以上)创建了没多久就会消亡的对象存储在年轻代,而年老代中存放生命周期长久的实例对象.年轻代中又被分 ...
- 【javascript】判断是否微信浏览器的最佳实践
根据判断UA中是否有关键字micromessenger,有的话则是微信内置浏览器 用Chrome的iPhone5模拟测试 //判断是否微信登陆 function isWeiXin() { var ua ...