源码安装nginx 方法二

yum 仓库不能用大写字母,和某些特殊符号

[root@oldboy conf.d]# gzip * 压缩当前目录下的所有文件

gzip ./* gzip . gzip./

# 关闭防火墙和selinux
[root@qls yum.repos.d]# systemctl stop firewalld  (stop,start,disable,enable)
[root@qls yum.repos.d]# setenforce 0 ---------重启虚拟机域

## 搭建yum仓库的三种方式  ----------------------------ftp://IP
# 方案一:vsftpd服务实现yum仓库 (ftp://)

客户机---yumURL---浏览器---仓库机站点目录(yum仓库)

# 1.安装vsftpd
[root@qls yum.repos.d]# yum install -y vsftpd
# 2.启动服务
[root@qls yum.repos.d]# systemctl start vsftpd
# 3.检查端口
[root@qls yum.repos.d]# netstat -lntup|grep 21
tcp6       0      0 :::21                   :::*                    LISTEN      8433/vsftpd 
# 4.安装创建yum仓库的命令
[root@qls pub]# yum install -y createrepo
# 5.制作成yum仓库
[root@qls pub]# createrepo /var/ftp/pub/base/


# 6.在客户机上配置yum仓库
[root@qls yum.repos.d]# vi zls_vsftpd.repo 
[zls_vsftpd]
name='This is zls's vsftpd repository'
baseurl=ftp://10.0.0.150/pub/base/
gpgcheck=0
enabled=1

# 方案二:本地,挂载光盘镜像 (file://)-----------------file://路径

yumURL---浏览器---本地yum仓库

# 1.将光盘插入光驱
# 2.挂载光驱
[root@qls pub]# mount /dev/cdrom /mnt
mount: /dev/sr0 is write-protected, mounting read-only
# 3.创建yum仓库
[root@qls pub]# createrepo /var/ftp/pub/zabbix/
# 4.配置yum源
[root@qls yum_repo]# vi /etc/yum.repos.d/zls_local.repo
[zls_local]
name=123
baseurl=file:///opt/yum_repo/   ---------------
gpgcheck=0
enabled=1

# 方案三:nginx服务搭建yum仓库     --- http://IP或域名 :端口

仓库机配置文件---yum仓库---客户机手写源--yum下载

# 1.安装nginx
[root@qls conf.d]# yum install -y nginx
# 2.删除nginx的conf.d下默认配置文件
[root@qls conf.d]# rm -fr /etc/nginx/conf.d/*

# 3.配置nginx配置文件--------写入配置文件(注释默认界面),就不会再是默认界面
[root@qls conf.d]# vim /etc/nginx/conf.d/yum.conf
server {
        listen 80;
        server_name www.drz.com;   #域名
        root /kpw_dsb;
        autoindex on;
}

www.drz.com 改成这个域名之后,浏览器刷新,IP 的什么没了(页面没了),(# 2个域名解析)

# 4.创建站点目录
[root@qls conf.d]# mkdir /kpw_dsb
# 5.启动nginx服务
[root@qls kpw_dsb]# systemctl start nginx
# 6.配置域名解析
按 windows + r 打开运行,输入 'drivers'   #直接生效
----drivers--etc--hosts
--C--windows--system32--drivers--etc--hosts

[root@oldboy ~]# vim /etc/hosts

127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

# 修改本机的hosts文件
在文件中加入 :10.0.0.10 www.syy.com 

# 在虚拟机的hosts文件:用于解析
在文件中加入:10.0.0.10 www.syy.com 

## 注意:输入http://www.syy.com -----(http)

------------------小心客户机的/etc/hosts 和wndows hosts也要修改

# 7.创建yum仓库
[root@qls nginx]# createrepo /kpw_dsb

---------------------------------------------客户机

# 8.手写repo文件
[root@qls yum.repos.d]# vi zls_nginx.repo
[zls_nginx]
name=456
baseurl=http://www.drz.com/
gpgcheck=0
enabled=1
# 9.在客户机配置域名解析
[root@qls yum.repos.d]# vi /etc/hosts
10.0.0.150 www.drz.com

## 自制RPM包 ----空目录下做依赖!!!

echo $?   0表示上一个命令执行成功,否则失败 

TAB 一下可以查看命令有没有装

warning警告不用管

源码安装nginx的优点:

.conf(配置文件),lib(库文件),log(日志文件).sbin(命令文件)可以在一个目录下。html(源码nginx的站点目录,页面)

修改配置文件最好要重启一下

yum reinstall  只能恢复配置文件

/usr/share/nginx/html/index.html   nginx 的源代码===nginx右键查看源代码

nginx默认页面可以随意修改,与/etc/nginx/nginx.conf   /etc/nginx/conf.d/yum.conf  配置文件有关

LOL是源码安装

nginx 有很多功能模块可以安装

echo $?  只能检查上一条命令是否出错,,不是0 就报错,,不能检测别的命令了,,

error 是报错

源码nginx这一块小心依赖环境,有些依赖下载过后再remove,再下载,这样该虚拟机的依赖环境和新的虚拟机的依赖环境**不一样**(remove的这个包不会再从新下载,缓存目录里并不存在 ) ,8说了,,**一定要在新的虚拟机搞依赖**,全新的环境里,缓存目录里不会少下载包

既然用打包的时候用-d 指定了依赖,那么yum下载的时候就会去找这些依赖,镜像站没有的话就报错,(这样好像不会影响使用)

find /var/cache/yum/* -name '*rpm'  快速找包

find /var/cache/yum/* -name '*rpm' |xargs rm -rf  快速删除包

缓存目录下,打开或关闭缓存会清空缓存目录

记得学会看日志

端口---,通道,一次只能允许一个**服务**使用,nginx默认使用的是80端口,vsftpd 默认使用的是21号端口,当然默认是可以修改的,http://IP/路径:80  ,浏览器中,80端口默认隐藏,如果http修改使用别的端口,那么使用浏览器访问的时候就要加上:80

我们用使用浏览器访问的页面(http://协议),使用的都是80端口,只是:80 ,省略了

http ://IP或域名 -------80端口 (省略)(如果不是80,那就要再后面加上:80)

https://  ----------------------443端口 (省略)(主页)

linux 没有默认90端口,可以修改为90端口

# 打rpm包的虚拟机,先安装,c语音环境,和源码nginx依赖,ruby语法

[root@qls ~]# vim /etc/yum.conf
keepcache=1     #//缓存软件包, 1启动 0 关闭   安装或者不安装,find除了挂载点都找不到第二个位置的yum下载的包,缓存关闭的话--改过之后立即生效

# 0.安装依赖----------安装依赖之前,在yum主配置文件/etc/yum.conf 中打开缓存,得到依赖,不打开安装后就找不到了
[root@qls nginx-1.16.1]# yum install -y gcc gcc-c++ glibc zlib-devel pcre-devel openssl-devel
zlib-devel,gcc,gcc-c++,glibc,pcre-devel,openssl-devel  是基础包,为系统创建一个c语言的环境,(缺少依赖第三步生成会报错)(编译的时候才会用到C语言的环境,下载运行的话不需要C语言,编译的时候需要用到C语言,gem的时候也需要用到C语言)-----rm 掉C语言

[root@qls nginx-1.16.1]# yum -y install ruby rubygems ruby-devel rpm-build   openssl-devel   安装语法

# sz依赖到桌面或者scp到仓库机,仓库机下载vsftpd,createrepo


报错:
1. 空格(包名之间的空格)
2. ckage : openssl-devel  不在空目录下打包,就会有这种问题(有些没有打包)
3. 少包(幻觉?)可以在新虚拟机下载指定包,再rz
4.看日志理解报错

注意:
1.有些依赖包卸载不干净,本身有不能用,所有要在一个全新的虚拟机下载依赖(一定要在空目录),然后打包 .tar.gz
2.如果nginx浏览器页面404,那么一定是配置文件的问题(/etc/nginx/nginx.conf 多少)
3.仓库机仓库更新,createrepo ,客户机仓库更新,yum clean all ,yum makecache
4.阿里云nginx的问题,
5.依赖打包的时机?

端口:
www.baidu.com :443 =https:// (主页)
www.baidu.com :80 =http://www.baidu.com
www.baidu.com :90  不存在就报错
端口是可以修改的,在主配置文件里面.网站走的都是80端口(默认加上的)

---------------------------- 注意在空目录下打包依赖

## 只能scp文件,不能scp目录

```bash
同一区域网的IP不同的虚拟机,使用超级复制scp,这样文件之间的的cp不需要经过windows,直接cp到同一个区域网下的不同IP的不同用户的Linux系统,第一次cp需要输入,yes,scp对象的用户密码,第二次直接输入密码
只能scp文件,不能scp目录

-r: 递归复制整个目录
-B: 使用批处理模式(传输过程中不询问传输口令或短语)
-p:保留原文件的修改时间,访问时间和访问权限


当前一个文件copy到远程另外一台主机上:
scp  /home/daisy/full.tar.gz root@172.19.2.75:/home/root  # 可以用相对路径
[root@oldboy ~]# mkdir -p kk/ll/mm
[root@oldboy ~]# scp -Bp kk root@10.0.0.7:/root

把文件从远程主机copy到当前系统:
scp root@/full.tar.gz 172.19.2.75:/home/root/full.tar.gz home/daisy/full.tar.gz
# 1.下载nginx源码包
[root@qls ~]# wget http://nginx.org/download/nginx-1.16.1.tar.gz  (直接在Linux下载速度太慢的话,可以windows下载再rz )


# 2.解压
[root@qls ~]# tar xf nginx-1.16.1.tar.gz   解压后就一个目录(zcf,xf.tf.-C,-X,--exclude==  ,)  
[root@qls ~]# cd nginx-1.16.1
[root@oldboy nginx-1.16.1]# ll
total 748
drwxr-xr-x 6 1001 1001    326 Apr 19 13:53 auto
-rw-r--r-- 1 1001 1001 296463 Aug 13  2019 CHANGES
-rw-r--r-- 1 1001 1001 452171 Aug 13  2019 CHANGES.ru
drwxr-xr-x 2 1001 1001    168 Apr 19 13:53 conf
-rwxr-xr-x 1 1001 1001   2502 Aug 13  2019 configure   #可执行文件

# 3.生成
[root@qls ~]# mkdir /app
[root@qls ~]# cd nginx-1.16.1
[root@qls nginx-1.16.1]# useradd nginx -s /sbin/nologin -M (源码启动nginx的时候nginx系统用户会自动登陆)(nginx启动前创建出来就好)

[root@qls nginx-1.16.1]# ./configure --prefix=/app/nginx-1.16.1 --user=nginx --group=nginx   (这一步依赖C语言)(这一步出错的话,把nginx-1.16.1目录删除,重新解压(第二步)官方nginx安装包)(当指定了配置文件,生成以后,就不能mv nginx-1.16.1还有下面的文件了,因为系统已经记录了这些文件的位置),要更换安装路径的话,就修改命令行路径,重新执行这条命令,重新 编译安装
怕装错位置,就用绝对路径表示
./configure (执行该文件)(安装)
--prefix=  (把该软件装在哪)(不存在就改名)

[root@qls nginx-1.16.1]# ll
-rwxr-xr-x 1 1001 1001   2502 Aug 13  2019 configure
drwxr-xr-x 4 1001 1001     72 Apr 19 14:55 contrib
drwxr-xr-x 2 1001 1001     40 Apr 19 14:55 html
-rw-r--r-- 1 1001 1001   1397 Aug 13  2019 LICENSE
-rw-r--r-- 1 root root    380 Apr 19 14:56 Makefile  #(多出来一个文件,(安装) 指定位置的文件)

[root@qls nginx-1.16.1]# echo $?        下/app下,生成nginx-1.16.1

# 4.编译
[root@qls nginx-1.16.1]# make    (就是执行Makefile,编译C语言的环境,还没有安装) ---一定要和 makefile在一起
[root@qls nginx-1.16.1]# echo $?

[root@oldboy nginx-1.16.1]# ll /app/
total 0

# 5.安装  ---真正的安装nginx
[root@qls nginx-1.16.1]# make install   (make && make install)
[root@qls nginx-1.16.1]# echo $?
[root@oldboy nginx-1.16.1]# ll /app/
total 0
drwxr-xr-x 6 root root 54 Apr 19 15:08 nginx-1.16.1  安装成功
[root@oldboy nginx-1.16.1]# ll /app/nginx-1.16.1/
total 0
drwxr-xr-x 2 root root 333 Apr 19 15:08 conf   nginx.conf 
drwxr-xr-x 2 root root  40 Apr 19 15:08 html   站点目录
drwxr-xr-x 2 root root   6 Apr 19 15:08 logs   日志目录
drwxr-xr-x 2 root root  19 Apr 19 15:08 sbin   库文件,存放启动程序
(_temp跟nginx客户访问有关)

------------------------------------------------源码安装nginx成功

# 6.检测 配置文件 有没有语法错误 (所有配置文件)
[root@fmp_nginx nginx-1.16.1]# cd /app/nginx-1.16.1/sbin/
[root@oldboy sbin]# ll
total 3736
-rwxr-xr-x 1 root root 3825088 Apr 19 21:35 nginx # 控制服务的启动
##这个nginx相当于源码nginx的启动脚本

[root@qls sbin]# /app/nginx-1.16.1/sbin/nginx -t          (作用有限)
nginx: the configuration file /app/nginx-1.16.1/conf/nginx.conf syntax is ok
nginx: configuration file /app/nginx-1.16.1/conf/nginx.conf test is successful  (# 检查了配置文件,检测了配置文件)


# 7.启动nginx---源码nginx没有启动脚本,不能用systemctl启动---一定要把阿里云的nginx关掉,因为阿里云nginx会占用80端口,
[root@qls sbin]# /app/nginx-1.16.1/sbin/nginx   开启,注意不能同时启动2个nginx
最好以绝对路径启动没有启动脚本的服务或命令(小心./)
[root@qls sbin]# /app/nginx/sbin/nginx -s stop  关闭源码安装nginx

[root@qls sbin]# nginx
[root@qls sbin]# nginx -t
[root@qls sbin]# nginx -s stop  关闭阿里云nginx
[root@qls sbin]# systemctl stop nginx   关闭 (start disable enable)

源码nginx开启,就可以通过浏览器 输入本机IP,访问nginx(默认页面---正经的)
这一部浏览器F12的Network--Disable 要关掉 ,再刷新

# 8.检测80端口 (检查源码安装nginx是否启动)(已知的唯一方法)
[root@oldboy sbin]# yum provides */netstat  (直接搜找不到)
[root@oldboy sbin]# yum install -y net-tools (netstat 和 ifconfig 属于 一个包)
[root@qls sbin]# netstat -lntup|grep 80
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      13468/nginx: master

# 9.做软连接
源码安装,相关目录或文件都在一个目录下
解决nginx的指向问题,光速升级
[root@qls nginx-1.16.1]# ln -s /app/nginx-1.16.1 /app/nginx

## 自定义
# 修改默认页面 ----改过之后立即生效--做好之后记得做软连接
html 里的 "UTF-8"/  不然中文乱码,在自己的网站里可以做动态页面
作用是,网站输入ip或域名访问yum仓库的时候页面问题
如果真的有域名的话,别人也可以访问这个网站

[root@qls html]# vim /app/nginx-1.16.1/html/index.html  源码安装nginx配置文件
在配置文件里只要加一个错误的字母,/app/nginx-1.16.1/sbin/nginx -t(启动脚本 -t)
就会报错,(小心配置文件里的{} )

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>                  # 会导致中文乱码
<title>欢迎来到曾老湿的nginx页面</title>    # 大字,,自己的网址,开始显示
<style>
    body {
         35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>欢迎来到曾老湿nginx的web页面</h1>      # 结束显示,,有的p标签可以删除
<a href="http://www.driverzeng.com">我的博客地址</a>.<br/>   #小字,网站跳转
<p><em>Thank you for using nginx.</em></p>
</body>
</html>

配置文件改过之后,立即生效。不需要重启服务,,页面网站还不能跳转(那是你操作错了,可以跳转的),现在这个网站只能跳到别的网站,别人看不到我的,当真正有了域名之后,别人就可以访问了
http:// 不加这个协议,会导致404 错误


修改nginx默认页面
wget http://test.driverzeng.com/Nginx_Code/h5_games.zip
unzip h5_games.zip
mv /root/h5_games/* /app/nginx-1.16.1/html/


---------------------------------------------------#自定义nginx默认页面



## 制作rpm包
fpm这个包 不在阿里云centos里面的base,epel源,在阿里云的rubygems里面,想通过yum下载,必须要添加源
download.driverzeng.com  (其他-选项里有fpm包),linux里wget下载别人网站里的内容,要用到别人的流量,rz上传,sz下载
wget 下载rpm或者压缩包或者图片,如果不-o,就下载到当前位置,当然也可以windows下载
#两种方式下载


[root@oldboy html]# yum install -y fpm
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirrors.aliyun.com     #找base源
 * extras: mirrors.aliyun.com  
 * updates: mirrors.aliyun.com   #找updates源
No package fpm available.


[root@qls ~]# mkdir fpm         因为fpm这个包解压后有好几个文件
[root@qls ~]# mv fpm-1.3.3.x86_64.tar.gz fpm
[root@qls fpm]# cd /root/fpm/

# 1. 解压
[root@qls fpm]# tar xf fpm-1.3.3.x86_64.tar.gz  (这个包里面有好几个文件,fpm工具,解压之后好几个.gem包(文件),使用.gem结尾的文件要用到一个(gem用)ruby语法)
[root@oldboy ~]# which gem  gem安装.gem文件
/usr/bin/gem

[root@qls ~]# vim /etc/yum.conf
keepcache=1     #//缓存软件包, 1启动 0 关闭   安装或者不安装,find除了挂载点都找不到第二个位置的yum下载的包,缓存关闭的话  ------对于nginx来说,一定要把这个缓存打开

cachedir=/var/cache/yum/
[root@qls ~]# find /var/cache/yum/ -name '*.rpm'
[root@qls ~]# find /var/cache/yum/ -name '*.rpm'|xargs rm -rf  先清空。清场,
[root@qls ~]# find /var/cache/yum/ -name '*.rpm'|xargs cp -t /user/local/src

# 2.安装ruby (gem用)ruby语法  ,小心空格
[root@qls fpm]# yum -y install ruby rubygems ruby-devel rpm-build   openssl-devel
[root@oldboy fpm]# echo $?
0

nginx的安装也需要这些包,所以要先保存这些依赖
用ruby语法要用yum安装ruby rubygems ruby-devel 软件包,这样就可以使用gem命令了
openssl-devel 可能依赖这个包

--------------------------------

# 3.查看 gem的源
[root@qls fpm]# gem sources --list  gem这个命令的源,默认rubygems官网,为gem提供服务,因为使用这个命令要访问国外的https://rubygems.org/官网,所以同样要换源
*** CURRENT SOURCES ***

https://rubygems.org/   # 源

# 4.更换为阿里云的源 先移除国外源
[root@qls fpm]# gem sources --remove https://rubygems.org/
https://rubygems.org/ removed from sources

# 5.更换为阿里云的源, 添加阿里云的源
[root@qls fpm]# gem sources -a https://mirrors.aliyun.com/rubygems/
https://mirrors.aliyun.com/rubygems/ added to sources

[root@qls fpm]# gem sources --list    检查源,这样就可以使用gem命令了
*** CURRENT SOURCES ***

https://mirrors.aliyun.com/rubygems/

# 6.使用   gem命令安装当前目录下所有的.gem文件-----这样就可以使用fpm-包了(有了fpm命令,这一步依赖C语音)
[root@qls fpm]# gem install *.gem  
[root@oldboy fpm]# echo $?
0

# 7.写出安装fpm之后要执行的脚本 - 不能87 ,这个脚本是客户安装的时候执行的,(肯定被打包在nginx-1.16.1.rpm 这个包里)
[root@qls ~]# vim /root/nginx.sh
#!/bin/bash
useradd nginx -s /sbin/nologin -M
ln -s /app/nginx-1.16.1 /app/nginx

启动脚本 (为了方便用户,修改默认页面也是,可以在这里写入脚本,用来systemctl启动源码nginx)
--------------#或者用这个脚本
#!/bin/bash

id nginx &>/dev/null                 # echo $? 结果转化为数字
if [ $? -ne 0 ];then
	useradd nginx -s /sbin/nologin -M
	echo nginx用户不存在,正在创建...   #输出在当前bash,当前路径
else
	echo nginx用户已存在 			#也可以不写
fi

ln -s /app/nginx-1.16.1 /app/nginx    #

cat > /usr/lib/systemd/system/nginx.service <<eof
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target

[Service]
Type=forking
PIDFile=/app/nginx/logs/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /app/nginx/logs/nginx.pid
ExecStartPre=/app/nginx/sbin/nginx -t
ExecStart=/app/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true

[Install]
WantedBy=multi-user.target

eof

echo 'export PATH="/app/nginx-1.16.1/sbin:$PATH"' >> /etc/profile #环境变量

-------# 注意当前安装的源码机并没有执行该脚本

vim /servers/scripts/nginx_rpm.sh

eq 等于 ,ne 不等于,ls 小于 ,gt 大于 ,le 小于等于 ,ge大于等于

-----------------

# 8.使用fpm打包  (注意空格)
[root@qls fpm]# fpm -s dir -t rpm -n nginx -v 1.16.1 -d 'zlib-devel,pcre-devel,openssl-devel' --post-install /root/nginx.sh -f /app/nginx-1.16.1/                                  执行脚本
-d 可以不指定C语言(gcc,gcc-c++,glibc)

no value for epoch is set, defaulting to nil {:level=>:warn} #黄  warn
no value for epoch is set, defaulting to nil {:level=>:warn} #黄
Created package {:path=>"nginx-1.16.1-1.x86_64.rpm"} (当前目录)

少一个依赖就会有红色报错
在那个目录下,打的包就在哪,黄黄红--黄黄执行成功--红(少工具),这里-d指定了依赖,在网站安装nginx的时候也会用到这些依赖,所以要把这些依赖和打成的包在网站上放到一起
[root@oldboy ~]#  ll
total 2448
-rw-------. 1 root root    1431 Apr 18 22:13 anaconda-ks.cfg
drwxr-xr-x  2 root root     227 Apr 19 16:30 fpm
drwxr-xr-x  9 1001 1001     186 Apr 19 14:55 nginx-1.16.1
-rw-r--r--  1 root root 1460463 Apr 19 17:06 nginx-1.16.1-1.x86_64.rpm #
-rw-r--r--  1 root root 1032630 Apr 16 12:09 nginx-1.16.1.tar.gz
-rw-r--r--  1 root root      70 Apr 19 17:05 nginx.sh

# 安装源码nginx的条件
一个linux系统安装好要做优化,防火墙,selinux,安装基础包(zlib-devel,gcc,gcc-c++,glibc,pcre-devel,openssl-devel)记得开启缓存,

大长串是依赖
gcc,gcc-c++,glibc
-d 'zlib-devel,gcc,gcc-c++,glibc,pcre-devel,openssl-devel'

fpm:打rpm包命令---不指定的话就放在家目录下

-s:dir     # 打目录 (目录写目录文件写文件)
-t:rpm     # 把目录打成 rpm包
-n:nginx   # 软件名字叫nginx (打包谁)
-v:1.16.1  # 软件的版本号
-d:        # 指定nginx的 依赖 包,不用下载依赖包,-d指定就可以,(,隔开)
如果系统做好了优化,已经有了C语言的环境,那么 -d 可以省略,,-d 指定的是安装的时候需要下载的依赖,也可以不指定,但是下载之后服务不完整,

-f:        # 指定要达成rpm包的目录路径   (原料在哪)

--post-install # 指定rpm包安装完成(客户机)之后要执行的脚本  ##查看有没有恶意脚本
--pre-install  # 指定rpm包安装之前,要执行的脚本

rpm -q --scripts  xx  查看执行前后的脚本 (xx在前后都可以)


-----------------------------------------------# 从官方下载源码nginx ,自己修改了nginx的默认界面,打成了 rpm 包(那么,这个包就是经过自己修改过之后的包)

[root@oldboy ~]# netstat -lntup   查看vsftpd是否启动 (没启动就开启)
[root@oldboy ~]# rm /var/ftp/yum/*  (下载依赖前---干净的目录下)

[root@oldboy ~]# mkdir /var/ftp/nginx
[root@oldboy ~]# mv ngin-1.16.1-1.x86_64.rpm /var/ftp/nginx  移动到网站目录,可以去网站看到放进去了

[root@oldboy ~]# cd /var/ftp/nginx  (无所谓)
[root@oldboy ~]# yum install -y zlib-devel,gcc,gcc-c++,glibc,pcre-devel,openssl-devel   (yum -d 不能用,也没用)
[root@oldboy ~]# find /var/ftp/yum -name '*rpm'|xargs cp -t /usr/local/src/*

[root@oldboy ~]# tar zcf /usr/local/src/*
[root@oldboy ~]# mv /usr/local/src/* /var/ftp/nginx/
虽然yum在安装命令或服务的时候可以自动的去找依赖,但是拥有的仓库里有这些依赖才行

把依赖放到网站目录的方法:(关键是找)
1.安装依赖以前打开yum缓存(/etc/yum.conf)的话,[root@qls ~]# find /var/cache/yum/xx  ,把依赖mv到/var/ftp/nginx 
2.find /mnt/Packages/xx (不一定有)  cp
3.wget http://  (不好找)
4.yum install xx (选-d,只下载不安装,包在哪???缓存不开就没有了)
5.在新机器上 开启yum缓存 下载依赖,sz--rz

nginx1 ---nginx2  
find ../nginx -type f -name '.rpm' ! -name 'nginx*'|xargs cp -t .

-----仓库机createrepo(解压之后)----客户机yum clean all yum makecache

--------------------------------------- 使用vsftpd服务,共享rpm包(镜像站)

---------------客户机 下载NB源镜像站,跟下载官网的一样(源码安装),我只是一个卑微的小运维,做一些脏活,累活

[root@oldboy ~]# ll /etc/yum.repos.d/
[root@oldboy ~]# gzip /etc/yum.repos.d/*
[root@oldboy ~]# vim /etc/yum.repos.d/NB.repo
[NB]
name=kill
baseurl=ftp://仓库机IP/路径
gpgcheck=0
enabled=1
[root@oldboy ~]# yum repolist
[root@oldboy ~]# yum clean all  清除缓存,重新加载,不然显示上一次更新的
[root@oldboy ~]# yum repolist 

[root@oldboy ~]# yum install -y nginx
[root@oldboy ~]# rpm -q
[root@oldboy ~]# rpm -qc
[root@oldboy ~]# rpm -ql
[root@oldboy ~]# /app/nginx/sbin/nginx -t
[root@oldboy ~]# ll /app
[root@oldboy ~]# /app/nginx/sbin/nginx
[root@oldboy ~]# systemctl disable firewalld
[root@oldboy ~]# vim /etc/sysconfig/selinux
[root@oldboy ~]# tail -f /app/nginx/logs/access.log
任何人访问(请求)源码nginx ,都会在正确日志或错误日志记录,(304走的是自己浏览器的缓存,把浏览器缓存关了,日志记录的就是200)

浏览器输入本机IP ,可以看到是NB自己定义的nginx页面 (专属定制),配置文件都在/app/nginx/*
/app/nginx/html/index.html  (站点目录)


--------------------------------------  # Complete



[root@oldboy ~]# createrepo /var/ftp/pub/nginx   更新vsftpd小仓库
重新指定URL(小心客户机和仓库机createrepo 要保持一致性 )

1.
[root@oldboy ~]# yum repolist 
[root@oldboy ~]# yum clean all  清除缓存,重新加载,不然显示1(仓库机要createrepo)
[root@oldboy ~]# yum repolist 
2. 当然也可以重启服务,达到更新的目的

[root@oldboy ~]# yum install -y ngin-1.16.1-1.x86_64.rpm  在有相关依赖的虚拟机里可以安装这个包,没有相关依赖的虚拟机不能安装(因为指定了)

防火墙,selinux
[root@oldboy ~]# /app/nginx-1.16.1/sbin/nginx -t  检查配置文件(ok,successful
[root@qls sbin]# /app/nginx-1.16.1/sbin/nginx   注意不能同时启动2个nginx

ip 域名,软链接,配置文件在/app/nginx/conf,html页面  相关文件都在/app,日志文件不分家
304缓存请求
200正常日志访问
下载依赖包的时候如果缓存不打开的话,下载安装、下载不安装 都找不到包(考虑wget的安全性)
在新环境#重新源码安装nginx
F12 :Network --- disable ---
原文地址:https://www.cnblogs.com/syy1757528181/p/12812790.html