no comments yet
20 Mar 2019

/bin/sh^M: bad interpreter: No such file or directory解决办法

这个问题是因为.sh脚本在windows系统下用记事本文件编写,不同系统的编码格式差异所造成的。
解决方法:修改.sh文件格式。

vi test.sh

输入:set fileformat,可以看到显示fileformat=dos
输入:set fileformat=unix,再输入:wq就行了。

no comments yet
18 Mar 2019

Ubuntu安装LXDE桌面环境

#升级
apt-get update -y
apt-get upgrade -y

#安装桌面及VNC
apt-get install xorg lxde-core tightvncserver -y

#启动VNC
tightvncserver :1

Read more

no comments yet
28 Feb 2019

CentOS Linux系统下apache日志文件设置(每天单独生成一个日志文件)

vi /etc/httpd/conf/httpd.conf  #编辑文件
#ErrorLog logs/error_log  #注释此行,添加下面这行
ErrorLog "|rotatelogs /var/log/httpd/error_log%Y%m%d.log 86400 480"  #每天单独生成一个日志文件
#CustomLog logs/access_log common  #注释此行,添加下面这行
CustomLog "|rotatelogs /var/log/httpd/access_log%Y%m%d.log 86400 480" common  #每天单独生成一个日志文件

ErrorLog /dev/null  #禁用错误日志
CustomLog /dev/null common  #禁用访问日志
no comments yet
25 Feb 2019

php中判断字符串是否全是中文或含有中文

<?php
 header('Content-type:text/html; charset=utf-8');
 $str = '你好';
 if(preg_match('/^[\x{4e00}-\x{9fa5}]+$/u', $str)>0){
  echo '全是中文';
 }elseif(preg_match('/[\x{4e00}-\x{9fa5}]/u', $str)>0){
  echo '含有中文';
 }
?>
no comments yet
22 Feb 2019

.htaccess文件实现不带www域名301跳转到带www域名

具体设置如下,利用.htaccess文件来实现:

RewriteEngine on
RewriteCond %{HTTP_HOST} ^yourdomain\.com$ [NC]
RewriteRule ^(.*)$ http://www.yourdomain.com/$1 [L,R=301]

将这段代码的最后两行中的yourdomain换成你的域名。