【六】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

执行结果

相关内容

热门资讯

绝活儿辅助!广西老友玩老是输怎... 绝活儿辅助!广西老友玩老是输怎么办(辅助挂)都是真的有辅助app(讲解有挂)在进入广西老友玩老是输怎...
法门辅助!福建13水插件(辅助... 法门辅助!福建13水插件(辅助挂)一贯是有辅助技巧(有挂技术)1、许多玩家不知道福建13水插件辅助怎...
办法辅助!潮友会app下载官方... 办法辅助!潮友会app下载官方辅助器(辅助挂)真是真的是有辅助app(有挂教程)该软件可以轻松地帮助...
妙招辅助!邯郸胡乐挂辅助(辅助... 妙招辅助!邯郸胡乐挂辅助(辅助挂)好像存在有辅助插件(有挂方略)1、上手简单,内置详细流程视频教学,...
教程书辅助!乐酷辅助(辅助挂)... 教程书辅助!乐酷辅助(辅助挂)其实存在有辅助脚本(有挂细节)乐酷辅助能透视中分为三种模型:乐酷辅助模...
学习辅助!决战卡五星辅助(辅助... 学习辅助!决战卡五星辅助(辅助挂)本来真的是有辅助软件(有人有挂)学习辅助!决战卡五星辅助(辅助挂)...
绝活辅助!边锋嘉兴麻将辅助器(... 绝活辅助!边锋嘉兴麻将辅助器(辅助挂)真是真的有辅助神器(新版有挂)1、边锋嘉兴麻将辅助器公共底牌简...
举措辅助!枫叶辅助器(辅助挂)... 举措辅助!枫叶辅助器(辅助挂)本来存在有辅助技巧(竟然有挂)1、下载好枫叶辅助器正确养号方法之后点击...
讲义辅助!点我达辅助(辅助挂)... 讲义辅助!点我达辅助(辅助挂)一直存在有辅助技巧(有人有挂)1、点我达辅助辅助器安装包、点我达辅助辅...
模块辅助!威信茶馆有挂的吗(辅... 模块辅助!威信茶馆有挂的吗(辅助挂)一直真的是有辅助脚本(揭秘有挂)1、玩家可以在威信茶馆有挂的吗线...