Submitted by gouki on 2014, July 28, 11:35 PM
今天被两个问题搞死
1、加载hprose.phar/HproseHttpServer.php一直报文件找不到:Warning: include(./hprose.phar/HproseHttpServer.php): failed to open stream: No such file or directory
2、定义了Yii的errorHandler和error的Controller结果死活不对。
解决:
1、居然是忘了phar在include的时候要申明协议,即include('hprose.phar/xxx.php')是不对的。必须要include("phar://hprose.phar/xxx.php");
该死的,居然忘了这个,命令行下写代码,总是搞错东西
2、这个问题说实在的。真TMD操蛋,我是想偷懒的,所以就加载了yiit.php。。想着这是个lite的文件,应该没啥问题啊?结果,就是因为加载的yiit.php而不是yii.php搞得我在那里折腾了半天。真是要人命啊
果然就象老王说的,每一个找寻半天不得结果的BUG后面,都有一个令人啼笑皆非的原因
PHP | 评论:0
| 阅读:15286
Submitted by gouki on 2014, July 18, 8:50 AM
说起curl请求https的网站,网上的教程很多,无非都是说在你没有证书的情况下,加上下面两句就可以了
PHP代码
- <?php
- curl_setopt_array($handle, array(
- CURLOPT_SSL_VERIFYPEER => false,
- CURLOPT_SSL_VERIFYHOST => false,
-
- ));
诚然,很多人在这么处理后就OK了,但我遇到的情况不一样,这两个加上之后,还是不能访问。
于是问了vampire,他让我试了一下在命令行下加参数访问,如:curl -3 https://xxxxx.com,顺利的得到了结果,https还是有version的。于是在上述的脚本里再加上一句:
PHP代码
- CURLOPT_SSLVERSION => 3,
指定sslversion。
当然,这个值 不一定是3,只是我正好是在version为3的情况下访问正常罢了。实际情况还需实际对待。
话说回来,我在curl在访问的时候报的错是:
XML/HTML代码
- curl: (35) error:14077458:SSL routines:SSL23_GET_SERVER_HELLO:reason(1112)
Over。
PHP | 评论:0
| 阅读:15643
Submitted by gouki on 2014, July 5, 12:04 AM
最近涉及到的项目中用到了thinkphp,我都N年没有碰过这玩意了。但现在还是需要用一用。正好那些能够下载得到的wxcms也可以用这个来优化一下性能。。其实我就一台服务器。装逼而已
于是转一下别人的文章,因为他其中特别写了一句:只要是exec就一定从主库走,query一定从从库走。所以建议query中不要有实际的更新和插入操作。以防万一
原文地址:http://www.verydemo.com/demo_c327_i782.html
前言:
Thinkphp 框架本身是支持读写分离的,如何做呢?
最简单的做法是在配置文件中修改:
PHP代码
- 'DB_TYPE'=> 'mysql',
- 'DB_DEPLOY_TYPE' => 1,
- 'DB_RW_SEPARATE'=>true,
- 'DB_HOST'=> '192.168.100.78,192.168.100.60',
- 'DB_NAME'=>'test',
- 'DB_USER'=>'root',
- 'DB_PWD'=>'root',
- 'DB_PREFIX' => 'fav_',
默认第一台数据库78是主数据库,负责写入操作,第二台60负责读操作,Thinkphp 会自动识别读和写,然后分配链接对应的数据库,来达到读写分离的效果。
注意事项:
1. 如果要设置分布式数据库,暂时不支持DB_DSN方式配置。
2.如果你当前采用了分布式数据库,并且设置了读写分离的话,query方法始终是在读服务器执行,因此query方法对应的都是读操作,而不管你的SQL语句是什么。
3.如果你当前采用了分布式数据库,并且设置了读写分离的话,execute方法始终是在写服务器执行,因此execute方法对应的都是写操作,而不管你的SQL语句是什么。
因此,'DB_DSN'=> 'mysql:host=192.168.100.60;dbname=51fanli_cang', 这种方式不支持主从分离,需要改。
当采用原生态的sql语句进行写入操作的时候,要用execute,读操作要用query,切记,否则乱掉了。
搞定!
---EOF---
Tags: thinkphp
PHP | 评论:0
| 阅读:22720
Submitted by gouki on 2014, June 5, 4:58 PM
我在上一篇博客在centos下处理PHP+WebSphere客户端中提到了一个英文网站:http://blog.phpdeveloper.org/?p=140,我也是参考它才完成了最终的配置,为此我也写了中文的说明,但感觉文笔不行,所以我还是贴上原文吧:
During a recent project at work I had to get PHP linked with IBM’s WebSPhere MQ software we have running on another internal server. Our goal was to use our existing web service to take the requests from external vendors and push their XML data back into the queue inside our firewall. Thankfully there’s an extension in PECL that does just that.
Here’s the basic steps I took – hopefully it’ll be useful to someone else out there in the same spot I was. This all assumes you’re working on a web server that doesn’t have an MQ server installed already:
- Get the extension: Head over to the PECL page for mqseries and download the latest version. Unpack it into a directory on your local server
- Get the MQ client libs: You’ll need to go to IBM’s website to download the latest client/libraries for your install (you’ll need an IBM ID to get to the downloads):
- Go to the IBM page for the MQ client listing
- Look for the “WebSphere MQ Clients” link under the “Related products and technologies” section and click on it
- Scroll down to the “Download Package” section and choose from one of the mirror locations
- Select your package from the list (I went with “Linux for System x86″ for our setup)
- Click on the download link and fill out some required information (you didn’t think you were getting off that easy, did you?)
- Agree to the terms and conditions and you’ll get a “Download Now” link
- Drop the archive file (tar, tar.gz, etc) into your server and unpack into a temporary directory (mine had an issue unpacking into the local directory, not a subdirectory)
- Install the package(s): Once you have the IBM software extracted, you should have a series of packages. You’ll need to install the “MQSeriesSDK” to get the right libraries in place to compile the PHP extension
- Build the mqseries extension: Go into the mqseries directory and run “phpize”, “./configure” and “make” to create the .so file. The process should drop it into the default extensions directory.
- If needed, move it: Be sure that the shared module for the extension is in the right directory for the PHP install to find it. (You can make a phpinfo() page if you’re not sure where that is.)
- Update your php.ini: Add in a line to include the extension in your current setup. Remember, after any changes to the php.ini, you need to restart the web server.
Now for the fun part – if everything’s working and the extension shows up in your phpinfo() as active, give this script a shot and see if you can connect to your MQ server:
1 |
$mq_host_ip = '127.0.0.1' ; |
2 |
$queue_name = 'HOST.REMOTE.Q' ; |
3 |
$mq_server = 'WBRK_QM_U49' ; |
5 |
'Version' => MQSERIES_MQCNO_VERSION_2, |
6 |
'Options' => MQSERIES_MQCNO_STANDARD_BINDING, |
8 |
'ChannelName' => 'CLIENT.CHANNEL' , |
9 |
'ConnectionName' => $mq_host_ip , |
10 |
'TransportType' => MQSERIES_MQXPT_TCP |
15 |
mqseries_connx( $mq_server , $mqcno , $conn , $comp_code , $reason ); |
16 |
if ( $comp_code !== MQSERIES_MQCC_OK) { |
17 |
trigger_error( 'Cannot open connection to server: ' . $mq_server ,E_USER_ERROR); |
19 |
echo 'Connection good!' ; |
Obviously you’ll need to adjust the settings to fit your server, but at least this gives you a start.
--END
PHP | 评论:0
| 阅读:20223
Submitted by gouki on 2014, June 5, 4:55 PM
事先申明。我是借鉴了这篇博客:http://blog.phpdeveloper.org/?p=140
当然在其中遇到了不少问题,我在这里一一说明:
1、准备工作
a. pecl mqseries :http://pecl.php.net/package/mqseries
b. ibm mq client: http://www-01.ibm.com/software/integration/wmq/clients/
2、步骤:
1、先安装ibm mq client :下载地址最终是要翻墙的,我这里不教翻墙技术。下载完后,解开压缩,在centos下面,直接rpm -ivh
MQSeriesRuntime-7.5.0-3.x86_64.rpm,和rpm -ivh MQSeriesSDK-7.5.0-3.x86_64.rpm ,由于我们只是当成一个client库来连接,因此安装这两个就够了
2、编译mqseries。在这里我吃药了,我下载的是0.14版的,我一看更新时间是2014年。我想这是最新的总没问题吧。结果。。。./configure到最后的时候,说--with-libdir=lib64找不到,让我指定。可是我明明指定了也不能安装。于是google了一下,发现这曾经是一个BUG。在2012年解决掉了。在bug.php.net里。写的是bug fixed。所以我下载了0.13的,然后再安装,果然成功了
3、测试
PHP代码
- <?php
- $mq_host_ip ='127.0.0.1';
- $queue_name = 'HOST.REMOTE.Q';
- $mq_server = 'WBRK_QM_U49';
- $mqcno = array(
- 'Version' => MQSERIES_MQCNO_VERSION_2,
- 'Options' => MQSERIES_MQCNO_STANDARD_BINDING,
- 'MQCD' => array(
- 'ChannelName' => 'CLIENT.CHANNEL',
- 'ConnectionName' => $mq_host_ip,
- 'TransportType' => MQSERIES_MQXPT_TCP
- )
- );
-
-
- mqseries_connx($mq_server,$mqcno,$conn,$comp_code,$reason);
- if ($comp_code !== MQSERIES_MQCC_OK) {
- trigger_error('Cannot open connection to server: '.$mq_server,E_USER_ERROR);
- }else{
- echo 'Connection good!';
- }
$mq_server从手册上看得知这应该是:queue_manager,所以应该是manager的名称
如果你访问的mq不是默认的端口号,还要加上端口号。我在这里走了不少弯路。我原来connectionName是写成:127.0.0.1:1234,报错2387,意思是host not avarible。查了下资料,原来端口号应该是 ip(port),也就是说得:127.0.0.1(1234) 这样的形式才OK。于是改好后再测试就通过啦。
----
我是在一台干净的Centos上安装的。所以做了很多准备工作:
1、 yum install php php-devel(devel里面才有phpize)
2、yum install gcc gcc-c++ g++
然后在安装的时候还有提示:you will need re2c ...于是找到这个博客:http://denghai260.blog.163.com/blog/static/726864092012260242533/
里面说道:
XML/HTML代码
- wget http://sourceforge.net/projects/re2c/files/re2c/0.13.5/re2c-0.13.5.tar.gz/download
- tar -zxvf re2c-0.13.5.tar.gz
- cd re2c-0.13.5
- ./configure && make && make install
至此,遇到的所有的问题都解决了。
PHP | 评论:0
| 阅读:17333