Archive for category PHP语言学习
nginx的一个简单配置
wget http://www.nginx.org/download/nginx-1.1.7.tar.gz
tar -zxvf nginx-1.1.7.tar.gz
wget http://wiki.nginx.org/images/7/78/Ngx_http_log_request_speed.tar.gz
wget https://nodeload.github.com/giom/nginx_accept_language_module/tarball/master –no-check-certificate -O nginx_accept_language_module.tar.gz
cd nginx-1.1.7
cd contrib
wget http://geolite.maxmind.com/download/geoip/database/GeoIPCountryCSV.zip
perl geo2nginx.pl < GeoIPCountryCSV.zip >geo.conf
cd ..
tar -zxvf ../Ngx_http_log_request_speed.tar.gz
tar -zxvf ../nginx_accept_language_module.tar.gz
sed -i -e ‘s/”nginx/”mws/g’ -e ‘s/1\./2\./g’ -e ‘s/”NGINX/”MWS/g’ src/core/nginx.h
./configure –prefix=/usr/local/nginx/ –with-http_stub_status_module –with-http_ssl_module –with-http_realip_module –add-module=ngx_http_log_request_speed –add-module=ngx_http_set_lang
make && make install
userid on;
userid_name uid;
userid_domain xxx.com;
userid_path /;
userid_expires 365d;
做个gif以便分析log
location = /_.gif {
empty_gif;
expires -1;
userid on;
userid_name _x;
userid_domain milanoo.com;
userid_path /;
userid_expires 365d;
if ( $uid_set ~ “^_x=(.+)$” ) {
set $uid $1;
}
if ( $uid_got ~ “^_x=(.+)$” ) {
set $uid $1;
}
log_format albertLog ‘$remote_addr – $uid – $time_local ^-^ “$http_referer” ^-^ “$args” ^-^ $http_Accept_Language – $http_user_agent’;
if ( $http_referer ) {
access_log logs/fx.log albertLog;
}
}
php X-Powered-By 去除
修改php.ini
expose_php = Off
或者nginx header_hidden
利用nginx user 模块进行A/B test
userid on;
userid_name uid;
userid_domain milanoo.com;
userid_path /;
userid_expires 365d;
if ( $uid_set ~ “^uid=(.{9})(.)(.+)$” ) {
set $serp $2;
set $uid $1$2$3;
}
if ( $uid_got ~ “^uid=(.{9})(.)(.+)$” ) {
set $serp $2;
set $uid $1$2$3;
}
set $fa A;
if ( $serp ~ “(A|B|C|D)” ) {
set $fa B;
}
##这个也可以出C方案D方案,就和 $serp分吧,但是必须是1/16的。。
log_format main ‘$uid_got – $serp – $uid_set’; //debug Log
access_log logs/php.log main; //debug//
#####要想做a/b test对$serp进行正则即可。。###
fastcgi_pass 127.0.0.1:9000;
fastcgi_param FA $fa #将方案号传递给php $_SERVER['FA']
fastcgi_param UID $uid; #传递给php $_SERVER['UID']
处理nginx user模块的sid 获得时间戳
$str = “D616AD4D”;
$splited = str_split($str, 2);
$splited = array_reverse($splited);
$str = implode(”, $splited);
print hexdec($str);
?>
nginx 安全策略学习
http://yp.oss.org.cn/software/show_resource.php?resource_id=1030
兄弟连
溫特斯年老時接受採訪的片段,他在其中轉述了戰友邁克·蘭尼中士的話:“每當回想起在E連的那段日子,我總是很珍惜我對孫子說過的話,他問我,‘爺爺,你是戰爭中的英雄嗎?’我回答,‘不是,可我加入了英雄的連隊……’”
nginx 对待空header访问
server {
listen 80 default;
rewrite ^(.*) http://www.myip.net permanent;
}
return 403也行
grep 子目录
find . -name *.php|xargs grep session_start()
expire 函数
function __expire($expires) {
header(“Pragma: public”);
header(“Cache-Control: maxage=”.$expires);
header(‘Expires: ‘ . gmdate(‘D, d M Y H:i:s’, time()+$expires) . ‘ GMT’);
}
__expire(600);
wget 使用手册
Linux wget是一个下载文件的工具,它用在命令行下。对于Linux用户是必不可少的工具,尤其对于网络管理员,经常要下载一些软件或从远程服务器恢复备份到本地服务器。如果我们使用虚拟主机,处理这样的事务我们只能先从远程服务器下载到我们电脑磁盘,然后再用ftp工具上传到服务器。这样既浪费时间又浪费精力,那不没办法的事。而到了Linux VPS,它则可以直接下载到服务器而不用经过上传这一步。wget工具体积小但功能完善,它支持断点下载功能,同时支持FTP和HTTP下载方式,支持代理服务器和设置起来方便简单。下面我们以实例的形式说明怎么使用wget。
1、使用wget下载单个文件
以下的例子是从网络下载一个文件并保存在当前目录
wget http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
在下载的过程中会显示进度条,包含(下载完成百分比,已经下载的字节,当前下载速度,剩余下载时间)。
2、使用wget -O下载并以不同的文件名保存
wget默认会以最后一个符合”/”的后面的字符来命令,对于动态链接的下载通常文件名会不正确。
错误:下面的例子会下载一个文件并以名称download.php?id=1080保存
wget http://www.centos.bz/download?id=1
即使下载的文件是zip格式,它仍然以download.php?id=1080命令。
正确:为了解决这个问题,我们可以使用参数-O来指定一个文件名:
wget -O wordpress.zip http://www.centos.bz/download.php?id=1080
3、使用wget –limit -rate限速下载
当你执行wget的时候,它默认会占用全部可能的宽带下载。但是当你准备下载一个大文件,而你还需要下载其它文件时就有必要限速了。
wget –limit-rate=300k http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
4、使用wget -c断点续传
使用wget -c重新启动下载中断的文件:
wget -c http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
对于我们下载大文件时突然由于网络等原因中断非常有帮助,我们可以继续接着下载而不是重新下载一个文件。需要继续中断的下载时可以使用-c参数。
5、使用wget -b后台下载
对于下载非常大的文件的时候,我们可以使用参数-b进行后台下载。
wget -b http://cn.wordpress.org/wordpress-3.1-zh_CN.zip
Continuing in background, pid 1840.
Output will be written to `wget-log’.
你可以使用以下命令来察看下载进度
tail -f wget-log
6、伪装代理名称下载
有些网站能通过根据判断代理名称不是浏览器而拒绝你的下载请求。不过你可以通过–user-agent参数伪装。
wget –user-agent=”Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16″ 下载链接
7、使用wget –spider测试下载链接
当你打算进行定时下载,你应该在预定时间测试下载链接是否有效。我们可以增加–spider参数进行检查。
wget –spider URL
如果下载链接正确,将会显示
wget –spider URL
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response… 200 OK
Length: unspecified [text/html]
Remote file exists and could contain further links,
but recursion is disabled — not retrieving.
这保证了下载能在预定的时间进行,但当你给错了一个链接,将会显示如下错误
wget –spider url
Spider mode enabled. Check if remote file exists.
HTTP request sent, awaiting response… 404 Not Found
Remote file does not exist — broken link!!!
你可以在以下几种情况下使用spider参数:
定时下载之前进行检查
间隔检测网站是否可用
检查网站页面的死链接
8、使用wget –tries增加重试次数
如果网络有问题或下载一个大文件也有可能失败。wget默认重试20次连接下载文件。如果需要,你可以使用–tries增加重试次数。
wget –tries=40 URL
9、使用wget -i下载多个文件
首先,保存一份下载链接文件
cat > filelist.txt
url1
url2
url3
url4
接着使用这个文件和参数-i下载
wget -i filelist.txt
10、使用wget –mirror镜像网站
下面的例子是下载整个网站到本地。
wget –mirror -p –convert-links -P ./LOCAL URL
–miror:开户镜像下载
-p:下载所有为了html页面显示正常的文件
–convert-links:下载后,转换成本地的链接
-P ./LOCAL:保存所有文件和目录到本地指定目录
11、使用wget –reject过滤指定格式下载
你想下载一个网站,但你不希望下载图片,你可以使用以下命令。
wget –reject=gif url
12、使用wget -o把下载信息存入日志文件
你不希望下载信息直接显示在终端而是在一个日志文件,可以使用以下命令:
wget -o download.log URL
13、使用wget -Q限制总下载文件大小
当你想要下载的文件超过5M而退出下载,你可以使用以下命令:
wget -Q5m -i filelist.txt
注意:这个参数对单个文件下载不起作用,只能递归下载时才有效。
14、使用wget -r -A下载指定格式文件
可以在以下情况使用该功能
下载一个网站的所有图片
下载一个网站的所有视频
下载一个网站的所有PDF文件
wget -r -A.pdf url
15、使用wget FTP下载
你可以使用wget来完成ftp链接的下载。
使用wget匿名ftp下载
wget ftp-url
使用wget用户名和密码认证的ftp下载
wget –ftp-user=USERNAME –ftp-password=PASSWORD url
__utm.gif的参数解释,搞明白google怎么做的,好自己弄。。
utmac:GA的站点配置ID
utmcc:GA的cookie值
utmcs:页面html编码
utmdt:页面标题
utmfl:flash版本
utmhid:未知,疑似随机数
utmhn:用户访问的主机名(就是域名)
utmje:用户浏览器是否支持JAVA
utmn:utm.gif唯一的ID编号,用于防止GIF图像被缓存
utmp:当前页面产生的请求,记录你在这个页面的点击行为及其他自定义的返回值
utmr:推介链接的URL
utms:本次会话访问页面的次数
utmsc:用户的屏幕颜色
utmsr:用户屏幕分辨率
utmu:GA内部使用值,用以改进GA的统计,暂时没用
utmul:用户浏览器的语言
utmuwv:Google Analyitcs追踪代码的版本号
其中utmcc是Cookie里存储的数据:
__utma用来分析唯一用户,访问次数,停留时间,新访或回访等等。
__utmz用来记录流量来源。
__utmv存储细分用户所定义的值,一般通过URL Builder生成,用于PPC。
以上这些并不是全部的返回数据,只是Google Analyitcs追踪的基本数据。如果开通了电子商务追踪功能或是自定义了事件追踪。那么在返回Google服务器的链接中就会看到更多的变量值。比如:
utme:事件追踪数据
utmipc:用户购买的产品编号
utmipn:用户购买的产品名称
utmipr:用户购买的产品单价
utmtsp:运费
utmttx:税款
让ultraedit识别模板文件

修改wordfile.txt里面第一行File Extensions = DWT LBI HTM HTML INC PHP3 PHP4 PHP PHTML CLASS TEST
后面加上扩展就ok了,记得重启
php防止洪水攻击 高效代码
如果是分布式的前端,请参考我之前的syslog方式汇总error然后一样可以防止洪水攻击,
这种模式的好处在于对前端已cache的部分不进行计算,反正也压不死,关键在于这些事实在在花费了php资源的.
第一次发布这种大一些代码,有问题请随时提问
http://blog.fabrichina.net/zip/banIp.zip
<?php
/*
* @author Albert
* 2011.8.24
* version 0.1.2
* 处理前端应用发过来的LOG
* serverIn.log : 格式为IP(long) | time() 一行一个
* 分别为1分钟 5 分钟 30分钟设置阀值(在$limit中)
* 使用popen tail -f log文件
*
* 1.分解log 按照时间(分钟) IP
* 2.IP如果在BanIP列表中 ,或者在 whiteIPList中则不继续检查
* 3.按照1 5 30 分别计算每个IP的次数
* 4.超过阀值的IP放入BanList准备写入文件
* 5.每5分钟将BanList写入$banIpLimitDataFile 准备banIpJob进行ban
* 6.每5分钟将$whiteIpLimitDataFile读入白名单,和之前的白名单混合
*
* **************** 使用方法 ***********
* //开启主服务
* nohup /usr/local/php/bin/php banIp.php startService &
* //设置crontab 当服务器访问量非常少的,时候,通过这个程序激活banIp 每分钟统计数据。并不是一定要设置的。
* crontab -e
* * * * * * /usr/local/php/bin/php /home/www/banIp.php Crontab
* ///在php文件中include banIp.php
* 并在执行核心应用时使用
* $banIp->logRequest() 记录用户操作。
* **************** 使用方法介绍结束 ****
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
class banIpClass {
/////Config BanIp应用
Private $limit = array("1" =>40, "5" =>80, "30" =>200); //1分钟 40个请求,5分钟80个请求,30分钟200个请求(可调整)
Private $allowSuffix = array(".googlebot.com", ".yahoo.net", ".search.live.com", ".inktomisearch.com", "msn.com");
Private $phpBin = '/usr/local/php/bin/php';
//定义交互文件
Private $baseDir =false ;
Private $banIpLimitDataFile = "requestLimit.data"; //json串,将Ban IP存在内存文件中,抛送给BanIpJob程序
Private $whiteIpLimitDataFile = "requestwhiteLimit.data"; //BanIpJob回传的白名单
Private $serverLogIn = "serverIn.log"; //应用写入文件
Private $banIpLogFile = 'banIpLog.log'; //写入 Mem Usage: 669.61 kb --- BanListIp --1 --whiteIpList -- 7-
Private $banIpRealBanIP= 'banIpList.log'; //最终的BanIp的列表
//预定义变量
Private $banIpList = array();
Private $whiteIpList = array('0.0.0.0'=>1); //默认一个ip这个ip是sysCrontab插入的,每分钟插入一个,用以激活计算循环有一定流量的网站不用这条
Private $banIpLogOnce = false;
////获取程序允许的目录////////////
Protected function getDir() {
if(!$this->baseDir)
$this->baseDir=rtrim(dirname(__FILE__), '/\\') . DIRECTORY_SEPARATOR ;
return $this->baseDir;
}
////按照1 5 30分钟来算
Protected function returnData($time) {
return array("1" =>$time, "5" =>intval($time/5), "30" =>intval($time/30));
}
////内存转化显示
Protected function memConvert($size) {
$unit = array('b', 'kb', 'mb', 'gb', 'tb', 'pb');
return @round($size/pow(1024, ($i = floor(log($size, 1024)))), 2).' '.$unit[$i];
}
///系统job 用于流量比较小的网站,无法保证每分钟有一个请求
Public function sysCrontabe() {
error_log('0.0.0.0|'.intval(time()/60)."\r\n", 3, $this->getDir().$this->serverLogIn ); //每分钟系统crontab调用一次
}
///正式的banIp Service 函数,处理调用的log数据,算出那些ip准备ban并忽略白名单ip
Public function banIpService() {
$tmpBanIpList = array();
if(!is_file($this->getDir().$this->serverLogIn)) die("没有找到数据文件,请先调用logRequest() 函数获取数据\r\n");
$tailLog = popen("tail -0f ".$this->getDir().$this->serverLogIn, "r"); //使用popen 链接tail方法,性能还是不错的 使用0f是为了避免之前的数据影响分析
if ($tailLog) {
while (1) {
$data = explode("|", trim(fgets($tailLog)));
if(isset($data[1]) && is_numeric($data[1])) {
if(!isset($nowCheck)) {
$nowCheck = $this-> returnData($data[1]);
}
$ipLong = ip2long($data[0]);
//==========================================================================
if(isset($this->banIpList[$ipLong])||isset($this->whiteIpList[$ipLong])) continue; //已经ban了或者已经是白名单了。
$tmp = $this->returnData($data[1]);
foreach(array("1", "5", "30") as $interval) {
if($tmp[$interval]!= $nowCheck[$interval]) {
unset($ipList[$interval][$nowCheck[$interval]]); //释放内存
$nowCheck[$interval] = $tmp[$interval];
if($interval == 5) { //过了5分钟了,开始操作ban记录
if(!is_file($this->getDir().$this->banIpLimitDataFile)&& count($this->banIpList)>0 ) { //文件不存在的时候再创建
file_put_contents($this->getDir().$this->banIpLimitDataFile, json_encode($this->banIpList));
$tmpBanIpList = $this->banIpList;
$this->banIpList = array(); //清除了,应该已经发送ban IP的指令了,如果不能ban Ip也发回white IP了。
}
if(is_file($this->getDir().$this->whiteIpLimitDataFile)) { //文件存在的时候开始
$tmpw = json_decode(file_get_contents($this->getDir().$this->whiteIpLimitDataFile), true);
foreach($tmpw as $perIpListV => $perTmpe)
$this->whiteIpList[$perIpListV] = 1;
@unlink ($this->getDir().$this->whiteIpLimitDataFile) ; //删除这个白名单文件,因为已经读到内存中了
}
//========================输出log===========================
$logStr = "Mem Usage: ".$this->memConvert(memory_get_usage())." --- BanListIp --".count($tmpBanIpList)." --whiteIpList -- ".count($this->whiteIpList)."-\r\n";
error_log($logStr, 3, $this->getDir().$this->banIpLogFile); //写入log
exec($this->phpBin .' '.__FILE__." BanJob");
}
}
if(isset($ipList[$interval][$nowCheck[$interval]][$ipLong])) {
$ipList[$interval][$nowCheck[$interval]][$ipLong]++;
if($ipList[$interval][$nowCheck[$interval]][$ipLong] > $this->limit[$interval])
$this->banIpList[$ipLong] = $interval;
}
else $ipList[$interval][$nowCheck[$interval]][$ipLong] = 1;
}
}
}
fclose($handle);
}
} //close banIpService
// 获取执行人IP
Protected function get_real_ip() {
$ip = false;
//注意HTTP_X_FORWARDED_FOR可以被欺诈,我这么用是因为前面有cdn不怕,但是正常情况下请优先remote_addr
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode (", " , $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach($ips as $perIp) {
if ( $this->check_ip( trim($perIp) ) ) {
$ip = trim($perIp);
break;
}
}
}
if( $ip === false && !empty($_SERVER["HTTP_CLIENT_IP"]) && $this->check_ip($_SERVER["HTTP_CLIENT_IP"])) {
$ip = trim($_SERVER["HTTP_CLIENT_IP"]);
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
//检查ip是否是内部ip
Protected function check_ip($ip) {
return !preg_match("/^(10|172.16|192.168|127.0.0)./" , trim( $ip ) );
}
//记录外部请求共service分析
Public function logRequest() {
if($this->banIpLogOnce) return;
else $this->banIpLogOnce = true; //保证logRequest 在一次请求中只记录一次
error_log($this->get_real_ip().'|'.intval(time()/60)."\r\n", 3, $this->getDir().$this->serverLogIn ); //每次php核心应用都要保证调用这里
}
//这个函数将被 banIpService 所调用
Public function banIpJob() {
if(!is_file($this->getDir().$this->banIpLimitDataFile)) die; //前端指令未下达,所以我也不用执行
$banIpList = json_decode(file_get_contents($this->getDir().$this->banIpLimitDataFile), true);
$whiteIpList=array();
$ban = 0;
foreach($banIpList as $perIp => $perRes) {
$host = gethostbyaddr(long2ip($perIp));
if($this->checkHost($host)) { //是被允许的后缀,说明他是正常的搜索机器人
$whiteIpList[$perIp] = 1; //添加到白名单去
}
else { //否则,就真干掉了!
exec("iptables -I INPUT -s ".long2ip($perIp)." -j DROP"); //干掉 要注意,这个一定是root身份执行,否则不会成功
error_log(long2ip($perIp)."|".date(DATE_RFC822)."\r\n", 3, $this->getDir().$this->banIpRealBanIP);
$ban++;
}
}
if(count($whiteIpList)>0) {
file_put_contents($this->getDir().$this->whiteIpLimitDataFile, json_encode($whiteIpList));
}
error_log("BanIpJob--BanIP:".$ban." WhiteIp:".count($whiteIpList)."\r\n", 3,$this->getDir().$this->banIpLogFile );
@unlink($this->getDir().$this->banIpLimitDataFile); //删掉这个文件以后,下一个文件才能送下来。否则会暂存在banIp文件(内存) 中
}
//检查host是不是再被可允许范围内
Protected function checkHost($host) {
foreach($this->allowSuffix as $perSuffix) {
if(substr($host, (0-strlen($perSuffix))) == $perSuffix)
return true;
}
return false;
}
} //close Class
$banIp = new banIpClass();
//$banIp->logRequest(); include 这个文件以后,可以直接调用这个函数记录。
if(isset($argv[1]) && trim($argv[1]) == 'serviceStart') { //使用php banIp.php serviceStart 指令来启动
$banIp->banIpService();
}
elseif(isset($argv[1]) && trim($argv[1]) == 'BanJob') { //5分钟启动一次job 进行iptables的ban操作
$banIp->banIpJob();
}
elseif(isset($argv[1]) && trim($argv[1]) == 'Crontab') { //crontab -e 定义* * * * * /usr/local/php/bin/php banIp.php Crontab
$banIp->sysCrontabe();
}
一个改良的realIp 获取函数
function get_real_ip() {
$ip=false;
if (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) {
$ips = explode ("," , $_SERVER['HTTP_X_FORWARDED_FOR']);
foreach($ips as $perIp) {
if ( check_ip( trim($perIp) ) ) {
$ip = trim($perIp);
break;
}
}
}
if( $ip === false && !empty($_SERVER["HTTP_CLIENT_IP"]) && check_ip($_SERVER["HTTP_CLIENT_IP"])) {
$ip = trim($_SERVER["HTTP_CLIENT_IP"]);
}
return ($ip ? $ip : $_SERVER['REMOTE_ADDR']);
}
function check_ip($ip) {
return !preg_match("/^(10|172.16|192.168|127.0.0)./" , trim( $ip ) );
}
echo get_real_ip();
禁止和放出某些ip
iptables -I INPUT -s 10.10.10.10 -j DROP
iptables -D INPUT -s 10.10.10.10 -j DROP
通过gethostbyaddr函数检测这个ip是不是google yahoo msn
Google:主机名称应包含于googlebot.com域名中,如:crawl-66-249-66-1.googlebot.com;
MSN:主机名称应包含于search.live.com域名中,如:livebot-207-46-98-149.search.live.com;
Yahoo:主机名称应包含于inktomisearch.com域名中,如:ab1164.inktomisearch.com。
yahoo :我监控到的还有 b3090878.crawl.yahoo.net
ultraedit 语法着色php5.0
http://sourceforge.net/project/showfiles.php?group_id=24036
吧wordfiles.txt copy过去
ab apr_socket_recv: Connection timed out 报错解决
修改源代码中
support/ab.c
if (recverrok) {
bad++;
close_connection(c);
if (verbosity >= 1) {
char buf[120];
fprintf(stderr,”%s: %s (%d)\n”, “apr_socket_recv”, apr_strerror(status, buf, sizeof buf), status);
}
return;
} else {
bad++; //新添加的
close_connection(c); //新添加的
//apr_err(“apr_socket_recv”, status); //修改了这里
}
重新编译apache ab就不怕报错了。。
解决Smarty 劫持__autoload()的问题
Smarty 3.x以后的版本,都会劫持__autoload 这样会让我们自己的代码有问题
首先,在include smarty.class.php之前先define(‘SMARTY_SPL_AUTOLOAD’,1);
如果这样还不行
请修改smarty.class.php 寻找registeredAutoLoadFunctions
将下面的代码改成
if (SMARTY_SPL_AUTOLOAD && set_include_path(get_include_path() . PATH_SEPARATOR . SMARTY_SYSPLUGINS_DIR) !== false) {
$registeredAutoLoadFunctions = spl_autoload_functions();
spl_autoload_register(‘smartyAutoload’);
spl_autoload_register(‘__autoload’);
}
当然,你要确认你的php是5.3.x如果不是,请升级你的php版本
还有,上面的这段hack代码实际上并不是smarty的本意,但是我用它原始方式总是报错在spl_autoload()这个函数上。
/*
if (!isset($registeredAutoLoadFunctions['spl_autoload'])) {
spl_autoload_register();
}
} else {
spl_autoload_register(‘smartyAutoload’);
}
*/
tomcat 7 VS Solr 安装
1:下载core的包.tomcat
apache-tomcat-7.0.16.tar.gz
2:tar -zxvf apache-tomcat-7.0.16.tar.gz
3:mv apache-tomcat-7.0.16 /usr/local/tomcat
4:vi /usr/local/tomcat/catalina.sh
5:在第一行加上 : export JAVA_OPTS=”$JAVA_OPTS -Dsolr.solr.home=/usr/local/solr/example/solr”
6: 把solr/example/webapps/solr.war 拷贝到tomcat/webapps下
6:./bin/startup.sh
错误,看/usr/local/tomcat/logs/catalina.out
Recent Comments