Servers 分类中的最新日记

MSN庞大的客户群体是不可忽视的,虽然Live有OpenID,但是很少有人会去开通,并且记得住的不多。记得上次有人在他的BLOG上说很多上网的人其实很白痴,连登录Gmail都要用hao123。包括在我使用OpenID的网站(OpenTags.org)上,真正使用OpenID登录的并不多,Google、Yahoo、Live的用户才多。Google、Yahoo虽然支持OpenID,但是都被阉割了,只是有选择的支持sreg。关于Google、Yahoo,下次再说,今天说Windows Live ID。

Windows Live ID,注意是ID不是OpenID,如果使用Login的方式会得到一个userid,但是这个userid只是一个识别符号,不是真正的Live ID,这个userid只能在你的网络识别Live ID,即一个appid对应一个userid,如果换了appid,即换站userid也跟着变。如果要再作第三方的认证就不合适了。我这里介绍的是取得真正的Live ID,即通过获取Live ID的联系人信息来获取Live ID。

如果要Login方式的userid可以不用再往下面看了,说一下获取Login方式的userid很简单,下载SDK包,然后里面有个sample,看下就懂了,记得要修改Application-Key.xml。

要取得真正的Live ID,按下列步骤即可:

申请(New Project >> Live Services: Existing APIs)


下载 Windows Live ID Web Authentication SDK 1.2 webauth-php-1.2.tar.gz


修改Application-Key.xml


$LoginUrl = '登录地址';
$AuthUrl = '验证地址';
$RealmUrl = '退出后返回的地址';

$DEBUG = true;
$KEYFILE = './Live/Application-Key.xml';
$COOKIE = 'webauthtoken';
$COOKIETTL = time() + (10 * 365 * 24 * 60 * 60);

include_once('./Live/lib/windowslivelogin.php');
$wll = WindowsLiveLogin::initFromXml($KEYFILE);
$wll->setDebug($DEBUG);

if(!empty($_REQUEST['action'])){
switch($_REQUEST['action']) {
case 'logout':
setcookie($COOKIE);
$LocationUrl = $RealmUrl;
break;
case "clearcookie":
setcookie($COOKIE);
$LocationUrl = $AuthUrl;
break;
default:
$user = $wll->processConsent($_REQUEST);
if(!empty($user)){
setcookie($COOKIE, $user->getToken(), $COOKIETTL);
$LocationUrl = $AuthUrl;
}else{
$LocationUrl = $LoginUrl;
}
break;
}
LocationHtml($LocationUrl);
}
$token = $_COOKIE[$COOKIE];
if($token){
$user = $wll->processConsentToken($token);
if(!$user->isValid()){
$LocationUrl = $AuthUrl.'?AuthType=Live&action=clearcookie';
}else{
$url = 'https://livecontacts.services.live.com/users/@L@'.$user->getLocationID().'/rest/livecontacts/owner';
$owner = getLiveID($url, array('Authorization: DelegatedToken dt="'.$user->getDelegationToken().'"'));
$openid = $owner->WindowsLiveID;
$email = $owner->WindowsLiveID;
$fullname = $owner->Profiles->Personal->LastName.' '.$owner->Profiles->Personal->FirstName;
$nickname = $owner->Profiles->Personal->DisplayName;
echo('<pre>');
print_r($owner);
echo('</pre>');
}
}else{
$LocationUrl = $wll->getConsentUrl('Contacts.View', 'zh-CN');
}


function getLiveID($url, $header){
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$data = curl_exec($ch);
curl_close($ch);
try{
$xml = new SimpleXMLElement($data);
}catch(Exception $e){
return false;
}
return $xml;
}

function LocationHtml($url, $e=null){
if(empty($url))
exit;
echo('<html>');
echo('<head>');
echo('<title>Redirect to: '.$url.'</title>');
echo('<meta http-equiv="refresh" content="1;url='.$url.'">');
echo('</head>');
echo('<body bgcolor="#FFFFFF" onload="window.location.href=\''.$url.'\'">');
echo('<table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" height="100%" width="100%">');
echo('<tr>');
echo('<td align="center" valign="middle">');
echo('<a href="'.$url.'" style="color:#000000;text-decoration:none">');
echo($url);
echo('</a>');
echo('</td>');
echo('</tr>');
echo('</table>');
if(!empty($e)){
echo('<script type="text/javascript">');
if(is_array($e))
echo('alert("'.implode('\n', $e).'");');
else
echo('alert("'.$e.'");');
echo('</script>');
}
echo('</body>');
echo('</html>');
exit;
}


注意:getLiveID要CURL支持,如果不支持请用其他办法。
FreeBSD 7.0-RELEASE-i386

IBM T43 2200BG

# ee /boot/loader.conf
添加:
legal.intel_iwi.license_ack=1
if_iwi_load="YES"
wlan_load="YES"
firmware_load="YES"
iwi_bss_load="YES"
iwi_ibss_load="YES"
iwi_monitor_load="YES"
# /etc/netstart
# ifconfig iwi0 list scan
# ee /etc/rc.conf
添加:
ifconfig_bge0="DHCP"
ifconfig_iwi0="ssid TP-LINK_57850C wepmode on weptxkey 1 wepkey 1:0x1234567890 DHCP"
#ifconfig_iwi0="ssid TP-LINK_57850C wepmode on weptxkey 1 wepkey 1:0x1234567890 inet 172.168.1.103 netmask 255.255.255.0"
#ifconfig_iwi0="DHCP ssid TP-LINK_57850C"
# reboot

重启网卡的其他方法:
# ifconfig iwi0 down && ifconfig iwi0 up scan

# /etc/rc.d/netif restart

安装pure-ftpd

| 评论(2)
FreeBSD 7.0-RELEASE-i386

# cd /usr/ports/ftp/pure-ftpd && make install clean
如果用户多可以用MYSQL或者PGSQL管理。
# mkdir /home/ftp
# pw useradd ftp -g ftp -G www -c "PureFTPd user Management" -d /home/ftp -s /sbin/nologin
# pw usermod -n www -G ftp
# chown ftp:ftp /home/ftp
# cp /usr/local/etc/pure-ftpd.conf.sample /usr/local/etc/pure-ftpd.conf
# chmod 664 /usr/local/etc/pure-ftpd.conf
# ee /usr/local/etc/pure-ftpd.conf
77行:NoAnonymous yes
126行:PureDB /usr/local/etc/pureftpd.pdb
240行:MinUID 1000
311行:AltLog stats:/var/log/pureftpd.log
如果ftpname为wheel组,是不可以成为FTP用户的,要该为其他组
# pw usermod -n ftpname -g ftp
# pw usermod -n ftpname -G wheel

# /usr/local/bin/pure-pw useradd ftpu -u ftpname -d /home/ftpname/public
ftpu是FTP用户名,-u ftpname是实际FreeBSD用户,-d锁定起始目录,-D不锁定。如果需要不同权限,建立新的FreeBSD用户、组与之对应。
# /usr/local/bin/pure-pw mkdb /usr/local/etc/pureftpd.pdb
# pw usermod -n ftpname -g wheel

$ mkdir /home/ftpname/public
$ ln -s /usr/local/www/apache22/data /home/ftpname/public/www

# echo 'pureftpd_enable="YES"' >> /etc/rc.conf
# chown -R ftpname:wheel /usr/local/www/apache22/data

# /usr/local/etc/rc.d/pure-ftpd start

修改用户目录:
# /usr/local/bin/pure-pw usermod ftpu -d /home/ftpname/public

# /usr/local/bin/pure-pw mkdb /usr/local/etc/pureftpd.pdb
# /usr/local/etc/rc.d/pure-ftpd restart

修改用户密码
# /usr/local/bin/pure-pw passwd username -m

安装cacti监控

FreeBSD 7.0-RELEASE-i386

# cd /usr/ports/net-mgmt/net-snmp && make install clean
# cd /usr/ports/net-mgmt/cacti && make install clean
ucd-snmp不选
# make pretty-print-run-depends-list
This port requires package(s) "mysql-client-5.0.67_1" to run.
# cd /usr/ports/databases/mysql50-server && make install clean
# echo 'mysql_enable="YES"' >> /etc/rc.conf
# /usr/local/etc/rc.d/mysql-server start
# mysqladmin --user=root create cacti
# echo "GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'; FLUSH PRIVILEGES;" | mysql
# mysql cacti < /usr/local/share/cacti/cacti.sql

# echo 'rocommunity public' >> /usr/local/share/snmp/snmpd.conf
# /usr/local/etc/rc.d/snmpd start
# netstat -na | grep "LISTEN"
# sockstat
//199 161 port
# snmpwalk -v 1 -c public 127.0.0.1 system

# ee /etc/rc.conf
snmpd_enable="YES"
snmpd_flags="-a"
snmpd_pidfile="/var/run/snmpd.pid"
snmptrapd_enable="YES"
snmptrapd_flags="-a -p /var/run/snmptrapd.pid"
# ee /usr/local/share/cacti/include/config.php
# ee /usr/local/etc/apache22/Includes/cacti.conf
Alias /cacti "/usr/local/share/cacti/"

<Directory "/usr/local/share/cacti/">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>

# apachectl configtest
# apachectl restart

# cd /usr/ports/databases/phpmyadmin && make install clean
# cp /usr/local/www/phpMyAdmin/config.sample.inc.php /usr/local/www/phpMyAdmin/config.inc.php
# ee /usr/local/www/phpMyAdmin/config.inc.php
$cfg['blowfish_secret'] = 'erw34'; //随便写什么
# ee /usr/local/etc/apache22/Includes/phpmyadmin.conf
Alias /phpmyadmin/ "/usr/local/www/phpMyAdmin/"

<Directory "/usr/local/www/phpMyAdmin/">
Options none
AllowOverride Limit

Order Deny,Allow
Deny from all
Allow from 127.0.0.1 .example.com
</Directory>

# apachectl configtest
# apachectl restart

http://localhost/cacti/
next >> 完成
登录名:admin
密码:admin
配置完成后。

# /usr/local/bin/php /usr/local/share/cacti/poller.php
# crontab -u cacti -e
*/5 * * * * /usr/local/bin/php /usr/local/share/cacti/poller.php > /dev/null 2>&1
# cat /usr/local/share/cacti/log/cacti.log

参考:
CACTI Version 0.8.7a for FreeBSD 6.2 release 配置全攻略

FreeBSD下用cacti抓取内存信息的方法

安装awstats的过程

| 引用通告(1)
# mkdir /etc/awstats
# mkdir /var/lib
# mkdir -m 777 /var/lib/awstats
# cp /usr/local/www/awstats/cgi-bin/awstats.model.conf /etc/awstats/awstats.www.mysite.com.conf
# ee /etc/awstats/awstats.www.mysite.com.conf
第51行:LogFile="/var/log/apache/www.mysite.com/%YYYY-24%MM-24/httpd-access_%YYYY-24%MM-24%DD-24.log"
第152行:SiteDomain="www.mysite.com"
第167行:HostAliases="mysite.com www.mysite.com 127.0.0.1 localhost 192.168.0.74"
第202行:DirData="/var/lib/awstats"
第238行:AllowToUpdateStatsFromBrowser=1
第449行:DefaultFile="index.php index.htm index.html"
第1515行:Include "awstats.www.mysite.com.conf"
# ee /usr/local/etc/apache22/Includes/awstats.conf
#
# Directives to allow use of AWStats as a CGI
#
Alias /awstatsclasses "/usr/local/www/awstats/classes/"
Alias /awstatscss "/usr/local/www/awstats/css/"
Alias /awstatsicons "/usr/local/www/awstats/icons/"
ScriptAlias /awstats/ "/usr/local/www/awstats/cgi-bin/"

#
# This is to permit URL access to scripts/files in AWStats directory.
#
<Directory "/usr/local/www/awstats/">
Options None
AllowOverride None
Order allow,deny
Allow from all
</Directory>
# apachectl configtest
# apachectl restart

# ee /usr/local/www/awstats/update-logs.sh
/usr/local/www/awstats/cgi-bin/awstats.pl -config=www.mysite.com -update
# chmod 755 /usr/local/www/awstats/update-logs.sh
# setenv EDITOR ee
# crontab -e
10 1 * * * /bin/csh /usr/local/www/awstats/update-logs.sh
不统计指定IP的访问量
SkipHosts="x.x.x.x."

参考:安装Apache2.2

--
免费在线记账服务,个人理财好帮手,小型企业财务管理工具。
http://www.keepaccounts.com/
Mr Wang

王炜,现在福建泉州从事 B2C 电子商务。爱好编程,业余时间在 FreeBSD / Apache / PHP / PostgerSQL 平台开发 B/S 架构的免费软件。

Follow Google Buzz Twitter Facebook Sina

收藏王炜's Blog

Bookmark and Share

关于此归档

这里是分类Servers中的最新日记。

上一个分类Our KeepAccounts

下一个分类Web

首页归档页可以看到最新的日记和所有日记。