Nginx服务安装与启动脚本配置
来源:互联网 发布:微名片制作软件 编辑:程序博客网 时间:2024/05/24 06:33
实验环境:RHEL7.2 x64-176,IP地址:192.168.1.176
实验工具:
实验步骤:
1、安装nginx服务器
2、配置nginx启动脚本
3、文件设置并验证结果
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1、安装nginx服务器
[root@localhost~]# useradd nginx -s /sbin/nologin -M #创建 nginx用户
[root@localhost~]# id nginx #验证
uid=1001(nginx)gid=1001(nginx) 组=1001(nginx)
[root@localhost ~]# yum install pcre pcre-devel openssl openssl-devel -y #安装依赖相关包
[root@localhost ~]# tar xf nginx-1.9.14.tar.gz #解压nginx源码包到当前目录
[root@localhost ~]# cd nginx-1.9.14/ #进入解压后的nginx目录
[root@localhost nginx-1.9.14]# ./configure --user=nginx --group=nginx #配置nginx
[root@localhostnginx-1.9.14]#make && make install #编译安装nginx
[root@localhostnginx-1.9.14]# /usr/local/nginx/sbin/nginx -t #检查语法
[root@localhostnginx-1.9.14]# /usr/local/nginx/sbin/nginx #启动nginx
#访问虚拟机IP地址测试出现 nignx 成功
2、配置nginx启动脚本
[root@localhost~]# vim nginx
==============================================================
#! /bin/bash
# chkconfig:2345 99 20
#description:nginx-server
nginx=/usr/local/nginx/sbin/nginx
case $1 in
start)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx-server isalready running"
else
echo "nginx-server beginstart"
$nginx
fi
;;
stop)
$nginx -s stop
if [ $? -eq 0 ]
then
echo "nginx-server isstoped"
else
echo "nginx-server stopfail,try again"
fi
;;
status)
netstat -anlpt | grep nginx
if [ $? -eq 0 ]
then
echo "nginx-server isrunning"
else
echo "nginx-server isstoped"
fi
;;
restart)
$nginx -s reload &>/dev/null
if [ $? -eq 0 ]
then
echo "nginx-server isbegin restart"
else
echo "nginx-server restartfail"
fi
;;
*)
echo "please enter {startrestart status stop}"
;;
esac
exit 0
================================================================
3、文件设置并验证结果
[root@localhost~]# cp nginx /etc/init.d/ #将启动文件复制到/etc/init.d目录下
[root@localhost ~]# chmod +x /etc/init.d/nginx #设置可执行权限
[root@localhost ~]# chkconfig --add nginx #将nginx添加为系统的服务
[root@localhost ~]# chkconfig --list nginx #查看nginx的开机运行级别
本文出自 “xinsz08の平行时空” 博客,请务必保留此出处http://xinsz08.blog.51cto.com/10565212/1826562
- Nginx服务安装与启动脚本配置
- nginx 服务启动脚本
- nginx服务启动脚本
- Nginx安装配置与服务搭建
- Nginx安装配置与服务搭建
- Nginx安装配置与服务搭建
- Nginx安装配置与服务搭建
- nginx编译安装之后如何配置服务脚本
- nginx安装配置脚本
- SVN服务的安装与启动,配置
- 配置Nginx,完善Nginx启动脚本
- nginx启动与配置
- Nginx 启动、停止服务的脚本
- Nginx 启动、停止服务的脚本
- 【shell编程】 nginx 服务的启动脚本
- nginx 服务启动脚本 chkconfig service
- nginx安装与启动
- nginx安装与启动
- 电脑启动流程
- Linux基础命令之计划任务
- Linux常用而且好玩的命令
- nagios监控服务器的搭建
- mysql基本知识学习
- Nginx服务安装与启动脚本配置
- Linux基础命令介绍
- 如何批量修改200台以上web服务器密码
- Jquery之张一山、周冬雨图片缩放
- 北京金万维科技有限公司面试题
- 北京金万维科技有限公司面试题
- mysql 最基础的日常操作
- Mysql Cluster7.4.6安装与配置
- MySQL优化