【六】Linux安装部署Nginx web服务器--及编写服务器启动脚本
创始人
2025-01-18 05:32:32
0

一、部署安装nginx

1、查看nginx是否安装依赖包

[root@localhost ~]#rpm  -q  zlib-devel  pcre-devel

package zlib-devel is not installed

package pcre-devel is not installed

2、若没有则安装nginx 依赖包  [root@localhost ~]# yum  -y  install  zlib-devel*  pcre-devel*

表示安装成功了

[root@localhost ~]# rpm  -q  zlib-devel*  pcre-devel*

zlib-devel-1.2.7-18.el7.x86_64

pcre-devel-8.32-17.el7.x86_64

3、添加启动用户 nginx 并禁止登陆

# useradd  -s  /sbin/nologin   nginx   -M   并不创建宿主目录。

# tail -1  /etc/passwd

nginx:x:1001:1001::/home/nginx:/sbin/nologin

4、源码编译安装nginx-------www.nginx.org  下载nginx-----------------rz上传到服务器

步骤: A, tar解压。    B,./configure配置      C, 编译生成makefile文件    D, make install 安装

A,  # tar   -zvxf   nginx-1.14.2.tar.gz   -C  /usr/src/

# cd  /usr/src/nginx-1.14.2/

B,  [root@nodel nginx]# ./configure  --user=nginx  --group=nginx  --prefix=/usr/local/nginx

如果报错,就安装c++  # yum -y install  gcc

参数:  --user  :指定用户        --group 指定组     --prefix  指定安装位置

C,编译生成makefile文件  [root@localhost nginx-1.14.2] # make     如果不行# yum  -y  install make

D, make install 安装      [root@localhost nginx-1.14.2]# make  install

nginx安装好了

5\启动nginx    

正常情况:#./nginx    若bash找不到。则在安装位置下启动

[root@localhost ]# /usr/local/ngnix/sbin/nginx

证明已经启动nginx

网站目录:/usr/share/nginx/html        配置文件目录:/usr/local/ngnix/conf/nginx.conf

二,编写服务器启动脚本

脚本名称:nginx.sh

脚本思路: (1)指导nginx主程序指令 start / stop / restart / check

                   (2)写完脚本放在 /etc/init.d/目录下

1、脚本,#chkconfig 35  86  12 是系统的启动级别----起作用

2、给脚本执行权限       [root@localhost ~]# chmod  +x  nginx.sh
3、脚本移动到启动目录下 [root@localhost ~]# mv  nginx.sh  /etc/init.d/
4、添加系统服务     [root@localhost init.d]# chkconfig  add  nginx.sh

执行结果

相关内容

热门资讯

透视肯定!pokermaste... 透视肯定!pokermaster脚本(透视)其实有挂,靠谱教程(有挂德州)-哔哩哔哩1、许多玩家不知...
一分钟解谜!hhpoker买挂... 您好,hhpoker买挂这款游戏可以开挂的,确实是有挂的,需要了解加去威信【136704302】很多...
透视辅助!wepoker有没有... 透视辅助!wepoker有没有挂(透视)真是真的是有挂,2025新版教程(有挂最新版)-哔哩哔哩1、...
第2分钟揭露!德州hhpoke... 第2分钟揭露!德州hhpoker脚本(透视)其实是真的挂,存在挂教程(证实有挂)-哔哩哔哩1、全新机...
透视免费!hhpoker底牌透... 透视免费!hhpoker底牌透视脚本(透视)总是是有挂,玩家教你(有挂俱乐部)-哔哩哔哩透视免费!h...
第二分钟必备!aa poker... 第二分钟必备!aa poker辅助(透视)确实存在有挂,力荐教程(有挂透视)-哔哩哔哩1、aa po...
透视讲解!哈糖大菠萝有挂吗5个... 透视讲解!哈糖大菠萝有挂吗5个常用方法(透视)竟然真的有挂,安装教程(有挂靠谱)-哔哩哔哩1、下载好...
十分钟透视!约局吧是否有挂(透... 十分钟透视!约局吧是否有挂(透视)总是是真的挂,安装教程(有挂工具)-哔哩哔哩亲,关键说明,约局吧是...
透视能赢!竞技联盟辅助(透视)... 您好,竞技联盟辅助这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家在...
8分钟解谜!哈糖大菠萝挂法(透... 您好,哈糖大菠萝挂法这款游戏可以开挂的,确实是有挂的,需要了解加去威信【485275054】很多玩家...