30 2014

PHP 5.5.15安装intl模块

分类: PHPLi Xi @ 2014-07-30 23:13:01

给PHP环境安装intl模块需要安装 icu4c。

intl模块安装

安装icu4c在本地环境。

wget http://download.icu-project.org/files/icu4c/53.1/icu4c-53_1-src.tgz
tar -xzf icu4c-53_1-src.tgz
cd icu/source
./configure –prefix=/usr/local/icu
make
make install

从Pecl下载intl模块

wget http://pecl.php.net/get/intl-3.0.0.tgz
tar -xzf intl-3.0.0.tgz
cd intl-3.0.0

/usr/local/php/bin/phpize
./configure –enable-intl –with-icu-dir=/usr/local/icu/ –with-php-config=/usr/local/php/bin/php-config
make
make install

配置php.ini启用intl模块

sed -i ‘s#; extension_dir = \”\.\/\”#extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20121212/”#’ /etc/php.ini
echo “;extension=intl.so” >> /etc/php.ini

阅读更多>>

标签: , , ,


26 2014

PHP-FPM unix socket 失败

分类: PHPLi Xi @ 2014-07-26 21:50:31

今天在配置PHP-FPM时,使用 fastcgi 连接 unix socket 方式报错:

2014/07/26 20:24:16 [error] 1595#0: *2 FastCGI sent in stderr: “Primary script unknown” while reading response header from upstream, client: 58.220.197.135, server: blog.lixiphp.com, request: “GET /index.php HTTP/1.1″, upstream: “fastcgi://unix:/tmp/php-cgi.sock:”, host: “blog.lixiphp.com”

经过查询,找到了原因。

解决方法

使用php-cgi来连接socket,以下是php-cgi 的命令行工具:

localhost:~ root$ php-cgi -h
Usage: php [-q] [-h] [-s] [-v] [-i] [-f ]
php <file> [args...]
-a Run interactively
-b <address:port>| Bind Path for external FASTCGI Server mode
-C Do not chdir to the script’s directory
-c <path>|<file> | Look for php.ini file in this directory
-n No php.ini file will be used
-d foo[=bar] Define INI entry foo with value ‘bar’
-e Generate extended information for debugger/profiler
-f <file> Parse <file>. Implies `-q’
-h This help
-i PHP information
-l Syntax check only (lint)
-m Show compiled in modules
-q Quiet-mode. Suppress HTTP Header output.
-s Display colour syntax highlighted source.
-v Version number
-w Display source with stripped comments and whitespace.
-z <file> Load Zend extension <file>.
-T <count> Measure execution time of script repeated <count> times.

php-cgi -b 可以建立TCP,IP+端口的连接,也可以通过socket文件的连接。

php-cgi -b /tmp/php-cgi.socket

第二个办法就是通过 spawn-fcgi 的方式来管理 cgi,它可以自动管理cgi的进程数。

阅读更多>>

标签: , , ,


14 2014

使用 PHP mailgun 发送邮件

分类: PHPLi Xi @ 2014-07-14 21:52:09

为了提高发送邮件的成功率,我们完全可以使用第三方服务来实现发送邮件功能,其中比较典型的提供商就是国外的mailgun和国内的sendcloud,由于sendcloud 模板限制为30条,且每次模板修改都要经过审核,故只能放弃使用sendcloud。

mailgun 绑定信用卡后,每月会赠送1万条邮件,对于小站来说基本够用,超出的部分也不贵。

有人可能会考虑sendcloud在国内的速度更快,mailgun在国外请求速度变慢,其实仔细一想,只要能收到国外的邮件,发送的速度慢点又何妨呢。

通过 mailgun API 发送邮件

# Include the Autoloader (see "Libraries" for install instructions)
require 'vendor/autoload.php';
use Mailgun\Mailgun;

# Instantiate the client.
$mgClient = new Mailgun('key-3ax6xnjp29jd6fds4gc373sgvjxteol0');
$domain = "samples.mailgun.org";

# Make the call to the client.
$result = $mgClient->sendMessage($domain, array(
'from' => 'Excited User <me@samples.mailgun.org>',
'to' => 'Baz <baz@example.com>',
'subject' => '邮件标题',
'text' => '邮件内容',
));

这个API看起来很类似REST WebService API,简单而快捷。

阅读更多>>

标签: , , ,


10 2014

PHP 上传文件错误 Error 代码

分类: PHPLi Xi @ 2014-07-10 19:23:26

默认表单带文件上传时 留空,会出现UPLOAD_ERR_NO_FILE 4错误代码。

PHP 错误代码列表

// UPLOAD_ERR_OK         Value: 0
// There is no error, the file uploaded with success.

// UPLOAD_ERR_INI_SIZE   Value: 1
// The uploaded file exceeds the upload_max_filesize directive in php.ini.

// UPLOAD_ERR_FORM_SIZE  Value: 2
// The uploaded file exceeds the MAX_FILE_SIZE directive that was specified in the HTML form.

// UPLOAD_ERR_PARTIAL    Value: 3
// The uploaded file was only partially uploaded.

// UPLOAD_ERR_NO_FILE    Value: 4
// No file was uploaded.

// UPLOAD_ERR_NO_TMP_DIR Value: 6
// Missing a temporary folder. Introduced in PHP 4.3.10 and PHP 5.0.3.

// UPLOAD_ERR_CANT_WRITE Value: 7
// Failed to write file to disk. Introduced in PHP 5.1.0.

// UPLOAD_ERR_EXTENSION  Value: 8
// A PHP extension stopped the file upload. Introduced in PHP 5.2.0.

注意到上传错误代码为0,即表示上传成功。

阅读更多>>


22 2014

解决Mac睡眠再打开时声音没有的问题

分类: ToolsLi Xi @ 2014-04-22 22:55:37

今天发现配备 Retina 显示屏的MacBook Pro, OSX Mavericks (10.9.2) 在系统睡眠以后,再开机的时候,声音没有,变无声了,怎么调节都没有用。但是重新启动以后就恢复正常。碰到这个问题几次了。

解决 Mac OSX Mavericks (10.9.2) MacBook Pro 睡眠再打开时声音控制失效的问题

在网上找到个靠谱的方法:

打开终端输入:

sudo kextunload /System/Library/Extensions/AppleHDA.kext

sudo kextload /System/Library/Extensions/AppleHDA.kext

这个不用重启就恢复正常声音。

阅读更多>>

标签: , ,


当前1, 所有6412345678910...203040...最后一页 »