转载请注明出处: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. BZOJ 1090 字符串折叠(Hash + DP)

    题目链接 字符串折叠 区间DP.$f[l][r]$为字符串在区间l到r的最小值 正常情况下 $f[l][r] = min(f[l][r], f[l][l+k-1]+f[l+k][r]);$ 当$l$到 ...

  2. [bzoj1018][SHOI2008]堵塞的交通traffic_线段树

    bzoj-1018 SHOI-2008 堵塞的交通traffic 参考博客:https://www.cnblogs.com/MashiroSky/p/5973686.html 题目大意:有一天,由于某 ...

  3. codeforces edu40

    H(dp计数) 题意: 有一颗树,最深的点的深度是n,每个深度为i的点都有ai个孩子. 对于1<=k<=2n-2,回答树上有多少点对之间的距离是k,答案对1e9+7取模 n<=500 ...

  4. gorm 结构体 预加载

    结构体构建 type PlansApproval struct {     ID uint     Plans_Id int //plans编号     UpdateUser int //更新者    ...

  5. uwsgi 热启动

    uwsgi文件每次启动都要kill进程,这样非常麻烦,理想的情况是须要改动文件就自己主动生效,经查阅资料.发现uwsgi是自带该功能的,该功能的配置节例如以下 <uwsgi> <py ...

  6. 【Java编程】建立一个简单的JDBC连接-Drivers, Connection, Statement and PreparedStatement

    本blog提供了一个简单的通过JDBC驱动建立JDBC连接例程.并分别通过Statement和PreparedStatement实现对数据库的查询. 在下一篇blog中将重点比較Statement与P ...

  7. JSP简明教程:汇总

    原创JSP教程,简洁明了,不含废话. JSP简明教程(一):JSP简单介绍 JSP简明教程(二):JSP基本的语法 JSP简明教程(三):JSP隐含对象 JSP简明教程(四):EL表达式语言.Java ...

  8. C#3.0之神奇的Lambda表达式和Lambda语句

    “Lambda 表达式”是一个匿名函数,它可以包含表达式和语句,并且可用于创建委托或表达式目录树类型.所有 Lambda 表达式都使用 Lambda 运算符 =>,该运算符读为“goes to” ...

  9. poj2595(凸包)

    Min-Max Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2192   Accepted: 502 Descriptio ...

  10. 李洪强iOS开发之-实现点击单行View显示和隐藏Cell

    李洪强iOS开发之-实现点击单行View显示和隐藏Cell 实现的效果:  .... ....