文本只涉及单节点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. [C][代码实例]交换指向常量的二级指针的位置

    #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> ...

  2. oracle数据库链路和同义词

    Oracle数据库链路的建立和使用 先来一个例子: --创建数据库链路create   public   database link xaffdblink connect to zdcl identi ...

  3. 洛谷P4606 [SDOI2018]战略游戏 [广义圆方树]

    传送门 思路 先考虑两点如何使他们不连通. 显然路径上所有的割点都满足条件. 多个点呢?也是这样的. 于是可以想到圆方树.一个点集的答案就是它的虚树里圆点个数减去点集大小. 可以把点按dfs序排序,然 ...

  4. swift 实践- 04 -- UIButton

    import UIKit class ViewController: UIViewController { // 按钮的创建 // UIButtonType.system: 前面不带图标, 默认文字为 ...

  5. Confluence 6 附件是如何被索引的

    当一个文件被上传到 Confluence 后,Confluence 将会尝试对文件进行解压,然后对文件中的内容进行索引.这样系统就能够允许用户对文件中的内容进行搜索,而不仅仅是搜索文件名.这个过程对系 ...

  6. iframe与主框架跨域相互访问方法

    iframe 与主框架相互访问方法  http://blog.csdn.net/fdipzone/article/details/17619673/ 1.同域相互访问 假设A.html 与 b.htm ...

  7. PhpStorm 2018 安装及破解方法

    参考教程: https://blog.csdn.net/u012278016/article/details/81772566

  8. cf1114D 区间dp基础

    最简单的那类区间dp,昨天晚上心态不对,不知道在打什么.. /* dp[l][r]表示区间[l,r]都涂成同色的代价 dp[l][r]可以由dp[l][r-1],dp[l+1][r],dp[l+1][ ...

  9. Spring Security Filter执行顺序

    1.场景:先走框架过滤器,后走自定义过滤器 @Bean public FilterRegistrationBean resourceFilterRegistration() { FilterRegis ...

  10. noip 初赛复习重点知识点

    一.进制转化 将k进制数转化为十进制数: 设k进制数为(abcd)k,则对应十进制数为 (小数同理,乘k的负幂次) 将十进制数转成k进制数: 设十进制数为x: t1=x/k,t2=x mod k t1 ...