月度归档:2017年05月

Linux CentOS7安装vsftpd 3.0.2服务器

实验环境:CentOS Linux release 7.3.1611 (Core)

内核版本:Linux version 3.10.0-514.el7.x86_64

1.查看系统自带的vsftpd软件包版本

# yum list vsftpd

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.cn99.com
Installed Packages
vsftpd.x86_64 3.0.2-21.el7 @base

2.开始安装

# yum install -y vsftpd

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.njupt.edu.cn
Resolving Dependencies
–> Running transaction check
—> Package vsftpd.x86_64 0:3.0.2-21.el7 will be installed
–> Finished Dependency Resolution

Dependencies Resolved

================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
vsftpd x86_64 3.0.2-21.el7 base 169 k

Transaction Summary
================================================================================
Install 1 Package

Total download size: 169 k
Installed size: 348 k
Downloading packages:
vsftpd-3.0.2-21.el7.x86_64.rpm | 169 kB 00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : vsftpd-3.0.2-21.el7.x86_64 1/1
Verifying : vsftpd-3.0.2-21.el7.x86_64 1/1

Installed:
vsftpd.x86_64 0:3.0.2-21.el7

Complete!

安装成功!

3.查看vsftpd配置文件目录

# ll /etc/vsftpd/

/etc/vsftpd/vsftpd.conf //主配置文件,核心配置文件
/etc/vsftpd/ftpusers //黑名单,这个里面的用户不允许访问FTP服务器
/etc/vsftpd/user_list //白名单,允许访问FTP服务器的用户列表
/etc/vsftpd/vsftpd_conf_migrate.sh //vsftpd操作的一些变量和设置脚本

4.重命名原有vsftpd.conf配置文件

# mv /etc/vsftpd/vsftpd.conf /etc/vsftpd/vsftpd.conf.bak

5.新建vsftpd.conf  并插入下面参数保存并退出

# vi /etc/vsftpd/vsftpd.conf

anonymous_enable=NO //拒绝匿名用户
local_enable=YES //接受本地用户
write_enable=YES //可以上传(全局控制)
local_umask=022 //本地用户上传文件的umask
dirmessage_enable=YES //用户进入一个目次后,是否给出静态提示。默认YES,默认即可
xferlog_enable=YES //表明将记录的上传下载情况写在xferlog_file所指定的文件中
connect_from_port_20=YES //FTP PORT主动模式进行数据传输时使用20端口(ftp-data)。YES使用,NO不使用。
xferlog_std_format=YES //是否采用标准格式记录日志
chroot_local_user=YES //所有的用户均不能切换到其他目录。
chroot_list_enable=YES //所有的用户均不能切换到其他目录
chroot_list_file=/etc/vsftpd/chroot_list //凡是加入vsftpd.chroot_list中的用户都不受限止,即;可以浏览其主目录的上级目录.
listen=NO
listen_ipv6=YES
pam_service_name=vsftpd //虚拟用户使用PAM认证方式。
userlist_enable=YES //是否启用vsftpd.user_list文件。
tcp_wrappers=YES //设置vsftpd是否与tcp wrapper相结合来进行主机的访问控制
allow_writeable_chroot=YES //解决500 OOPS错误

注意:请去掉“//”和“后面的文字”否则启动ftp服务器可能会失败。

6.创建文件chroot_list文件

# touch /etc/vsftpd/chroot_list //默认留空

7.启动ftp服务

# systemctl enable vsftpd.service //设置开机自启动
# systemctl start vsftpd.service //启动ftp服务
# ss -antup | grep ftp //查看ftp服务端口
tcp LISTEN 0 32 :::21 :::* users:((“vsftpd”,pid=6354,fd=3))

显示21端口表示已经启动成功

8.新建ftp用户,其中/home/renwole是我自己的ftp目录,可以根据需要进行相应更改

# useradd -g ftp -d /home/renwole -s /sbin/nologin renwole

-g //用户组 指定用户所属的附加组
-d //目录 指定用户主目录,如果此目录不存在,则同时使用-m选项,可以创建主目录。
-s /sbin/nologin //指定用户只能用于ftp登录,拒绝登录系统

9.设置ebadu用户密码为“renwoletest123”

# passwd renwole

输入两次相同密码回车设置成功

10.设置防火墙,否则无法连接ftp服务器,当然你也可以关闭防火墙。

# firewall-cmd –permanent –zone=public –add-service=ftp //将ftp服务器服务加入防火墙
# firewall-cmd –reload //不重启firewall防火墙使其重载生效

11.设置SELinux:

# getsebool -a | grep ftp
# setsebool -P ftpd_full_access on

vsftpd服务器已经配置安装完成,现在可以测试连接ftp服务器了。

Windows&Linux系统 开发测试环境集成软件包

UPUPW绿色免安装环境包,目前主要在windows下平台运行,支持包括Apache,Nginx和Kangle,并具备cmd命令行管理界面,是windows下不错的虚拟主机管理系统。

详情地址://www.upupw.net

LNMT集成环境安装包,它是有linux shell编写而成,目前也是只能在CentOS/RedHat系统下运行,支持Nginx、MariaDB、Tomcat,常用基本缓存组件,单该环境安装包不支持Apache,是一大遗憾。

详情地址://lnmt.org/

Anmpserver是一个完全开源;而且还是跨平台的开发测试环境软件包,不仅免费,而且还是绿色版,解压即用。支持平台包括Windows、Linux、OS X。该环境包支持Apache、Nginx、MySQL、PHP、还整合了WEB套件,对于菜鸟来说是极大的利器。

详情地址://www.anmpserver.com/

wdcp众人所知,是一套php虚拟主机管理系统,不仅支持Apche、Nginx、MySQL,还支持php、Apche&Nginx多版本共存和SSL。各大云市场都有该系统的镜像,目前wdcp最新版本是V3。可惜不支持windwos平台。

详情地址://www.wdlinux.cn

phpstudy是一个PHP调试环境的程序集成包,该应用集成了最新的Apache、PHP、MySQL、phpMyAdmin、ZendOptimizer,用户安装后无需配置即可使用。对于php新手来说,使用phpstudy配置windows环境可以达到省时省力的效果。但不支持Linux平台。

详情地址://www.phpstudy.net/

XAMPP是完全免费且易于安装的环境软件包,其中包含MariaDB、PHP和Perl。XAMPP开放源码包可以自定义任意修改。XAMPP还支持跨平台操作,也是多年的老牌子,推荐使用。

详情地址://www.apachefriends.org/

WampServer是一个集成安装环境平台。支持Apache、PHP、MySQL数据库。

详情地址://www.wampserver.com/

LNMP一键安装包是用Linux shell编写,可以在CentOS/RadHat/Fedora、Debian/Ubuntu/Raspbian/Deepin VPS或独立主机上安装LNMP(Nginx/MySQL/PHP)、LNMPA(Nginx/MySQL/PHP/Apache)、LAMP(Apache/MySQL/PHP)。可以直接用于生产环境,如果你使用的是linux系统,我建议你使用。

详情地址://lnmp.org/

oneinstack是后起之秀,可快速在生产环境中部署lnmp/lamp/lnmpa/lnmt(Linux、Nginx/Tengine、 MySQL/MariaDB/Percona、PHP、Apache、Tomcat)适用于CentOS 5~7(包括redhat)、Debian 6~8、Ubuntu 12~15的32位和64位,推荐使用。

详情地址://oneinstack.com/

PHPWAMP是运行在windows平台下纯绿色的PHP集成环境,这个环境和WampServer差不多,支持php多版本切换。

详情地址://www.phpwamp.com/

Windows server 2012 R2二进制(绿色免安装)安装MySQL5.7.18数据库

实验环境Windows2012 R2 64 数据中心版,Mysql 5.7.18 x64位 二进制安装包。
该mysql配置适用于windows server 2003/2008/2012/2016 64位

下载安装包//dev.mysql.com/downloads/mysql/
将压缩包解压到D盘并命名为mysql-5.7.18
接下来添加系统变量;我的电脑-右击属性-或高级系统设置-高级-环境变量-系统变量。修改Path变量名中变量值的最后面添加mysql路径(在加之前先加分号;和前面已有的变量值分开)。

;D:\mysql-5.7.18\bin

解压的mysql目录默认存在my-default.ini,拷贝一份命名为my.ini。并将下面mysql优化参数替换my.ini原有的内容。

[client]
no-beep
port=3306
[mysql]
default-character-set=utf8

[mysqld]
lower_case_table_names=1
port=3306
basedir=”D:/mysql-5.7.18″
datadir=”D:/mysql-5.7.18/Data”
tmpdir=”D:/mysql-5.7.18/Temp”
character-set-server=utf8

default-storage-engine=INNODB
sql-mode=”NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION”
# General and Slow logging.
log-output=FILE
general-log=0
general_log_file=”D:/mysql-5.7.18/mysql-general.log”
slow-query-log=1
slow_query_log_file=”D:/mysql-5.7.18/mysql-slow.log”
long_query_time=10

log-error=”D:/mysql-5.7.18/mysql.err”

server-id=0
secure-file-priv=”D:/mysql-5.7.18/Uploads”

#YH

max_connections=151
query_cache_size=0
table_open_cache=2000
tmp_table_size=40M
thread_cache_size=10

#*** MyISAM Specific options
myisam_max_sort_file_size=100G
myisam_sort_buffer_size=71M
key_buffer_size=8M
read_buffer_size=64K
read_rnd_buffer_size=256K

#*** INNODB Specific options ***
innodb_flush_log_at_trx_commit=1
innodb_log_buffer_size=1M
innodb_buffer_pool_size=8M
innodb_log_file_size=48M
innodb_thread_concurrency=9
innodb_autoextend_increment=64
innodb_buffer_pool_instances=8
innodb_concurrency_tickets=5000
innodb_old_blocks_time=1000
innodb_open_files=300
innodb_stats_on_metadata=0
innodb_file_per_table=1
innodb_checksum_algorithm=0

back_log=80
flush_time=0
join_buffer_size=256K
max_allowed_packet=4M
max_connect_errors=100
open_files_limit=4161
query_cache_type=0
sort_buffer_size=256K
table_definition_cache=1400
binlog_row_event_max_size=8K
sync_master_info=10000
sync_relay_log=10000
sync_relay_log_info=10000

以上mysql参数是我精心优化,并参考了网上诸多实例而来,放心使用,当然你也可以根据需要修改。

注意:如果mysql目录下无下列目录,就按照配置文件里的设置创建文件夹。

D:\MySql\Data
D:\MySql\Temp
D:\MySQL\Uploads

下面添加服务名,windwos键+r调出运行,输入cmd,并安装为系统服务,具体命令操作如下;

C:\Users\Administrator>d:
D:\>cd mysql-5.7.18
D:\mysql-5.7.18>cd bin
D:\mysql-5.7.18\bin>mysqld –install MySQL
Service successfully installed.

显示已经添加mysql服务名成功.

这里需要注意;安装mysql服务名的时候有些教程需要指派my.ini文件的具体路径,其实这个指派与否并不重要,mysql启动的时候会自动识别mysql目录下的my.ini,如果没有此文件或my.ini配置不正确都会导致mysql启动失败。

安装mysql服务器成功后;默认用户名是root,密码为空。可以通过cmd设置mysql的root密码,现在给root设置密码为RenwolePasswd123。cmd命令操作如下;

C:\Users\Administrator>d:
D:\>cd mysql-5.7.18
D:\mysql-5.7.18>cd bin
D:\mysql-5.7.18\bin>mysqladmin -u root -p password RenwolePasswd123

到此mysql服务器安装已完成。现在的mysql服务器已具备生产中所需环境。

mysql占用cpu百分之百解决方案

虚拟主机的mysql数据库经常cpu 100%,日志中也没有详细说明,导致mysql运行速度慢,严重时实例还会挂掉。要查看到底哪个数据库占用cpu就需要要用到mysql过滤命令processlist,从而解决mysql跑cpu的问题。

第一种方案,登陆phpmyadmin执行以下sql语句;

show processlist;

执行后会反馈出具体存在问题的数据库。
第二种方案,使用终端登录mysql数据库,执行以下语句即可;

MariaDB [(none)]> show processlist;
+——+——+———–+——+———+——+——-+——————+–
| Id | User | Host | db | Command | Time | State | Info | P
+——+——+———–+——+———+——+——-+——————+–
| 3008 | root | localhost | NULL | Query | 0 | init | show processlist |
+——+——+———–+——+———+——+——-+——————+–
1 row in set (0.00 sec)

反馈出来的就是有问题的数据库,两种方法差不多,但结果都是一样的。

Linux Centos7下chattr lsattr命令查看、隐藏、锁定文件

今天一个客户Cenots系统的lnmp环境lnmp环境,ftp下有一个文件,即使使用root权限也删除不掉,后来才发现,该文件的属性被锁定了,于是我就把这个命令记录下来,以备以后使用。总结了2个命令

chattr与lsattr

1、实际应用如下:

chattr命令禁止修改系统关键文件,命令如下。

[root@localhost ~]# chattr +i /etc/resolv.conf

2、现在使用lsattr命令查看resolv.conf文件的属性

[root@localhost ~]# lsattr /etc/resolv.conf
—-i———– /etc/resolv.conf

3、该文件已经被锁定,即使root权限也无法删除、修改、或移动。

4、比如让某个文件只能往里面写数据,但不能被删除。该场景适用于重要的日志文件。这样写;

chattr +a /var/log/messages

5、例如显示当前目录所有隐藏文件

[root@localhost ~]# lsattr -a

大概可以这么理解:chattr是锁定用的,lsattr是查看隐藏文件的属性。

linux定时计划任务 自动删除目录下文件

运行系统;centos7.3 64 最小化安装

要实现定时删除某个目录下的所有文件需要用到linux的crontab命令,可以用shell脚本实现。例如删除/tmp下的所有缓存文件,操作如下:

[root@localhost ~]# vi /etc/init.d/delete.sh

按i并复制下面内容到delete.sh文件内,之后按shift+: 输入wq保存并退出。

#!/bin/bash
dir=/tmp //需要清空的目录名称
files=`ls ${dir}`
for file in $files
do
if [ -e ${dir}/${file} ];then
rm -f ${dir}/${file}
fi
done

然后给此脚本755权限,代码如下:

[root@localhost ~]# chmod 755 /etc/init.d/delete.sh

下面就使用crontab命令进行时间设定,例如,每天凌晨3点清除/tmp目录下的所有文件。运行以下命令会进入vim编辑界面。

[root@localhost ~]# crontab –e

粘贴以下代码;

0 3 * * * /etc/init.d/delete.sh

保存并退出,现在定时工作已经完成了,每天凌晨3点自动清空/tmp目录下的文件。

crontab –e的时间用法说明;

* * * * * /etc/init.d/delete.sh

分 时 日 月 周 命令
第1列*号表示分钟1-59 每分钟用*或者 */1表示
第2列*号表示小时0-23小时(0表示0点)
第3列*号表示日期1-31日
第4列*号表示月份1-12月
第5列*号表示每周,0-6(0表示星期天)
第6列是要运行的命令

例如每周3的晚上23:30运行该脚本,可以这样写:

30 23 * * 3 /etc/init.d/delete.sh

其他时间段也是如此。

linux centos7分区 格式化挂载磁盘

服务器安装centos的时候,通常linux系统分区默认为3个分区,主分区最多4个,其他可根据自己的需要挂载。

/ 根分区,通常10-100G左右(根据总磁盘大小情况)
/boot 系统操作分区 (100-500MB 足矣)
/swap 虚拟内存暂存分区(通常是内存的2倍)

如果有剩下的磁盘就保留,后期再挂载。安装完系统后就开始格式化剩下的分区,并挂载指派出来。

1、首先查看未指派的分区名称,有的不一样,我的分别是/dev/sda和/dev/sdb,sda是系统分区,sdb是存储数据分区。

# fdisk -l
Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00043041

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

2、可以看到红色标注的是10G的数据磁盘,我们现在执行分区,代码如下:

# fdisk -S 56 /dev/sdb

Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x52d681d6.

The device presents a logical sector size that is smaller than
the physical sector size. Aligning to a physical sector (or optimal
I/O) size boundary is recommended, or performance may be impacted.

Command (m for help):【输入n回车,添加新分区,如果需要更多,请输入m回车看帮助】

Partition type:
p primary (0 primary, 0 extended, 4 free)
e extended
Select (default p):【输入p回车,P的意思是主分区】
Partition number (1-4, default 1):【输入数字1回车,分区数量】
First sector (2048-20971519, default 2048):【默认回车】
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-20971519, default 20971519):【默认回车】
Using default value 20971519
Partition 1 of type Linux and of size 10 GiB is set

Command (m for help):【输入wq保存】

The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

3、分区完成。输入fdisk -l查看信息

Disk /dev/sda: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x00043041

Device Boot Start End Blocks Id System
/dev/sda1 * 2048 2099199 1048576 83 Linux
/dev/sda2 2099200 20971519 9436160 8e Linux LVM

Disk /dev/sdb: 10.7 GB, 10737418240 bytes, 20971520 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk label type: dos
Disk identifier: 0x52d681d6

Device Boot Start End Blocks Id System
/dev/sdb1 2048 20971519 10484736 83 Linux

Disk /dev/mapper/cl-root: 8585 MB, 8585740288 bytes, 16769024 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
Disk /dev/mapper/cl-swap: 1073 MB, 1073741824 bytes, 2097152 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes

4、可以查看/dev/sdb1已经被默认分区,现在开始格式化此分区。

注意:以下有几种常用磁盘格式,如果你想格式化ext3格式,代码如下;

# mkfs.ext3 /dev/sdb1

格式化ext4格式,代码如下;

# mkfs.ext4 /dev/sdb1

我这里采用的是xfs磁盘格式;代码如下;

# mkfs.xfs -f /dev/sdb1

meta-data=/dev/sdb1 isize=512 agcount=4, agsize=655296 blks
= sectsz=4096 attr=2, projid32bit=1
= crc=1 finobt=0, sparse=0
data = bsize=4096 blocks=2621184, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0 ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=4096 sunit=1 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

5、已经格式化成功。将磁盘挂载信息写入到系统配置文件中,不然开机不会自动挂载,代码如下;

# echo ‘/dev/sdb1 /www xfs defaults 0 0’ >> /etc/fstab
# mkdir /www //新建挂载目录
# mount -a //挂载磁盘
# df -h //查看挂载是否成功

Filesystem Size Used Avail Use% Mounted on
/dev/mapper/cl-root 8.0G 3.1G 5.0G 39% /
devtmpfs 906M 0 906M 0% /dev
tmpfs 916M 0 916M 0% /dev/shm
tmpfs 916M 8.3M 908M 1% /run
tmpfs 916M 0 916M 0% /sys/fs/cgroup
/dev/sda1 1014M 138M 877M 14% /boot
tmpfs 184M 0 184M 0% /run/user/0
/dev/sdb1 10G 33M 10G 1% /www

6、可以看到www目录已经挂载成功。

扩展阅读,fdisk -S 56 /dev/sdb的时候输入m有帮助信息,下面就列举说明:

a、toggle a bootable flag //切换一个可启动的标志
b、 edit bsd disklabel //编辑bsd disklabel
c、 toggle the dos compatibility flag //切换dos兼容性模式
d、 delete a partition //删除一个分区
g、 create a new empty GPT partition table //创建一个新的空GPT分区表
G 、create an IRIX (SGI) partition table //创建一个IRIX(SGI)分区表
l 、list known partition types //列出已知的分区类型
m、 print this menu //打印此菜单
n、 add a new partition //添加一个新的分区
o、 create a new empty DOS partition table //创建一个新的空DOS分区表
p、 print the partition table //打印分区表
q、 quit without saving changes //退出而不保存更改
s、 create a new empty Sun disklabel //创建一个新的空的Sun磁盘标签
t、 change a partition’s system id //更改分区的系统ID
u、 change display/entry units //更改显示/输入单位
v、 verify the partition table //验证分区表
w、 write table to disk and exit //将表写入磁盘保存并退出
x、extra functionality (experts only) //高级功能(仅限专家)

linux Nginx1.12.0平滑升级到新版本nginx-1.13.3

本篇演示生产环境:Centos7.3 64位 最小化安装版。

1.查看当前Nginx版本信息。代码如下:

# /usr/local/nginx/sbin/nginx -V
 nginx version: nginx/1.12.0
 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
 built with OpenSSL 1.0.1e-fips 11 Feb 2013
 TLS SNI support enabled
 configure arguments: --prefix=/usr/local/nginx --user=www --group=www --with-pcre --with-http_v2_module --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_image_filter_module --with-mail --with-threads --with-mail_ssl_module --with-stream_ssl_module

2.下载nginx-1.13.3版本到/usr/local/下,解压并进入解压后的目录。代码如下:

 # cd /usr/local/
 # wget //nginx.org/download/nginx-1.13.3.tar.gz
 # wget //www.openssl.org/source/openssl-1.1.0e.tar.gz //下载最新openssl
 # tar zxvf openssl-1.1.0e.tar.gz //解压文件
 # tar zxvf nginx-1.13.3.tar.gz
 # cd nginx-1.13.3

3.查看nginx版本的时候,configure后面有一大串模块,这也是你第一次安装nginx时所指定的模块,升级的时候也要同时指定,也可以添加其他模块。代码如下:

./configure \
 --prefix=/usr/local/nginx \
 --user=www \
 --group=www \
 --with-pcre \
 --with-openssl=/tmp/openssl-1.1.0e \
 --with-http_ssl_module \
 --with-http_v2_module \
 --with-http_realip_module \
 --with-http_addition_module \
 --with-http_sub_module \
 --with-http_dav_module \
 --with-http_flv_module \
 --with-http_mp4_module \
 --with-http_gunzip_module \
 --with-http_gzip_static_module \
 --with-http_random_index_module \
 --with-http_secure_link_module \
 --with-http_stub_status_module \
 --with-http_auth_request_module \
 --with-http_image_filter_module \
 --with-mail \
 --with-threads \
 --with-mail_ssl_module \
 --with-stream_ssl_module \
 # make

4.注意:make完以后,执行下面代码。不需要执行make install,否则会覆盖安装,nginx服务会出现各种问题。

不中断nginx web服务器的正常运行称之为平滑升级,先重命名之前的nginx二进制文件。代码如下:

# mv /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak

拷贝刚编译新生产的Nginx二进制文件到/usr/local/nginx/sbin/目录;代码如下:

# cp /usr/local/nginx-1.13.3/objs/nginx /usr/local/nginx/sbin/

5.开始执行升级命令。代码如下:

# cd /usr/local/nginx-1.13.3
 # make upgrade
 /usr/local/nginx/sbin/nginx -t
 nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
 nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful
 kill -USR2 `cat /usr/local/nginx/logs/nginx.pid`
 sleep 1
 test -f /usr/local/nginx/logs/nginx.pid.oldbin
 kill -QUIT `cat /usr/local/nginx/logs/nginx.pid.oldbin`

6.再次查看nginx升级后的版本信息。代码如下:

# /usr/local/nginx/sbin/nginx -V
nginx version: nginx/1.13.3
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-11) (GCC)
built with OpenSSL 1.1.0e 16 Feb 2017
TLS SNI support enabled

可以看到已经成功升级到1.13.3,本文教程可用于生产环境当中。希望能帮到大家。转载请注明!

linux centos7系统tar文件压缩打包命令

实验环境:Centos7.* 64位,最小化安装版。长时间不解压缩,命令就会忘记,给自己留个记录,没事来看看。

打包成tar.gz格式压缩包

# tar -zcvf renwolesshel.tar.gz /renwolesshel

解压tar.gz格式压缩包

# tar zxvf renwolesshel.tar.gz

打包成tar.bz2格式压缩包

# tar -jcvf renwolesshel.tar.bz2 /renwolesshel

解压tar.bz2格式的压缩包

# tar jxvf renwolesshel.tar.bz2

压缩成zip格式

# zip -q -r renwolesshel.zip renwolesshel/

解压zip格式的压缩包

# unzip renwolesshel.zip

暂时先这些吧,后期遇到了再添加。

linux Centos7 ssh、sftp、scp命令远程传输文件

以下实验数据都是手工亲测,非拷贝而来,所以真实可靠,也是我在工作当中经常用到的一些命令,分享出来,大家一块学习。
系统操作环境Centos7.3 64 *2,两台机器都在公网IP地址分别是

A:223.5.5.5
B:223.6.6.6

一、sftp是一个交互式文件传输程式。它类似于ftp传输协议,属于ssh, 但它进行加密传输,相对FTP来讲有更高的安全性。

sftp用法

如果有服务器的端口不是默认的22,请在sftp后面加-P 端口号 即可。

# sftp root@223.6.6.6
The authenticity of host ‘223.6.6.6 (223.6.6.6)’ can’t be established.
ECDSA key fingerprint is SHA256:Hl/dKTFzL4lOlF8DIG5itaV4OAsZunC2AWlFGLjLfsg.
Are you sure you want to continue connecting (yes/no)? yes【输入yes回车】
Warning: Permanently added ‘223.6.6.6’ (ECDSA) to the list of known hosts.
root@223.6.6.6’s password:【输入223.6.6.6的root密码并回车】
Connected to 223.6.6.6.
sftp>

将223.6.6.6服务器文件下载到223.5.5.5的home目录;

sftp> get /var/www/renwole.txt /home/

将223.5.5.5服务器文件上传到223.6.6.6服务器的mnt目录;

sftp> put /home/renwole.txt /mnt/

你如果不知道远程主机的目录是什么样, ls命令可以列出223.6.6.6服务器的当前目录列表。例如:

sftp> ls //和查看本地操作命令一样
sftp> pwd //查询223.6.6.6的当前工作目录

改变路径可以用cd ,改变本机路径可以用 cd.. 例如;

sftp> cd

如果用于修改服务器文件,可以使用ssh连接,例如:

# ssh root@223.6.6.6
root@223.6.6.6’s password:【输入B服务器密码回车进入内部】

如果想退出,例如:

# exit //退出机器,返回你原始机器界面。

二、scp具有和ssh一样的验证机制,从而可以实现2台机器安全的远程拷贝文件。

scp可以概括为:

scp -P 端口 文件路径 用户名@主机地址:远程目录

如果想拷贝本地文件到另外一台ssh终端,可以使用以下命令;

# scp /renwole/mariadb.tar.gz root@223.6.6.6:/renwole123/
root@223.6.6.6’s password:【输入密码回车】
mariadb.tar.gz  8%  37MB  1.3MB/s  05:29  ETA

如果你反过来操作,把远程主机的文件拷贝到当前系统,操作命令以下;

# scp root@223.6.6.6:/renwole123/mariadb.tar.gz /renwole

如果你想拷贝文件夹以及文件夹内的所有文件,就加参数 -r 如果你的端口号不是22,那么需要在scp后加个 -P (区分大小写)端口号。建议加-C选项,因为这样可以启用SSH的压缩功能;传输速度更快,例如

# scp -P 6632 -C /renwole/mariadb root@223.6.6.6:/renwole123/

其实我个人建议使用scp,速度快,稳定,安全。