获取Nginx软件包 ==>(文章末尾有脚本一键安装,含获取软件包)
官网网站:http://www.nginx.org/社区版或http://www.nginx.com/企业版
源码编译安装Nginx软件
回顾源码编译三步走:
① ./configure配置
② make编译
③ make install安装
第一步:上传Nginx软件包到Linux服务器端
第二步:联网,安装Nginx软件所需的依赖库
# yum install pcre-devel zlib-devel openssl-devel -y
第三步:对Nginx软件包进行解压缩操作
# tar -xf nginx-1.18.0.tar.gz
第四步:创建一个www账号
# useradd -r -s /sbin/nologin www
第五步:使用./configure对Nginx软件进行配置(对软件安装包进行配置)
# cd nginx-1.18.0
# ./configure --prefix=/usr/local/nginx --user=www --group=www --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module
编译参数说明
参数 作用
–prefix 编译安装到的软件目录
–user worker进程运行用户
–group worker进程运行用户组
–with-http_ssl_module 支持https 需要pcel-devel依赖第六步:编译与安装Nginx软件
# make && make instal
Nginx目录介绍
目录 作用
conf 配置文件(nginx.conf)
html 网站默认目录(类似apache的htdocs目录)
logs 日志(access.log、error.log)
sbin 可执行文件 [软件的启动 停止 重启等]原生启动方式:
# sbin/nginx -c /usr/local/nginx/conf/nginx.conf
原生关闭方式:
# sbin/nginx -s stop
原生重启方式:需要停止Nginx服务,相当于先关闭后打开
# sbin/nginx -s stop
# sbin/nginx -c /usr/local/nginx/conf/nginx.conf
原生的热重载(不停止Nginx服务,重载nginx.conf配置文件)
# sbin/nginx -s reload
☆ Nginx服务配置
CentOS7.6 配置:
使用前提,必须先把Nginx停止掉!!!!!!!!
# sbin/nginx -s stop
编写nginx.service脚本,有了这个脚本,我们就可以使用systemctl对其进行控制了
# vim /usr/lib/systemd/system/nginx.service
[Unit]
Description=Nginx Web Server
After=network.target[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true[Install]
WantedBy=multi-user.target
启动Nginx:
# systemctl start nginx
停止Nginx:
# systemctl stop nginx
重载Nginx:
# systemctl reload nginx
开启启动与开机不启动:
# systemctl enable nginx
# systemctl disable nginx
shell脚本安装Nginx#!/bin/bash
wget http://nginx.org/download/nginx-1.18.0.tar.gz &>/dev/null
sleep 1
tar -xf nginx-1.18.0.tar.gz &>/dev/null
sleep 1
yum -y install gcc
yum -y install gcc-c++
yum -y install make
yum -y install pcre-devel
yum -y install zlib-devel
yum -y install openssl-devel
sleep 1
cd nginx-1.18.0
./configure --prefix=/usr/local/nginx
sleep 1
make && make install
sleep 1
cd /usr/local/nginx
sbin/nginx
ps -ef | grep nginx#shell脚本就是命令的堆砌
原创:https://www.panoramacn.com
源码网提供WordPress源码,帝国CMS源码discuz源码,微信小程序,小说源码,杰奇源码,thinkphp源码,ecshop模板源码,微擎模板源码,dede源码,织梦源码等。专业搭建小说网站,小说程序,杰奇系列,微信小说系列,app系列小说
免责声明,若由于商用引起版权纠纷,一切责任均由使用者承担。
您必须遵守我们的协议,如果您下载了该资源行为将被视为对《免责声明》全部内容的认可-> 联系客服 投诉资源www.panoramacn.com资源全部来自互联网收集,仅供用于学习和交流,请勿用于商业用途。如有侵权、不妥之处,请联系站长并出示版权证明以便删除。 敬请谅解! 侵权删帖/违法举报/投稿等事物联系邮箱:2640602276@qq.com未经允许不得转载:书荒源码源码网每日更新网站源码模板! » Nginx源码编译安装
关注我们小说电影免费看关注我们,获取更多的全网素材资源,有趣有料!120000+人已关注
评论抢沙发