IE下图片链接有边框的解决办法

分类:网站技术日期:2012-03-04 - 18:28:42评论:20条作者:老谢

今天在修改一个页面,发现ie下显示图片链接有边框,如图所示:

IE下图片链接有边框的解决办法

解决办法如下:

img{ border:none;}

感谢独角鲸

Tags: ,

Nginx提示host not found in upstream

分类:运维技术日期:2012-03-04 - 0:00:36评论:2条作者:老谢

今天对nginx.conf进行修改,保存后进行语法检查,配置应该没问题,但是提示下面的信息,瞬间忧桑了,

nginx: [emerg] host not found in upstream “demo1.xj123.info” in /usr/local/nginx
nginx: configuration file /usr/local/nginx/conf/nginx.conf test failed

其中demo1.xj123.info是我的博客后端之一,从提示的错误和网上搜索一番来看,应该是找不到主机,于是ping了一下demo1.xj123.info,结果是可以ping通,这就令我费解了,而且cat /etc/resolv.conf里面的nameserver是正确的。

实在没头绪了,又敲了一次nginx -t竟然提示成功。

nginx: the configuration file /usr/local/nginx/conf/nginx.conf syntax is ok
nginx: configuration file /usr/local/nginx/conf/nginx.conf test is successful

最后:这个问题就是由于找不到主机导致的,如果担心类似问题,可以修改hosts文件

Nginx 1.1.9配置PHP 5.3.10(php-fpm+fastcgi)

分类:运维技术日期:2012-03-03 - 15:04:43评论:7条作者:老谢

本文只介绍PHP的安装以及整合到Nginx,至于Nginx的安装教程请看:CentOS编译安装Nginx(附:管理脚本)

Nginx 1.1.9配置PHP 5.3.10(php-fpm+fastcgi)

wget http://vps.xj123.info/usr/lamp/php-5.3.10.tar.gz
tar -zxf php-5.3.10.tar.gz
cd php-5.3.10
./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --enable-fpm
make && make install
cp php.ini-production /usr/local/php/etc/php.ini

继续阅读…

Tags: , ,

php获取访问者ip地址

分类:程序设计日期:2012-03-03 - 12:08:45评论:10条作者:老谢

老谢目前需要这个功能来做点小东西,于是就网上找了一番,下面的代码直接复制走即可,如需要自己可以美化一下,摘抄自andrew_659的空间
演示地址http://67.215.236.139/ip.php

<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>公网ip查询</title>
</head>
<body>
<?php
$user_IP = ($_SERVER["HTTP_VIA"]) ? $_SERVER["HTTP_X_FORWARDED_FOR"] : $_SERVER["REMOTE_ADDR"];
$user_IP = ($user_IP) ? $user_IP : $_SERVER["REMOTE_ADDR"];
echo $user_IP."<br>";
?>
</body>
</html>

让vim支持中文编码(GB2312和Unicode编码UTF8)

分类:linux日期:2012-03-02 - 10:32:19评论:4条作者:老谢

有时候一些脚本,网上直接wget,里面有中文注释,这样用vim编辑脚本的时候一堆乱码,就比较蛋痛了!但是又懒得把脚本下载回来,修改后再上传,比较麻烦,于是乎,非常有必要让vim支持中文编码了!

返回自己的主目录,可以直接敲击cd命令,然后ls -al看下有没有.vimrc文件,如果没有就新建,加入下面的两行内容:

let &termencoding=&encoding
set fileencodings=utf-8,gbk,ucs-bom,cp936

保存后,再用vim编辑试试看,UTF8和GB2312都没有问题了!!

指定目录禁止执行php文件

分类:运维技术日期:2012-03-01 - 22:51:31评论:6条作者:老谢

做网站,有些目录必须要有写入权限,网站才能运行,但又担心别有用心的人在该目录上传.php的可执行文件,这样就有安全隐患了,下面例子为如何禁止某个目录执行.php的文件,代码摘自:http://who0168.blog.51cto.com/253401/577309

apache

<Directory /usr/local/apache/htdocs/bbs/data>
php_flag engine off
</Directory>
<Directory ~ "^/home/centos/web/data">
 <Files ~ ".php">
 Order allow,deny
 Deny from all
 </Files>
</Directory>

nginx

location /data/ {
location ~ .*\.(php)?$ {
deny all;
}
}

wordpress文章评论后可见

分类:折腾日期:2012-02-27 - 18:15:33评论:27条作者:老谢

function reply_to_read($atts,$content=null){
    extract(shortcode_atts(array("notice"=>'<span class="reply-to-read">此處內容需要
<a href="'. get_permalink().'#respond" title="評論本文">評論本文</a>後
<a href="javascript:window.location.reload();" 
title="刷新">刷新本頁</a>才能查看.</span>'),$atts));
    $email=null;
    $user_ID=(int)wp_get_current_user()->ID;
    if($user_ID>0){
        $email =  get_userdata($user_ID)->user_email; //如果用戶已登錄,從登錄信息中獲取email
    }else if(isset($_COOKIE['comment_author_email_'.COOKIEHASH])){
        $email=str_replace('%40','@',$_COOKIE['comment_author_email_'.COOKIEHASH]); 
//如果用戶未登錄但電腦上有本站的Cookie信息,從Cookie裏讀取email
    }else{
        return $notice; //無法獲取email,直接返回提示信息
    }
    if(empty($email)){
        return $notice;
    }
    global $wpdb;
    $post_id=get_the_ID(); //文章的ID
    $query="SELECT `comment_ID` 
FROM {$wpdb->comments} WHERE `comment_post_ID`={$post_id} 
and `comment_approved`='1' and `comment_author_email`='{$email}' LIMIT 1";
    if($wpdb->get_results($query)){
        return $content; //查詢到對應的已經審核通過的評論則返回內容
    }else{
        return $notice; //否則返回提示信息
    }
}
 
add_shortcode('reply', 'reply_to_read');

以上代码复制到function.php即可,用法如下:

[reply]评论可见内容[/reply]

原文传送门:http://zuidongting.com/non-plug-ins-to-achieve-the-contents-of-the-article-shows-the-code-reply-share.html

Mysql清理日志文件

分类:运维技术日期:2012-02-25 - 23:12:45评论:16条作者:老谢

Mysql运行中,默认会生成日志,这是众所周知的,而且网上很多网友反映硬盘空间不足了,最后检查都是被mysql的日志占掉了大量的空间,对于这些日志文件,我们应该如何清理呢?

Putty
[root@xj123 data]# ls
micro mysql-bin.000002 mysql-bin.000005 wp
mysql mysql-bin.000003 mysql-bin.index xj123.info.err
mysql-bin.000001 mysql-bin.000004 mysql-bin.000005 xj123.info.pi

[root@xj123 data]# du ./ -h
18M ./wp
168K ./micro
988K ./mysql
120M ./

继续阅读…

Nginx打开目录浏览功能

分类:运维技术日期:2012-02-25 - 11:07:36评论:2条作者:老谢

Apache的目录浏览默认是打开的,而Nginx的目录浏览默认是关闭的,演示传送门 ==> VPS软件下载

要打开该功能,非常简单,只需要添加autoindex on;参数即可,下面是vps.xj123.info的例子:

nginx.conf
server {
listen 80;
server_name vps.xj123.info;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;

location / {
root html/vps;
index index.html index.htm;
}
}

autoindex_exact_size off;
默认为on,显示出文件的确切大小,单位是bytes。
改为off后,显示出文件的大概大小,单位是kB或者MB或者GB

autoindex_localtime on;
默认为off,显示的文件时间为GMT时间。
改为on后,显示的文件时间为文件的服务器时间

Nginx的启动、停止、平滑重启

分类:运维技术日期:2012-02-24 - 22:42:34评论:4条作者:老谢

启动Nginx

/usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

停止Nginx

可以发送向通信号给Nginx主进程的方式来停止Nginx,操作如下:

CentOS release 5.7 (Final)
[root@vps ~]# ps -ef | grep nginx #查询master process主进程号
root 3266 1 0 Feb20 ? 00:00:00 nginx: master process /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf
nobody 3267 3266 0 Feb20 ? 00:00:01 nginx: worker process
root 9282 9239 0 20:51 pts/0 00:00:00 grep nginx
[root@vps ~]# kill -QUIT 3266 #从容停止Nginx

继续阅读…