作者:freethy 发布于:2012-12-28 17:27 Friday
1. 建立两个用户分别用于访问两个不同的站点.
# useradd -M www -s /sbin/nologin
# useradd -M www2 -s /sbin/nologin
2. 建立两个站点的目录
# mkdir -p /web/667
# mkdir -p /web/668
# chown
www.www -R /web/667
# chown www2.www2 -R /web/668
# chmod 555 -R /web/667
# chmod 555 -R /web/668
可写目录,给755.在nginx中屏蔽不能执行php
3. php-fpm.conf设置两个应用程序池
[www]
listen = 127.0.0.1:9000
listen.backlog = -1
user = www
group = www
pm = static
pm.max_children = 5
pm.start_servers =20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
request_terminate_timeout = 0s
request_slowlog_timeout = 0s
rlimit_files = 1024
rlimit_core = 0
catch_workers_output = yes
[www2]
listen = 127.0.0.1:9001
listen.backlog = -1
user = www2
group = www2
pm = static
pm.max_children = 5
pm.start_servers =20
pm.min_spare_servers = 5
pm.max_spare_servers = 35
pm.max_requests = 500
request_terminate_timeout = 0s
request_slowlog_timeout = 0s
rlimit_files = 1024
rlimit_core = 0
catch_workers_output = yes
4. nginx.conf配置站点
server {
listen 80;
server_name 667.com;
location / {
root /web/667/;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /web/667/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
server {
listen 80;
server_name 668.com;
location / {
root /web/668/;
index index.php index.html index.htm;
}
location ~ ^/uploads/ {
}
location ~ \.php$ {
root /web/668/;
fastcgi_pass 127.0.0.1:9001;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
评论(24)
引用(0)
浏览(2880)
作者:freethy 发布于:2012-12-26 15:24 Wednesday
WinCE5.0模拟器下载:WinCE5模拟器
补充:
1、ActiveSync无法连接到WinCE模拟器的问题
有时候出现可能出现ActiveSync无法连接WinCE模拟器,可以采用如下方法解决:
1)WinCE模拟器中,开始->设置->拨号和网络连接;新建连接“我的连接”,连接类型选择“直接连接”;下一步,选择设备“Serial over DMA”,完成
2)WinCE模拟器中,开始->设置->控制面板->PC 连接;更改连接方式为“我的连接”
3)ActiveSync中,连接设置,选中”允许USB连接”,”允许连接到以下任一端口”设置为“DMA”,”这台计算机已连接到”设置为“自动”,选中“允许自动设备身份验证”,点确定。
若”允许连接到以下任一端口”已设置为“DMA”,可以改变一下,点确定。再重新设置为“DMA”,再点确定,以触发设置变更。
4)点击VS工具->设备仿真器器管理器->刷新->选择最下面其他wince->右键插入底座
即可连接
评论(12)
引用(0)
浏览(2939)
作者:freethy 发布于:2012-12-23 23:43 Sunday
#region 获取整数的某一位,设置整数的某一位
/// <summary>
/// 取十进制整数位的值
/// </summary>
/// <param name="_Resource"></param>
/// <param name="_Mask"></param>
/// <returns></returns>
public static int GetIntBit(int num, int _mask)
{
return num >> _mask & 1;
}
/// <summary>
/// 将十进制整数的某位置为0或1
/// </summary>
/// <param name="_Mask">整数的某位</param>
/// <param name="a">整数</param>
/// <param name="flag">是否置1,TURE表示置1,FALSE表示置0</param>
/// <returns>返回修改过的值</returns>
public static int SetIntBit(int _mask, int a, bool flag)
{
if (flag)
{
a |= (0x1 << _mask);
}
else
{
a &= ~(0x1 << _mask);
}
return a;
}
#endregion
评论(20)
引用(0)
浏览(5319)
作者:freethy 发布于:2012-12-23 23:42 Sunday
在使用C#做协议解释程序的时候,经常有一些数据,是以十六进制表示的,并且用ascii,或者utf-8之类的字符编码过的,收到这些消息后,经常要将这些信息解释成有意义的十进制信息
最近经常用到,所在这里备注一下,这个是从微软的网站上转载地
原文地址:
string testHex = "200300C6";
Console.WriteLine( Int32.Parse(testHex,System.Globalization.NumberStyles.AllowHexSpecifier) );
令外在使用过程中也需要使用C#将字符串,转化为日期时间
string testDate = "091029075541";
Console.WriteLine(DateTime.ParseExact(testDate, "yyMMddHHmmss", null));
以下的未经过验证
DateTime dt = DateTime.ParseExact("15:35:05", "HH:mm:ss", null);
DateTime dt = DateTime.ParseExact(DateTime.Now.ToString("yyyy-MM-dd ") + "15:35:05", "yyyy-MM-dd HH:mm:ss", null);
DateTime dt = Convert.toDateTime(str,"yyyy-MM-dd HH:mm:ss")
评论(25)
引用(0)
浏览(5892)
作者:freethy 发布于:2012-12-23 20:51 Sunday
在WindowsCE上很好用的注册表操作工具
DM.zip
评论(0)
引用(0)
浏览(2287)
作者:freethy 发布于:2012-12-23 17:20 Sunday
using System;
using System.Text.RegularExpressions;
using System.IO;
using System.Text;
using System.Net;
using System.IO.Compression;
using System.Web;
using System.Collections;
namespace 控制台测试
{
class Program
{
static void Main(string[] args)
{
byte[] buffer = getBytes("http://video.shishicai.cn/haoma/cqssc/list/120.aspx", null, null);
string html = Encoding.UTF8.GetString(buffer);
MatchCollection mc= Regex.Matches(html, @"{""BonusNumberString"":""(?[^|]*)\|\d\|\d"",""BonusTime"":""(?[^""]*)"",""IssueNumber"":""(?[^""]*)""}");
foreach (Match m in mc)
{
Console.WriteLine(m.Groups["qi"] + " " + m.Groups["num"].Value.Replace(",", " ") + " " + m.Groups["kai"]);
}
Console.WriteLine("程序运行结束,按任意键关闭窗口!");
Console.ReadKey();
}
// 读取网络资源,返回字节数组
private static byte[] getBytes(string url, CookieContainer cookie, byte[] postData)
{
int c = url.IndexOf("/", 10);
byte[] data = null;
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.AllowAutoRedirect = true;
if (cookie != null) request.CookieContainer = cookie;
request.Referer = (c > 0 ? url.Substring(0, c) : url);
request.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)";
request.Headers[HttpRequestHeader.AcceptEncoding] = "gzip, deflate";
if (postData != null) // 需要 Post 数据
{
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(postData, 0, postData.Length);
requestStream.Close();
}
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
string ce = response.Headers[HttpResponseHeader.ContentEncoding];
int ContentLength = (int)response.ContentLength;
Stream s = response.GetResponseStream();
c = 1024 * 10;
if (ContentLength < 0) // 不能获取数据的长度
{
data = new byte[c];
MemoryStream ms = new MemoryStream();
int l = s.Read(data, 0, c);
while (l > 0)
{
ms.Write(data, 0, l);
l = s.Read(data, 0, c);
}
data = ms.ToArray();
ms.Close();
}
else // 数据长度已知
{
data = new byte[ContentLength];
int pos = 0;
while (ContentLength > 0)
{
int l = s.Read(data, pos, ContentLength);
pos += l;
ContentLength -= l;
}
}
s.Close();
response.Close();
if (ce == "gzip") // 若数据是压缩格式,则要进行解压
{
MemoryStream js = new MemoryStream(); // 解压后的流
MemoryStream ms = new MemoryStream(data); // 用于解压的流
GZipStream g = new GZipStream(ms, CompressionMode.Decompress);
byte[] buffer = new byte[c]; // 读数据缓冲区
int l = g.Read(buffer, 0, c); // 一次读 10K
while (l > 0)
{
js.Write(buffer, 0, l);
l = g.Read(buffer, 0, c);
}
g.Close();
ms.Close();
data = js.ToArray();
js.Close();
}
return data; // 返回字节数组
}
}
}
评论(49)
引用(0)
浏览(3716)
作者:freethy 发布于:2012-12-19 9:27 Wednesday
开发环境:
FL2440开发板 Wince5.0 .net2.0
现在的连接情况:某传感器(TTL电平)<——>(TTL电平)MAX3232模块(RS232)<——>FL2440(RS232)串口
此连接方式 软件收发数据一切正常
现在希望降低功耗,增加稳定性,减少成本,精简掉 MAX3232模块
改成此连接:某传感器(TTL电平)<——>FL2440(TTL)串口
此连接已经多次尝试,串口也选择正确,均无法收发数据
看了一些帖子说要删除某注册表红外部分,折腾了两天没搞懂。
后来发现重刷光盘下三个串口wince系统TTL串口就可以了
评论(90)
引用(0)
浏览(5178)
作者:freethy 发布于:2012-12-14 14:49 Friday
--by freethy
--201200924
declare @dbname varchar(max)
declare @path varchar(max)
set @path = ''E:\\DataBaseBackUp''
--删除n天之前的冗余
DECLARE @OLDDATE DATETIME
SELECT @OLDDATE=GETDATE()-5
EXECUTE master.dbo.xp_delete_file 0,N''E:\\DataBaseBackUp'',N''bak'',@OLDDATE
--定义游标
Declare cur_backup Cursor
For Select [Name] From Master..SysDatabases where [Name] not in (''master'', ''model'', ''msdb'', ''tempdb'', ''Northwind'', ''pubs'')
--创建游标
Open cur_backup
--移动或提取列值
Fetch From cur_backup into @dbname
--利用循环处理游标中的列值
While @@Fetch_Status=0
Begin
--备份数据库
declare @strPath varchar(max)
set @strPath = @path + ''\\'' + convert(NVARCHAR(8),getdate(),112) + ''-'' + @dbname + ''.bak''
BACKUP DATABASE @dbname TO DISK = @strPath WITH NOINIT , NOUNLOAD , NOSKIP , STATS = 10, NOFORMAT
Print @strPath
Fetch From cur_backup into @dbname
End
--关闭/释放游标
Close cur_backup
Deallocate cur_backup
评论(5)
引用(0)
浏览(2428)
作者:freethy 发布于:2012-12-14 10:23 Friday
568A双绞线(双机交叉直连线)
接线法一头:白橙,橙,白绿,蓝,白蓝,绿,白褐,褐
另一头:白绿,绿,白橙,蓝,白蓝,橙,白褐,褐
评论(0)
引用(0)
浏览(2087)
作者:freethy 发布于:2012-12-13 15:03 Thursday
INSERT INTO `qb_buy_sort` ( `fid` , `fup` , `name` ,
`type` ,
`template` , `mid` , `class` , `descrip` , `config` )
SELECT `fid` , `fup` , `name` ,
`type` ,
`template` , `mid` , `class` , `descrip` , `config`
FROM `qb_sell_sort`
评论(0)
引用(0)
浏览(2243)