centos7.0安装mysql5.7

下载mysql源的安装包
mysql源地址
安装源

rpm -ivf mysql-community-release-el7-5.noarch.rpm

安装

yum install mysql-server

然后按下Y就能安装成功了
但是我安装之后不能启动,运行了一下

mysql_secure_installation

会出现一些设置,root密码设置什么的,设置完成之后mysql自己就启动了
但是这个安装的是5.6版本的mysql,我想安装5.7的

yum-config-manager --disable mysql56-community
yum-config-manager --enable mysql57-community-dmr

然后更新一下·

yum update

就是5.7了

php安装5.6

来自于http://www.zabbix.cc/technic/1420/
配置yum源
追加CentOS 6.5的epel及remi源。

# rpm -Uvh http://ftp.iij.ad.jp/pub/linux/fedora/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm

以下是CentOS 7.0的源。

yum install epel-release
rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

使用yum list命令查看可安装的包(Packege)。

# yum list --enablerepo=remi --enablerepo=remi-php56 | grep php

安装PHP5.6
yum源配置好了,下一步就安装PHP5.6。

# yum install --enablerepo=remi --enablerepo=remi-php56 php php-opcache php-devel php-mbstring php-mcrypt php-mysqlnd php-phpunit-PHPUnit php-pecl-xdebug php-pecl-xhprof

用PHP命令查看版本。

[root@www ~]# php --version
PHP 5.6.9 (cli) (built: May 15 2015 09:31:38) 
Copyright (c) 1997-2015 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2015, by Zend Technologies
    with Xdebug v2.3.2, Copyright (c) 2002-2015, by Derick Rethans

在这里安装的版本是PHP5.6.0,细心的用户可能已经发现ZendGuardLoader变成Zend OPcahe了。

对从PHP5.5开始PHP代码缓存从APC变成了Zend OPcache了。

LINUX设置自定义服务(centos6.6)

安装了一个amoeba,这个并不是系统服务,要设置开机启动,于是就去修改/etc/rc.local文件,用了绝对路径,在命令行下测试是可以成功启动的,但是开机不生效,于是想把这个设置成系统的服务,之前没做过,记录下
1.照格式写shell

vi /etc/init.d/amoeba
#!/bin/bash
#
# auditd        This starts and stops auditd
#
# chkconfig: 2345 11 88
# description: This starts the Linux Auditing System Daemon, \
#              which collects security related events in a dedicated \
#              audit log. If this daemon is turned off, audit events \
#              will be sent to syslog.
#
#
######forjava
export JAVA_HOME=/usr/java/jdk1.6.0_45
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
#######

###amoeba
export AMOEBA_HOME=/usr/local/amoeba/
export PATH=$PATH:$AMOEBA_HOME/bin
#######
case "$1" in
start)
        echo "Starting amoeba"
        /usr/local/amoeba/bin/amoeba start &
        ;;

stop)
        echo "Stop amoeba"
        /usr/local/amoeba/bin/amoeba stop
        ;;
restart)
        echo "Stop amoeba..."
        /usr/local/amoeba/bin/amoeba stop
        echo "Starting amoeba"
        /usr/local/amoeba/bin/amoeba start &
        ;;
esac

再配置

chmod +x amoeba #给权限
chkconfig --add amoeba #添加到系统服务

ok

js操作cookie

穿转载自http://www.w3cschool.cc/js/js-cookies.html
//设置cookie,参数依次为,cookie键值,cookie值,cookie时间(代表天数)

        function setCookie(cname,cvalue,exdays){
            var d = new Date();
            d.setTime(d.getTime()+(exdays*24*60*60*1000));
            var expires = "expires="+d.toGMTString();
            document.cookie = cname + "=" + cvalue + "; " + expires;
        }
        //获取cookie
        function getCookie(cname){
            var name = cname + "=";
            var ca = document.cookie.split(';');
            for(var i=0; i<ca.length; i++)
              {
              var c = ca[i].trim();
                if (c.indexOf(name)==0) 
                    return c.substring(name.length,c.length);
              }
            return "zj";
        }
        //删除cookie
        function delCookie (cookie_name) {
            document.cookie = cookie_name+"=; expires=Thu, 01 Jan 1970 00:00:00 GMT";
        }

不知道为什么,今天在本地测,删除cookie是成功的,昨天在服务器上面,删除cookie死活不行,服务器系统也是windows啊。。。。。
昨天不成功解决办法

var date=new Date();
date.setTime(date.getTime()-10000);
document.cookie=cookie_name+"=zj; expire="+date.toGMTString()+"; path=/";

js检测客户端类型并跳转

var bForcepc = fGetQuery("dv") =="pc";
    function fBrowserRedirect(){
        var sUserAgent = navigator.userAgent.toLowerCase();
        var bIsIpad = sUserAgent.match(/ipad/i) =="ipad";
        var bIsIphoneOs = sUserAgent.match(/iphone os/i) =="iphone os";
        var bIsMidp = sUserAgent.match(/midp/i) =="midp";
        var bIsUc7 = sUserAgent.match(/rv:1.2.3.4/i) =="rv:1.2.3.4";
        var bIsUc = sUserAgent.match(/ucweb/i) =="ucweb";
        var bIsAndroid = sUserAgent.match(/android/i) =="android";
        var bIsCE = sUserAgent.match(/windows ce/i) =="windows ce";
        var bIsWM = sUserAgent.match(/windows mobile/i) =="windows mobile";
        if(bIsIpad){
            var sUrl = location.href;
            if(!bForcepc){
                return true;
            }
        }
        if(bIsIphoneOs || bIsAndroid){
            var sUrl = location.href;
            if(!bForcepc){
                return true;
            }
        }
        if(bIsMidp||bIsUc7||bIsUc||bIsCE||bIsWM){
            var sUrl = location.href;
            if(!bForcepc){
                return true;
            }
        }
        return false;
    }
    function fGetQuery(name){//获取参数值
        var sUrl = window.location.search.substr(1);
        var r = sUrl.match(new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"));
        return(r ==null?null: unescape(r[2]));
    }
    function fShowVerBlock(){
        if(bForcepc){
            document.getElementById("dv_block").style.display ="block";
        }
         else{
            document.getElementById("ad_block").style.display ="block";
        }
    }
    if(fBrowserRedirect()){
        if (window.location.host=='www.xxx.com') {
            window.location.href='http://m.xxx.com'+window.location.href.substr(window.location.href.indexOf(window.location.host)+window.location.host.length,window.location.href.length);
        };
    }else{
        if (window.location.host=='m.xxx.com') {
            window.location.href='http://www.xxx.com'+window.location.href.substr(window.location.href.indexOf(window.location.host)+window.location.host.length,window.location.href.length);
        };
}

apache重写模块学习(3)

对YYYY转变为XXXX的向前兼容

描述:
在转变了大批document.YYYY文件为document.XXXX后(比如.html→.phtml),如何保持URL的向前兼容(仍然虚拟地存在)?
解决方案:
只须按基准文件名重写,并测试带有新的扩展名的文件是否存在,如果存在则用新的,否则仍然用原来的。

将document.html重写为document.phtml的向后兼容的规则集
当且仅当document.phtml存在且document.html不存在的时候
RewriteEngine on
RewriteBase /~quux/
# 剪切并记住basename
RewriteRule ^(.*)\.html$ $1 [C,E=WasHTML:yes]
# 如果存在的话就重写为document.phtml
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule ^(.*)$ $1.phtml [S=1]
# 否则返回先前的basename
RewriteCond %{ENV:WasHTML} ^yes$
RewriteRule ^(.*)$ $1.html

昨天在家里安装例子配置的死活不行,后来还是改动了下代码才实现的

RewriteEngine on
#RewriteCond %{EVN:html} !^ok$
RewriteRule ^(.*)\.html $1 [C,E=html:ok]
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule (.*) $1.phtml [S=1]
#RewriteBase /mod_rewrite_test/
RewriteCond %{REQUEST_FILENAME}.html -f
RewriteRule (.*) $1.html 

今天来公司,试试,竟然是ok的。。。,贴上公司代码

RewriteEngine on
RewriteBase /
# 剪切并记住basename
RewriteRule ^(.*)\.html$ $1 [C,E=html:yes]
# 如果存在的话就重写为document.phtml
RewriteCond %{REQUEST_FILENAME}.phtml -f
RewriteRule ^(.*)$ $1.phtml [S=1]
# 否则返回先前的basename
RewriteCond %{ENV:html} ^yes$
RewriteRule ^(.*)$ $1.html

公司和家里不同的地方是,xampps,公司是用的wampserver,不知道是不是apache版本的不同。。。。或者是其他的什么原因。。。
在公司配置的时候,是成功了,但是,.phtml的文件的html标签不会被解析成html标签,会原样输出,找的的解决办法是
打到Apache主配置文件,搜索“AddType text/html .shtml”:

#AddType text/html .shtml .html .htm  
#AddOutputFilter INCLUDES .shtml .html .htm  

把这两行前面的#去掉。然后重启Apache,可以解析html文件了。
没有按照上面的做,而是另起了一行

AddType text/html .phtml

再在公司电脑上面安装了同一个版本的xampps,也是ok的。。。。。。估计是昨天哪里写的不对

新旧文件的替换
http://test.com/a.html,访问这个网址的时候,正常应该访问网站根目录下的a.html文件,但是需要一个效果,在访问上面url的时候,实际访问的是网站根目录下的b.html文件代码如下

RewriteEngine on
RewriteRule ^a\.html$ b.html 

上面这样的是可以的,并且浏览器的url也不会改变,依然是http://test.com/a.html,但是如果想要在访问的文件改变的同时,使浏览器的url也发生变化,那就需要重定向的指令
代码如下

RewriteEngine on
RewriteRule ^a\.html$ b.html [R]

可是这句代码报错了,并且浏览器的url变成了http://test.com/D:/xampps/htdocs/test/b.html
然后加上***rewrite base / *** 就是ok的了
结合http://apache.jz123.cn/rewrite/rewrite_tech.html的说明,我想,在进入目录级的htaccess文件下的处理的时候,其实url已经转换成文件实际路径了,在进行替换也是对文件路径的替换,而不是替换url,所以才会出现在重定向的时候,url里面包含的是文件的路径,加上rewrite base之后,在进入的htaccess文件的时候,路径会被转变回url,再进行替换,就是ok的了,rewrite base 还有就是会加在重写后的url前面