转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_5.html

进入/usr/local目录

cd /usr/local

下载最新版的ngxin压缩包

wget http://nginx.org/download/nginx-1.13.9.tar.gz

解压

tar -zxvf nginx-1.13..tar.gz

删除压缩包

rm -f nginx-1.13..tar.gz

进入nginx目录准备安装

cd nginx-1.13.

使用默认配置

./configure

安装

make && make install

删除安装文件,节约空间

rm -rf /usr/local/nginx-1.13.

添加环境变量

vim /etc/profile

在最后添加

export PATH=$PATH:/usr/local/nginx/sbin

使配置生效

source /etc/profile

添加nginx服务,首先新增启动文件

vim /etc/init.d/nginx

内容如下

#!/bin/sh
# nginx - this script starts and stops the nginx daemin
#
# chkconfig: - # description: Nginx is an HTTP(S) server, HTTP(S) reverse \
# proxy and IMAP/POP3 proxy server # processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit nginx="/usr/local/nginx/sbin/nginx" prog=$(basename $nginx) NGINX_CONF_FILE="/usr/local/nginx/conf/nginx.conf" lockfile=/var/lock/subsys/nginx start() { [ -x $nginx ] || exit [ -f $NGINX_CONF_FILE ] || exit echo -n $"Starting $prog: " daemon $nginx -c $NGINX_CONF_FILE retval=$? echo [ $retval -eq ] && touch $lockfile return $retval } stop() { echo -n $"Stopping $prog: " killproc $prog -QUIT retval=$? echo [ $retval -eq ] && rm -f $lockfile return $retval } restart() { configtest || return $? stop start } reload() { configtest || return $? echo -n $"Reloading $prog: " killproc $nginx -HUP RETVAL=$? echo } force_reload() { restart } configtest() { $nginx -t -c $NGINX_CONF_FILE } rh_status() { status $prog } rh_status_q() { rh_status >/dev/null >& } case "$1" in start) rh_status_q && exit
$
;; stop) rh_status_q || exit
$
;; restart|configtest)
$
;; reload)
rh_status_q || exit
$
;; force-reload)
force_reload
;;
status)
rh_status
;; condrestart|try-restart) rh_status_q || exit
;; *) echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
exit esac

添加到系统服务

chmod  /etc/init.d/nginx
chkconfig --add /etc/init.d/nginx

运行nginx和nginx服务

nginx
service nginx start

修改nginx,用它来代理转发node

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

修改location的默认路径转发到3000端口

location / {
proxy_pass http://127.0.0.1:3000;
}

让nginx重新加载配置

nginx -s reload

设置重启后自动以git用户启动test项目

首先新建启动文件

vim /etc/init.d/test_autorun

内容如下

#!/bin/sh
# chkconfig:
# description: text_autorun
# 以git用户启动服务
su - git -c "pm2 start /srv/www/test/index.js -i 1 --name \"test-production\""

然后设置它为可执行文件,并设置开机自动启动

chmod  /etc/init.d/test_autorun
chkconfig --add /etc/init.d/test_autorun

好了,现在nginx已经配置完成了。

【前端】CentOS 7 系列教程之五: 安装最新版 nginx 并转发 node 服务的更多相关文章

  1. RabbitMQ系列教程之五:主题(Topic)(转载)

    RabbitMQ系列教程之五:主题(Topic) (本实例都是使用的Net的客户端,使用C#编写),说明,中文方括号[]表示名词. 在上一个教程中,我们改进了我们的日志记录系统. 没有使用只能够进行虚 ...

  2. 实战SpringCloud响应式微服务系列教程(第八章)构建响应式RESTful服务

    本文为实战SpringCloud响应式微服务系列教程第八章,讲解构建响应式RESTful服务.建议没有之前基础的童鞋,先看之前的章节,章节目录放在文末. 1.使用springboot2.1.4构建RE ...

  3. 【前端】CentOS 7 系列教程之一: 安装 node 最新版

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_1.html 此系列教程从零开始,安装node.mysql.git,nginx.并且设置git自动部署. ...

  4. 【前端】CentOS 7 系列教程之六: 安装 mysql 5.7

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_6.html 进入/usr/local/src目录 cd /usr/local/src 下载mysql的 ...

  5. 【前端】CentOS 7 系列教程之四: 配置 git 服务器自动部署

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_4.html 安装pm2守护进程,备用 npm install -g pm2 创建/srv/www文件夹 ...

  6. 【前端】CentOS 7 系列教程之三: 搭建 git 服务器

    转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_3.html 上一篇我们安装好了git,这一篇我们搭建git服务器 创建一个用户组 groupadd g ...

  7. Docker系列教程01-Centos7安装新版Docker教程(10步)

    最近一直忙于开发,没有时间好好总结一下docker的知识.其实现在docker的教程已经很多很多了,但是很多系统的教程都是基于Ubuntu系统,因为官方推荐使用Ubuntu系统啊,原因在于Ubuntu ...

  8. 树莓派系列教程:安装系统与配置环境,使用PuTTy与VNC图形界面远程登录

    本文所需物品清单: Raspberry Pi 3 Model B 主板.SD卡与读卡器(用于烧录系统) 资料整理来源在文尾 需要下载的资源与工具: 推荐系统-Raspbian 树莓派官方深度定制的硬件 ...

  9. Yii2系列教程:安装及Hello World

    http://www.yiiframework.com/ 安装Yii2 打算从头开始,所以,连安装Yii2也稍微写一点吧.安装Yii2最好的方式就是使用composer: composer globa ...

随机推荐

  1. Codeforces 849B Tell Your World (计算几何)

    题目链接 Tell Your World 题意 给出N个点(i, xi),问是否存在两条平行的直线,使得每一个点恰好在两条直线的其中一条上. 每条直线必须穿过至少一个点. 考虑每个点和第1个点的斜率, ...

  2. Atcoder 2373 Cookie Exchanges

    Problem Statement Takahashi, Aoki and Snuke love cookies. They have A, B and C cookies, respectively ...

  3. java集合系列之ArrayList源码分析

    java集合系列之ArrayList源码分析(基于jdk1.8) ArrayList简介 ArrayList时List接口的一个非常重要的实现子类,它的底层是通过动态数组实现的,因此它具备查询速度快, ...

  4. R12: How to add Microsoft Excel as Type to the Create Template List of Values in BI Publisher (Doc ID 1343225.1)

    Modified: 27-Oct-2013 Type: HOWTO In this Document Goal Solution References APPLIES TO: BI Publisher ...

  5. MongoDB副本集的原理,搭建

    介绍: mongodb副本集即客户端连接到整个副本集,不关心具体哪一台机器是否挂掉.主服务器负责整个副本集的读写,副本集定期同步数据备份,一旦主节点挂掉,副本节点就会选举一个新的主服务器,这一切对于应 ...

  6. [转]PHP并发IO编程之路(深度长文)

    原文:https://www.imooc.com/article/8449 -------------------------------------------------------------- ...

  7. [CSS3] Define Form Element States with CSS Form Pseudo Classes

    Using just semantic CSS Pseudo-Classes you can help define important states for form elements that e ...

  8. IOS UIPickView+sqlite 选择中国全部城市案例

    1.案例简单介绍 通过读取文件.将中国全部城市写入sqlite数据库中,现通过UIPickView实现中国全部城市的选择,效果图例如以下所看到的 2.城市对象模型 中国全部城市数据请看http://b ...

  9. 微信小程序 开发环境配置

    1.注册小程序 (1)微信公众平台:https://mp.weixin.qq.com/(2)立即注册 (3)流程 (4)小程序注册 (5)填写相关信息,并去邮箱激活.这样小程序的账号就注册完成了. 2 ...

  10. Eclipse中Easy Shell插件配置PowerCmd

    1.了解EasyShell.PowerCMD和基本命令 http://sourceforge.net/projects/pluginbox/ http://www.powercmd.com/ 了解基本 ...