文本只涉及单节点nginx

安装gcc g++依赖库

apt-get install build-essential
apt-get install libtool

安装pcre依赖库

apt-get update
apt-get install libpcre3 libpcre3-dev

安装zlib依赖库

apt-get install zlib1g-dev

安装ssl依赖库

apt-get install openssl

下载并安装

wget -P /opt/downloads http://nginx.org/download/nginx-1.15.9.tar.gz
tar zxvf /opt/downloads/nginx-1.15..tar.gz -C /opt
cd /opt/nginx-1.15.9
./configure
./configure --prefix=/opt/nginx
make
make install

修改nginx配置

vim /usr/local/nginx/conf/nginx.conf

放出pid

error_log  logs/error.log;
error_log logs/error.log notice;
error_log logs/error.log info; pid logs/nginx.pid;

去掉http节点下某些注释(非必须)

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; access_log logs/access.log main;

验证配置文件

/usr/local/nginx/sbin/nginx -t 

启动

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

注:-c 指定配置文件的路径,不加的话,nginx会自动加载默认路径的配置文件,可以通过 -h查看帮助命令。

停止

/usr/local/nginx/sbin/nginx -s stop

帮助

/usr/local/nginx/sbin/nginx -h

守护进程启动:

vim /lib/systemd/system/nginx.service
[Unit]
Description=nginx
After=syslog.target network.target remote-fs.target nss-lookup.target [Service]
Type=forking
PIDFile=/usr/local/nginx/logs/nginx.pid
ExecStartPre=/usr/local/nginx/sbin/nginx -t
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload -c /usr/local/nginx/conf/nginx.conf
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

赋予权限

chmod  /lib/systemd/system/nginx.service

启用守护进程

systemctl enable nginx.service
systemctl daemon-reload

运行

systemctl start nginx.service

查看日志

journalctl -f -u nginx.service

查看状态

systemctl status nginx.service

查看nginx进程

ps -ef|grep nginx

nginx安装,运行(ubuntu)的更多相关文章

  1. windows server,nginx安装,配置,运行nodeJS后端的web项目的实现,以及错误分析及解决方法

    一.安装nginx 下载windows版nginx (http://nginx.org/download/nginx-1.12.2.zip),之后解压到需要放置的位置(C:\nginx) 二.将Ngi ...

  2. mac 安装nginx,并配置nginx的运行环境

    1. 安装nginx // 查询有没有nginx brew search nginx //开始安装nignx brew install nginx 2. 检查nignx是否安装成功 nginx -V ...

  3. ubuntu 12.04 下nginx安装步骤

    2013-12-05 10:25 2289人阅读 评论(0) 收藏 举报  分类: Ubuntu/Linux(17)  nginx(4)  转自:http://blog.csdn.net/acccca ...

  4. HHvm Apache 2.4 Nginx建站环境搭建方法安装运行WordPress博客

    HHvm Apache 2.4 Nginx建站环境搭建方法安装运行WordPress博客 VPS主机   2014年06月02日 17:20   评论»       文章目录 Debian上安装 Ce ...

  5. Windows下将nginx安装为服务运行

    今天看到nginx这个小服务器软件正式版更新到了1.4.2,想玩下它.这个服务器软件虽小,但功能强大,是开源软件,有着良好的性能,被很多个人.企业,甚至大型企业所使用! 由于是在Windows下,所以 ...

  6. .Net Core Linux centos7行—安装nginx,运行静态网站

    使用编译安装方式安装nginx Nginx下载地址:http://nginx.org/en/download.html.下载Stable version(稳定版就好).当前稳定版:http://ngi ...

  7. ubuntu nginx 安装以及配置文件详解

    1.到nginx官网下载源码包.最好下载稳定版本,nginx官网http://www.nginx.org/ 2.安装nginx依赖包运行命令: sudo apt-get install libssl- ...

  8. ubuntu server nginx 安装与配置

    ubuntu server nginx 安装与配置 一:关于nginx http://wiki.ubuntu.org.cn/Nginx http://nginx.org/cn http://wiki. ...

  9. 以非root权限安装nginx及运行

    本章主要讲如何在无root权限(包含无sudo权限)条件下于centos命令行中安装nginx以及在大于1024的端口(这里用8080)上运行. 1. 安装 两种方式,一是下载预编译好的rpm包安装, ...

随机推荐

  1. Golang的单引号、双引号与反引号

    Go语言的字符串类型string在本质上就与其他语言的字符串类型不同: Java的String.C++的std::string以及Python3的str类型都只是定宽字符序列 Go语言的字符串是一个用 ...

  2. IntelliJ IDEA使用教程 (总目录篇)

    注:本文来源于<    IntelliJ IDEA使用教程 (总目录篇)  > IntelliJ IDEA使用教程 (总目录篇) 硬件要求 IntelliJ IDEA 的硬件要求 安装包云 ...

  3. Confluence 6 访问日志脚本

    日志访问脚本在连接:https://confluence.atlassian.com/download/attachments/133267635/Atlassian-accessLogScripts ...

  4. 探索一个NSObject对象占用多少内存?

    1 下面写代码测试探索NSObject的本质 Objective-C代码,底层实现其实都是C\C++代码 #import <Foundation/Foundation.h> int mai ...

  5. JSP 隐式对象

    一. 隐式对象 JSP隐式对象 对象 类型 request javax.servlet.http.HttpServletRequest response javax.servlet.http.Http ...

  6. 在anaconda中安装tensorflow

    打开Anaconda Prompt, step1: 输入清华仓库镜像 conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/ ...

  7. numpy 与 pandas

    numpy: import numpy as np np.array([1,2,3]) 创建数组 np.arange(10).reshape(2,5) 类似于range(起始,终止,步长),可以加re ...

  8. SSM框架接收处理安卓端的json数据

    最近项目上与安卓端做JSON数据交互,使用的SSM框架,刚开始的时候感觉很简单,想着不就是把安卓端的JSON数据封装为Bean类对象吗? 于是就这样写了 可是这样一直报400,百度原因是因为请求url ...

  9. 插件使用一表单验证一validation

    jquery-validation是一款前端经验js插件,可以验证必填字段.邮件.URL.数字范围等,在表单中应用非常广泛. 官方网站 https://jqueryvalidation.org/ 源码 ...

  10. C/C++内存管理器

    C标准库提供了malloc,free,calloc,realloc,C++标准库还提供了new, new[], delete, delete[].这些用来管理内存,看起来够用了,为啥还要自己写一个内存 ...