【前端】CentOS 7 系列教程之五: 安装最新版 nginx 并转发 node 服务
转载请注明出处: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 服务的更多相关文章
- RabbitMQ系列教程之五:主题(Topic)(转载)
RabbitMQ系列教程之五:主题(Topic) (本实例都是使用的Net的客户端,使用C#编写),说明,中文方括号[]表示名词. 在上一个教程中,我们改进了我们的日志记录系统. 没有使用只能够进行虚 ...
- 实战SpringCloud响应式微服务系列教程(第八章)构建响应式RESTful服务
本文为实战SpringCloud响应式微服务系列教程第八章,讲解构建响应式RESTful服务.建议没有之前基础的童鞋,先看之前的章节,章节目录放在文末. 1.使用springboot2.1.4构建RE ...
- 【前端】CentOS 7 系列教程之一: 安装 node 最新版
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_1.html 此系列教程从零开始,安装node.mysql.git,nginx.并且设置git自动部署. ...
- 【前端】CentOS 7 系列教程之六: 安装 mysql 5.7
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_6.html 进入/usr/local/src目录 cd /usr/local/src 下载mysql的 ...
- 【前端】CentOS 7 系列教程之四: 配置 git 服务器自动部署
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_4.html 安装pm2守护进程,备用 npm install -g pm2 创建/srv/www文件夹 ...
- 【前端】CentOS 7 系列教程之三: 搭建 git 服务器
转载请注明出处:http://www.cnblogs.com/shamoyuu/p/linux_3.html 上一篇我们安装好了git,这一篇我们搭建git服务器 创建一个用户组 groupadd g ...
- Docker系列教程01-Centos7安装新版Docker教程(10步)
最近一直忙于开发,没有时间好好总结一下docker的知识.其实现在docker的教程已经很多很多了,但是很多系统的教程都是基于Ubuntu系统,因为官方推荐使用Ubuntu系统啊,原因在于Ubuntu ...
- 树莓派系列教程:安装系统与配置环境,使用PuTTy与VNC图形界面远程登录
本文所需物品清单: Raspberry Pi 3 Model B 主板.SD卡与读卡器(用于烧录系统) 资料整理来源在文尾 需要下载的资源与工具: 推荐系统-Raspbian 树莓派官方深度定制的硬件 ...
- Yii2系列教程:安装及Hello World
http://www.yiiframework.com/ 安装Yii2 打算从头开始,所以,连安装Yii2也稍微写一点吧.安装Yii2最好的方式就是使用composer: composer globa ...
随机推荐
- PAT (Advanced Level) 1086. Tree Traversals Again (25)
入栈顺序为先序遍历,出栈顺序为中序遍历. #include<cstdio> #include<cstring> #include<cmath> #include&l ...
- HBASE的安装过程及运行HBASE程序的需要配置的内容
HBase安装配置 ①下载压缩包(选择与自己安装的Hadoop版本的兼容版本,见后面附录) 官网下载地址:https://mirrors.tuna.tsinghua.edu.cn/apache/hba ...
- iOS--基于键值的观察者模式(KVO)
VO简而言之就是:基于键值的观察者,实际上就是观察者模式. Cocoa Framework已经为我们提供了这一模式,不需要我们自己来实现了.我们只需要按照约定的方式去做就可以了.KVO主要用于用户界面 ...
- Android 学习笔记---获取RadioGroup的选定值
1,获取RadioGroup控件: RadioGroup radioGroup = (RadioGroup)findViewById(R.id.myRadioGroup); 2,获取RadioButt ...
- mac mysql重置密码
http://blog.csdn.net/xiaozhuanddapang/article/details/53185775 情况一:在mysql官网直接下载dmg文件进行安装,忘记密码 1.关闭my ...
- Python机器学习--降维
主成分分析(PCA) 测试 # -*- coding: utf-8 -*- """ Created on Thu Aug 31 14:21:51 2017 @author ...
- Android开发之入口Activity
Android开发之入口Activity Adnroid App是怎样确定入口Activity的? 难道就由于class的类名叫MainActivity,布局文件叫activity_main.xml? ...
- mac上的xampp出现Access forbidden! You don’t have permission to access the requested object. It is either
一个Joomla!程序,之前是在win上的xampp上运行得非常好的,当我把它拿到mac下面的xampp上去运行的时候,发现有问题,没法运行,报以下的错误: Access forbidden! Yo ...
- C#模拟登录Facebook 实现发送消息、评论帖子
由于目前电脑网页版FB实现模拟登录比较困难,本次选择了FB的手机版页面进行登录 MVC: private static string UserName = "用户名"; priva ...
- SQLDMO注冊
在维护人事系统时.师姐给我们提出一个功能上有问题. 备份数据库时.报黄页.然后须要我们寻找原因,作出解决方式. 一開始我从原先在本机上公布的系统入手,发现没有出现故障.可是.当对程序进行调试时,就出现 ...