2018年1月

PHP获取上一个月 下一个月

如果当前为2018-01-29则通过echo date("Y-m",strtotime("+1 month"));则会得出3月的错误结果

function GetMonth($sign="1")  
{  
    //得到系统的年月  
    $tmp_date=date("Ym");  
    //切割出年份  
    $tmp_year=substr($tmp_date,0,4);  
    //切割出月份  
    $tmp_mon =substr($tmp_date,4,2);  
    $tmp_nextmonth=mktime(0,0,0,$tmp_mon+1,1,$tmp_year);  
    $tmp_forwardmonth=mktime(0,0,0,$tmp_mon-1,1,$tmp_year);  
    if($sign==0){  
        //得到当前月的下一个月   
        return $fm_next_month=date("Ym",$tmp_nextmonth);          
    }else{  
        //得到当前月的上一个月   
        return $fm_forward_month=date("Ym",$tmp_forwardmonth);           
    }  
}  

echo GetMonth('0');

ubuntu16.04安装后耳机无声音 双屏无显示

双屏无显示问题需要安装英伟达驱动即可,搜索“附加驱动”即可安装
声音解决:
下载pulseaudio音量控制软件
sudo apt install pavucontrol
终端输入:pavucontrol

配置:HDA NVidia 侧写改为“关”,内置音频“模拟立体声双工”
输出设备 port设置为“模拟耳机”

将httpd/apache设为自启动 httpd 服务不支持 chkconfig

将apache添加为开机启动有两个方法:
1、在/etc/rc.d/rc.local内加入启动命令 /usr/local/apache2/bin/apachectl start
2、将http添加为系统服务
cp /usr/local/apache2/bin/apachectl /etc/rc.d/init.d/httpd
chmod +x /etc/rc.d/init.d/httpd

chkconfig --add httpd

chkconfig --list|grep httpd

httpd 服务不支持 chkconfig
vi /etc/rc.d/init.d/httpd

添加

#!/bin/bash
#chkconfig:345 61 61   //此行的345参数表示,在哪些运行级别启动,启动序号(S61);关闭序号(K61)
#description:Apache httpd   //此行必写,描述服务.

linux中升级python版本

不建议直接覆盖升级系统python版本。服务器默认版本为2.6.6,升级到2.7.14
cd /usr/local/src
wget http://www.python.org/ftp/python/2.7.3/Python-2.7.14.tgz
tar -zxvf Python-2.7.3.tgz
cd Python-2.7.14
mkdir /usr/local/python27
./configure --prefix=/usr/local/python27
make && make install
此处直接将新版本定义为python27
如需定义为python则拷贝旧python并修改对应/usr/bin/yum为对应旧版本python
ln -s /usr/local/python27/bin/python2.7 /usr/bin/python27