yum install net-tools
不然netstat ifconfig 不能用
1.修改
ifcfg-enp0s3
vim /etc/sysconfig/network-scripts/ifcfg-enp0s3
根据实际情况添加
TYPE=Ethernet #网卡类型
DEVICE=eth0 #网卡接口名称
ONBOOT=yes #系统启动时是否自动加载
BOOTPROTO=static #启用地址协议 --static:静态协议 --bootp协议 --dhcp协议
IPADDR=192.168.1.11 #网卡IP地址
NETMASK=255.255.255.0 #网卡网络地址
GATEWAY=192.168.1.1 #网卡网关地址
DNS1=10.203.104.41 #网卡DNS地址
HWADDR=00:0C:29:13:5D:74 #网卡设备MAC地址
BROADCAST=192.168.1.255 #网卡广播地址
然后:
/etc/init.d/network reload
因为我希望centos和我的真实主机kali在同一网段
所以在virtualbox选择桥接网卡 wlan0
开启SSH
systemctl restart sshd
在主机kali连接centos
ssh 192.168.2.222
像centos传文件:
scp /root/hacking root@192.168.2.222:/root/
详细:
1、从服务器上下载文件
scp username@servername:/path/filename /var/www/local_dir(本地目录)
例如scp root@192.168.0.101:/var/www/test.txt 把192.168.0.101上的/var/www/test.txt 的文件下载到/var/www/local_dir(本地目录)
2、上传本地文件到服务器
scp /path/filename username@servername:/path
例如scp /var/www/test.php root@192.168.0.101:/var/www/ 把本机/var/www/目录下的test.php文件上传到192.168.0.101这台服务器上的/var/www/目录中
3、从服务器下载整个目录
scp -r username@servername:/var/www/remote_dir/(远程目录) /var/www/local_dir(本地目录)
例如:scp -r root@192.168.0.101:/var/www/test /var/www/
4、上传目录到服务器
scp -r local_dir username@servername:remote_dir
例如:scp -r test root@192.168.0.101:/var/www/ 把当前目录下的test目录上传到服务器的/var/www/ 目录
安装Nginx
1、准备工作
选首先安装这几个软件:GCC,PCRE(Perl Compatible Regular Expression),zlib,OpenSSL。
Nginx是C写的,需要用GCC编译;Nginx的Rewrite和HTTP模块会用到PCRE;Nginx中的Gzip用到zlib;
用命令“# gcc”,查看gcc是否安装;如果出现“gcc: no input files”信息,说明已经安装好了。
否则,就需要用命令“# yum install gcc”,进行安装了!一路可能需要多次输入y,进行确认。
安装好后,可以再用命令“#gcc”测试,或者用命令“# gcc -v”查看其版本号。
同样方法,用如下命令安装PCRE,zlib,OpenSSL(其中devel,是develop开发包的意思):
# yum install -y pcre pcre-devel
# yum install -y zlib zlib-devel
# yum install -y openssl openssl-devel
2、下载并安装
创建目录(nginx-src)并进去;然后,从官方地址(http://nginx.org/)下载,解压,配置,编译,安装:
# mkdir nginx-src && cd nginx-src
# wget http://nginx.org/download/nginx-1.7.3.tar.gz
# tar xzf nginx-1.7.3.tar.gz
# cd nginx-1.7.3
# ./configure
# make
# make install
# whereis nginx
nginx: /usr/local/nginx
默认的安装路径为:/usr/local/nginx;跳转到其目录下sbin路径下,便可以启动或停止它了。
# ./nginx -h
nginx version: nginx/1.7.3
Usage: nginx [-?hvVtq] [-s signal] [-c filename] [-p prefix] [-g directives]
Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-q : suppress non-error messages during configuration testing
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file
启动:nginx
停止:nginx -s stop
3、添加到系统服务
使用命令“# vi /etc/init.d/nginx”,打开编辑器,输入如下内容:
#!/bin/sh
# chkconfig: 2345 85 15
# Startup script for the nginx Web Server
# description: nginx is a World Wide Web server.
# It is used to serve HTML files and CGI.
# processname: nginx
# pidfile: /usr/local/nginx/logs/nginx.pid
# config: /usr/local/nginx/conf/nginx.conf
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx deamon"
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
SCRIPTNAME=/etc/init.d/$NAME
test -x $DAEMON || exit 0
d_start(){
$DAEMON || echo -n "already running"
}
d_stop(){
$DAEMON -s quit || echo -n "not running"
}
d_reload(){
$DAEMON -s reload || echo -n "can not reload"
}
case "$1" in
start)
echo -n "Starting DESC:
NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping DESC:
NAME"
d_stop
echo "."
;;
reload)
echo -n "Reloading $DESC conf..."
d_reload
echo "reload ."
;;
restart)
echo -n "Restarting DESC:
NAME"
d_stop
sleep 2
d_start
echo "."
;;
*)
echo "Usage: $ScRIPTNAME {start|stop|reload|restart}" >&2
exit 3
;;
esac
exit 0
保存退出后,再使用下面的命令,使其可执行;然后,添加配置并查看。
可用chkconfig修改其值,也可用ntsysv工具改变是否自启动。
# chmod +x /etc/init.d/nginx
# chkconfig --add nginx
# chkconfig nginx on/off
# chkconfig --list nginx
nginx 0:off 1:off 2:on 3:on 4:on 5:on 6:off
安装FastDFS
1. 下载安装libfastcommon
git clone https://github.com/happyfish100/libfastcommon.git
cd libfastcommon/
./make.sh
./make.sh install
确认make没有错误后,执行安装,64位系统默认会复制到/usr/lib64下。
这时候需要设置环境变量或者创建软链接
export LD_LIBRARY_PATH=/usr/lib64/
ln -s /usr/lib64/libfastcommon.so /usr/local/lib/libfastcommon.so
2. 下载安装fastdfs
tar xzf FastDFS.tar.gz
cd FastDFS/
./make.sh
./make.sh install
确认make没有错误后,执行安装,默认会安装到/usr/bin中,并在/etc/fdfs中添加三个配置文件。
3. 修改配置文件
首先将三个文件的名字去掉sample,暂时只修改以下几点,先让fastdfs跑起来,其余参数调优的时候再考虑。
tracker.conf 中修改
base_path=/usr/fastdfs #用于存放日志。
storage.conf 中修改
base_path=/usr/fastdfs-storaged #用于存放日志。
store_path0=/usr/fastdfs0 #存放数据,若不设置默认为前面那个。
tracker_server=192.168.29.132:22122 #指定tracker服务器地址。
client.conf 中同样要修改
base_path=/usr/fastdfs #用于存放日志。
tracker_server=192.168.29.132:22122 #指定tracker服务器地址。
4. 启动tracker和storage
/usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
/usr/bin/fdfs_storaged /etc/fdfs/storage.conf
5. 检查进程
root@ubuntu:~# ps -ef |grep fdfs
root 7819 1 0 15:24 ? 00:00:00 /usr/bin/fdfs_trackerd /etc/fdfs/tracker.conf
root 8046 1 0 15:36 ? 00:00:01 fdfs_storaged /etc/fdfs/storage.conf start
表示启动ok了,若有错误,可以在/usr/fastdfs目录下检查日志。
6. 上传/删除测试
使用自带的fdfs_test来测试,使用格式如下:
root@ubuntu:~# fdfs_test /etc/fdfs/client.conf upload /home/steven/01.jpg
...
group_name=group1, ip_addr=192.168.29.132, port=23000
storage_upload_by_filename
group_name=group1, remote_filename=M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580.jpg
...
example file url: http://192.168.29.132/group1/M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580.jpg
storage_upload_slave_by_filename
group_name=group1, remote_filename=M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580_big.jpg
...
example file url: http://192.168.29.132/group1/M00/00/00/wKgdhFTV0ZmAP3AZAPk-Io7D4w8580_big.jpg
使用fdfs_delete_file来删除文件,格式如下:
fdfs_delete_file /etc/fdfs/client.conf group1/M00/00/00/wKgdhFTV11uAXgKWAPk-Io7D4w8667.jpg
可以看到,上传ok了,这里会生成两个文件,这是fastdfs的主/从文件特性,以后再介绍。example file url是不能在浏览器中直接打开的,除非配合nginx使用,这里我不需要了。删除文件需要完整的group_name和remote_filename。