Centos7.4 初始化-网络设置-sudo设置-ifconfig

http://mirrors.aliyun.com/centos/7.4.1708/isos/x86_64/
下载个最小镜像,安装的过程跳过。。

1.查看mac地址(在路由有时要绑定mac)

# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 00:0c:29:52:36:e6 brd ff:ff:ff:ff:ff:ff
inet 192.168.1.30/24 brd 192.168.1.255 scope global ens32
valid_lft forever preferred_lft forever
inet6 fe80::b9b:78aa:abc9:6146/64 scope link
valid_lft forever preferred_lft forever

2.配置网络:

#vi /etc/sysconfig/network-scripts/ifcfg-ens32

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=423fae8d-6151-424b-af3b-9dbd5ad39fa5
DEVICE=ens32
#modify
BOOTPROTO=static
ONBOOT=yes
IPADDR0=192.168.1.30
PREFIX0=24
NETMASK=255.255.255.0
GATEWAY0=192.168.1.254
DNS1=192.168.1.254

service network restart

3.安装一些常用命令
yum install -y net-tools.x86_64 nmap-ncat.x86_64 lrzsz lsof wget git 
4.设置sudo免密码
echo 'username ALL=(ALL) NOPASSWD: ALL' >> /etc/sudoers

wordpress修改上传文件大小及类型

wordpress 版本是最新的,4.8.1
默认,只有部分图像类型的文件可以上传,文件大小限制为2M。

1.修改文件类型:

vi wp-includes/functions.php
/mysql2date jump to this function:
$mime_to_ext = apply_filters( 'getimagesize_mimes_to_exts', array(
'image/jpeg' => 'jpg',
'image/png' => 'png',
'image/gif' => 'gif',
'image/bmp' => 'bmp',
'image/tiff' => 'tif',
//add more file type
'zip'=> 'application/zip',
'tar'=> 'application/x-tar',
'gz|gzip'=> 'application/x-gzip',

) );

现在就增加了zip/tar/gz/gzip文件类型的支持。

2.  修改文件大小

a.php

5.6/fpm/php.ini:post_max_size = 32M
5.6/fpm/php.ini:upload_max_filesize = 32M

重启php5.6-fpm

b.nginx:413 Request Entity Too Large

在nginx.conf里找到http段,加一句:client_max_body_size 32m;

重启nginx

从mysql备份文件中得到某一张表的数据

有时候,想从备份sql中查看某张表的数据,常规的做法是先恢复整库再找那张表,太浪费时间了。于是就写了个bash脚本从整库的备份文件中提取某张表。
./export_one_table_from_backup_file.sh '\`user\`' 'backup.sql'"

#!/bin/bash
if [ $# -lt 2 ]; then
echo "usage: ./export_one_table_from_backup_file.sh'\`table_name\`' 'backup_sql_file'"
echo "Example: ./export_one_table_from_backup_file.sh '\`user\`' 'backup.sql'"
exit
fi
tb_name=$1
sql_file=$2
if [ ! -f "$sql_file" ]
then
echo $sql_file not exist,shell exit
exit
else
echo $sql_file is found
echo start check table: $1 from $2
fi
new_sql_name=`echo $tb_name|sed -e 's/\`//g'`
echo ${new_sql_name}
new_sql_file_name=${new_sql_name}_`date +%Y%m%d-%H-%M-%S`.sql
start_line=`grep -n "$tb_name" $sql_file |awk -F':' '{print $1}'|head -n 1`
end_line=`grep -n "$tb_name" $sql_file |awk -F':' '{print $1}'|tail -n 1`
echo $start_line $end_line
echo 'set foreign_key_checks=0;' > $new_sql_file_name
cat $sql_file |sed -n "${start_line},${end_line}p" >> $new_sql_file_name
echo 'set foreign_key_checks=1;' >> $new_sql_file_name
echo ls $new_sql_file_name