CentOS 6 (74)

[warn] NameVirtualHost *:80 has no VirtualHosts

错误:[warn] NameVirtualHost *:80 has no VirtualHosts 原因:定义了多个NameVirtualHost 解决:Ubuntu之前的版本定义在/etc/apache2/sites-available/default, 8.04后在/etc/apache2/ports.conf 故可以将/etc/apache2/ports.conf中的NameVirtualHost *:80注释掉 这个问题的本质是在没有定义域名是一个端口只能对应一个虚拟主机,将NameVirtualHost *:80改为其他端口也可以解决 如果有多个不同的域名的话,用同样的端口也可以
Read more...

CentOS配置时间同步NTP

CentOS配置时间同步NTP 为什么要使用ntpd而不是ntpdate? 原因很简单,ntpd是步进式的逐渐调整时间,而ntpdate是断点更新,比如现在服务器时间是9.18分,而标准时间是9.28分,ntpd会在一段时间内逐渐的把时间校准到与标准时间相同,而ntpdate会立刻把时间调整到9.28分,如果你往数据库内写入内容或在其他对时间有严格要求的生产环境下,产生的后果会是很严重的。(注:当本地时间与标准时间相差30分钟以上是ntpd会停止工作) NTP通信协议原理 1.首先主机启动NTP。 2.客户端会向NTP服务器发送调整时间的message。 3.然后NTP server会送出当前的标准时间给client 4.client接受来自server的时间后,会根据这个信息来调整自己的时间。这样就实现了网络对时。 NTP这个deamon采用了123端口。(UDP) “当我们要利用Tim server来进行实践的同步更新时,就需要使用NTP软件提供的ntpdate来连接端口123” 与时间相关的一些命令和配置文件 1./etc/ntp.conf linux各版本虽然目录不同,但文件名相同。可以用which ntp.conf 或者locate ntp.conf来查找。这是NTP唯一的一个设置文件。 2./usr/share/zoneinfo/ 这个里面规定了这个主要时区的时间设置文件。 3./etc/sysconfig/clock 这个文件是linux的主要时区设置文件,每次开机后linux会自动读取这个文件来设置系统所默认的显示时间,可以看看它里面到底设置了什么: cat /etc/sysconfig/clock # The ZONE parameter is only evaluated by system-config-date. # The timezone of the system is defined by the contents of /etc/localtime. ZONE="Asia/Shanghai" UTC=true ARC=false 4./etc/localtime 本地端时间配置文件。 5./bin/date 这个是时间的修改命令,除了输出时间,还可以修改时间。 6./sbin/hwclock 因为linux系统上面BIOS时间与linux系统时间是分开的,所以使用date这个指令调整了时间之后,还需要使用hwclock才能将修改过的时间写入BIOS中。 7./usr/sbin/ntpd 这是NTP的daemon文件,需要启动它才能提供NTP服务,这个命令会读取/etc/ntp.conf里面的设置。 8./usr/sbin/ntpdate 这是client用来连接NTP Server的主要执行文件,如果您不想启用NTP,只想启用NTP Client功能的话,可以只应用此命令。 9,/usr/sbin/ntptrace 可以用来追踪某台时间服务器的时间对应关系。 安装与配置 1、设置时区 cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime 2、安装ntpd服务 yum -y install ntp 3、配置ntpd vi /etc/ntp.conf restrict default kod nomodify notrap nopeer noquery # restrict -6 default kod nomodify notrap nopeer noquery #针对ipv6设置 # 允许本地所有操作 restrict 127.0.0.1 restrict -6 ::1…
Read more...

lsof 工具

lsof 工具可列出某个Unix 进程所打开文件信息的清单,被打开文件的类型可能包括了:本地文件,目录,网络共享文件,块设备文件,字符设备文件,共享库,管道,软链接,套接字等等. 以下是具体的lsof 操作实例总结: 1,列出所有被打开文件信息 #lsof 2,查看某个被打开文件信息 #lsof /path/to/file #lsof /path/to/file1 /path/to/file2 3,列出某个目录下的被打开文件 #lsof +D /path #lsof | grep “/path” 4,列出某个用户下的被打开文件 #lsof -u nobody #lsof -u nobody,root 5,列出某个进程下的被打开文件 #lsof -c httpd #lsof -c httpd -c mysqld 6,复合查询(OR)被打开文件信息 #lsof -u nobody -c httpd 7,复合查询(AND)被打开文件信息 #lsof -a -u root -c httpd 8,查看除root之外所有用户的被打开文件 #lsof -u ^root 9,查看具体进程PID的被打开文件 #lsof -p 10101 #lsof -p 10101,10102,10103 10,列出所有网络连接 #lsof -i 11,列出所有网络TCP或者UDP连接 #lsof -i tcp #lsof -i udp 12,查看具体网络端口信息 #lsof -i :80 #lsof -i tcp:80 #lsof -i udp:53 13,查看具体用户下所有网络连接 #lsof -a -u www -i 14,列出NFS 文件 #lsof -N 15,列出Unix 套接字文件 #lsof -U 16,列出某个特定文件描述符相关联的文件 #lsof -d 2 #lsof…
Read more...

centos shell get ip mac address

--------------------------------mac------------------------ cat /sys/class/net/eth*/address -------------------------mac----------------------------- /sbin/ifconfig \ | grep 'eth0' \ | tr -s ' ' \ | cut -d ' ' -f5------------------ip-------------------------- /sbin/ifconfig \ | grep '\<inet\>' \ | sed -n '1p' \ | tr -s ' ' \ | cut -d ' ' -f3 \ | cut -d ':' -f2--------------------------mac----------------ifconfig | grep HWaddr | awk -F" " '{print $5}'------------------------ip-------------------------ifconfig eth0 | grep "inet addr" | awk -F: '{print $2}' | awk '{print $1}'
Read more...

linux 网络操作相关命令

#/bin/sh #查看http请求的header tcpdump -s 1024 -l -A -n host 192.168.9.56 tcpdump -s 1024 -l -A src 192.168.9.56 or dst 192.168.9.56 sudo tcpdump -A -s 1492 dst port 80 #本地网络中IP地址为192.168.0.5的主机现在与外界通信的情况 sudo tcpdump -i eth0 src host 192.168.0.5 #查看网卡eth0的http请求的tcp包 tcpdump -i eth0 port http tcpdump -i eth0 port http or port smtp or port imap or port pop3 -l -A | egrep -i 'pass=|pwd=|log=|login=|user=|username=|pw=|passw=|passwd=|password=|pass:|user:|userna me:|password:|login:|pass |user ' #查看tcp,upd,icmp非ssh的包 tcpdump -n -v tcp or udp or icmp and not port 22 #查看http请求的request 包 sudo tcpdump -i eth0 port 80 -w - #过滤http响应的get host头信息 sudo tcpdump -i en1 -n -s 0 -w - |…
Read more...

CentOS 6 VMware Tools Install the Easy Way

Initiate the VMware tools install on your CentOS 6.2 VM. Open a SSH session to your VM and copy/paste this: yum -y install perlmkdir /mnt/cdrommount /dev/cdrom /mnt/cdromcp /mnt/cdrom/VMwareTools-*.tar.gz /tmpumount /mnt/cdromtar -zxf /tmp/VMwareTools-*.tar.gz -C /tmpcd /./tmp/vmware-tools-distrib/vmware-install.pl --defaultrm -f /tmp/VMwareTools-*.tar.gzrm -rf /tmp/vmware-tools-distrib Bam! VMware Tools installed!
Read more...

PuTTYgen

PuTTYgen PuTTYgen 是一套可以產生金鑰的工具,它可生成 RSA 以及 DSA 的金鑰, 做出來的公開以及私有金鑰,可以用於 PuTTY 、 PSCP 、 Plink 以及 Pageant 。 產生一個新的金鑰 : 直接點選 PuTTYgen 圖示。 第一步,選擇所要生成之金鑰的演算法 (RSA / DSA) 、 SSH 版阿本以及金鑰的長度,如下圖所示。  按下後,在下圖所表示的紅框內任意移動滑鼠, 直到金鑰產生結束,此時,電腦會收集滑鼠任意移動所得到的資訊,最為產生金鑰的亂數依據,如下圖。 產生完後,可更改金鑰的備註,另外請任意輸入自己不易忘記的句子,做為啟動私鑰的通行碼之用,之後將私鑰儲存在安全的地方,如下圖所示。 以下將講解上述過程中遇到的各個選項及其代表意義: 生成之金鑰的演算法: SSH 1 協定僅能使用 RSA 做為生成金鑰的演算法,而 SSH 2 協定能夠支援 RSA 以及 DSA 兩種演算法。 PuTTY 的作者強烈建議使用者使用 RSA 來生成金鑰,因為 DSA 有一些設計不良的地方,可能會導致是用者的私鑰被有心人士竊聽,倘若非要使用 DSA 時,也請不要在每台遠端伺服機使用同樣的金鑰。 金鑰的長度: 長度越長,相對而言,也就更為安全,但對於大部分的情況之下, 1024 bit 已經很足夠。 啟動私鑰: 當儲存私鑰至近端電腦時,若沒有輸入通行碼 (passphrase) ,則私鑰不會再被加密,意指任何人若取得此私鑰則對方將聽行無阻。若在儲存之際,有事先輸入自己熟記的一串通行碼,則就算私鑰被拿走,對方也無法取用其中的內容。 請記住你的通行碼,它並無法經由其他方式取得它。 關於相容性的問題: 大部分的 SSH 1 client 使用標準定義的私鑰, PuTTY 也是依照標準來執行,所以不會有與其他的 SSH client 相衝突。 然而 SSH 2 的私鑰並沒有一個標準的格式,所以任一套軟體 (PuTTY 、 OpenSSH 、 ssh.com) 生成的金鑰無法立刻在其他套軟體上執行。 PuTTYgen 能夠將私鑰輸出成 OpenSSH 以及 ssh.com 的格式,請先下載最新測試版的 PuTTYgen ,先將私鑰匯入 PuTTYgen 後,在 Converstions 中選擇所要輸出的格式,在儲存新的私鑰之前,請先移除通行碼。 如何利用金鑰來提供連線認證: 如果你使用 SSH 1 協定,請先至遠端家目錄的 .ssh 目錄,以文字編輯器開啟檔案…
Read more...

Using Rsync and SSH

This document covers using cron, ssh, and rsync to backup files over a local network or the Internet. Part of my goal is to ensure no user intervention is required when the computer is restarted (for passwords, keys, or key managers). I like to backup some logging, mail, and configuration information sometimes on hosts across the network and Internet, and here is a way I have found to do it. You'll need these packages installed: rsync openssh cron (or vixie-cron) Please note these instructions may be specific to Red Hat Linux versions 7.3, 9, and Fedora Core 3, but I…
Read more...

命令行查看Memcached运行状态(shell或者telnet) 测试 Memcach

查看memcached状态的基本命令,通过这个命令可以看到如下信息: STAT pid 22459 进程IDSTAT uptime 1027046 服务器运行秒数STAT time 1273043062 服务器当前unix时间戳STAT version 1.4.4 服务器版本STAT pointer_size 64 操作系统字大小(这台服务器是64位的)STAT rusage_user 0.040000 进程累计用户时间STAT rusage_system 0.260000 进程累计系统时间STAT curr_connections 10 当前打开连接数STAT total_connections 82 曾打开的连接总数STAT connection_structures 13 服务器分配的连接结构数STAT cmd_get 54 执行get命令总数STAT cmd_set 34 执行set命令总数STAT cmd_flush 3 指向flush_all命令总数STAT get_hits 9 get命中次数STAT get_misses 45 get未命中次数STAT delete_misses 5 delete未命中次数STAT delete_hits 1 delete命中次数STAT incr_misses 0 incr未命中次数STAT incr_hits 0 incr命中次数STAT decr_misses 0 decr未命中次数STAT decr_hits 0 decr命中次数STAT cas_misses 0 cas未命中次数STAT cas_hits 0 cas命中次数STAT cas_badval 0 使用擦拭次数STAT auth_cmds 0STAT auth_errors 0STAT bytes_read 15785 读取字节总数STAT bytes_written 15222 写入字节总数STAT limit_maxbytes 1048576 分配的内存数(字节)STAT accepting_conns 1 目前接受的链接数STAT listen_disabled_num 0 STAT threads 4 线程数STAT conn_yields 0STAT bytes 0…
Read more...

( ! ) Warning: count(): Parameter must be an array or an object that implements Countable in /var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php on line 191
Call Stack
#TimeMemoryFunctionLocation
10.0028413552{main}( ).../index.php:0
20.19444263912Joomla\CMS\Application\SiteApplication->execute( ).../index.php:49
30.19444263912Joomla\CMS\Application\SiteApplication->doExecute( ).../CMSApplication.php:196
40.656311453864Joomla\CMS\Application\SiteApplication->dispatch( ).../SiteApplication.php:233
50.657411478144Joomla\CMS\Component\ComponentHelper::renderComponent( ).../SiteApplication.php:194
60.659411533472Joomla\CMS\Component\ComponentHelper::executeComponent( ).../ComponentHelper.php:377
70.660211560872require_once( '/var/www/vhosts/shan.info/httpdocs/components/com_k2/k2.php' ).../ComponentHelper.php:402
80.675111896064K2ControllerItemlist->execute( ).../k2.php:64
90.675111896064K2ControllerItemlist->display( ).../BaseController.php:710
100.692612803008K2ControllerItemlist->display( ).../itemlist.php:49
110.692612803008K2ControllerItemlist->display( ).../controller.php:19
120.696013017272Joomla\CMS\Cache\Controller\ViewController->get( ).../BaseController.php:663
130.708313037960K2ViewItemlist->display( ).../ViewController.php:102
140.950116239784K2ViewItemlist->display( ).../view.html.php:1407
150.950116239784K2ViewItemlist->loadTemplate( ).../HtmlView.php:230
160.953116308256include( '/var/www/vhosts/shan.info/httpdocs/templates/gk_publisher/html/com_k2/templates/default/category.php' ).../HtmlView.php:701