文本只涉及单节点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. oracle_基本SQL语言

      一:DDL数据定义语言 1:create(创建)       创建表 CREATE TABLE <table_name>( column1 DATATYPE [NOT NULL] [P ...

  2. Confluence 6 审查日志

    日志审查能够允许管理查看你 Confluence 站点所做的修改.这个在你希望对你的 Confluence 进行问题查看或者是你希望对你 Confluence 保留重要的修改事件,例如修改了全局权限. ...

  3. Confluence 6 尝试从 XML 备份中恢复时解决错误

    错误可能是因为数据库突然不可访问而产生.也有可能是你备份文件有问题,你需要找到你 XML 备份文件中违反数据库规定的记录修改这个记录后再创建一个新的 XML 备份: 在实例开始恢复的时候,请按照下面的 ...

  4. Confluence 6 使用 Jira 管理用户

    如果你已经使用了 Jira 来管理你的任务和 issue 的话,你可以选择将 Jira 和 Confluence 整合在一起,将用户管理集中到一个地方.你可以控制你 Jira 中的用户组是否具有使用 ...

  5. python冒泡排序法

  6. npm无反应的问题&npm常用命令

    RT: windows安装完nodejs后做了相关环境变量配置后,cmd输入npm命令无反应,就光标一直闪,百度了半天终于找到解决办法 解决方法:C:\Users\Administrator(或你的账 ...

  7. ActiveMQ消息的消费原理

    消费端消费消息: 在 初识ActiveMQ 中我提到过,两种方法可以接收消息,一种是使用同步阻塞的ActiveMQMessageConsumer#receive方法.另一种是使用消息监听器Messag ...

  8. Nginx详解七:Nginx基础篇之Nginx官方模块

    Nginx官方模块 --with-http_stub_status_module:Nginx的客户端状态,用于监控连接的信息,配置语法如下:配置语法:stub_status;默认状态:-配置方法:se ...

  9. WARN Session 0x0 for server null, unexpected error, closing socket connection and attempting reconnect (org.apache.zookeeper.ClientCnxn) java.net.ConnectException: Connection refused

    1.启动kafka的脚本程序报如下所示的错误: [hadoop@slaver1 script_hadoop]$ kafka-start.sh start kafkaServer... [-- ::,] ...

  10. 一脸懵逼学习Hive的元数据库Mysql方式安装配置

    1:要想学习Hive必须将Hadoop启动起来,因为Hive本身没有自己的数据管理功能,全是依赖外部系统,包括分析也是依赖MapReduce: 2:七个节点跑HA集群模式的: 第一步:必须先将Zook ...