首页 > 编程技术 > php

PHP中PDO_MYSQL扩展安装的2种方法

发布时间:2016-11-25 15:28

下文小介绍在linux中PDO_MYSQL扩展的两种安装方法,希望本文章可以让各位理解在linux系统中PDO_MYSQL扩展安装使用。

方法一,

看到CakePHP文档要求安装pdo_mysql扩展,于是就尝试安装了一下。

这里我的系统是CentOS 6.0。如果你的系统是其他版本的Linux/Unix,可以参考。如果你的系统是Windows的,抱歉,以下内容不适合你,请移步。

首先是下载pdo_mysql扩展的源码包。下载页面在这里:http://pecl.php.net/package/PDO_MYSQL。可以先下载了然后用FTP传到服务器。

我是在复制了下载地址以后使用wget直接下载到服务器端的。
# wget http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

然后是解压缩。
# tar -zxvf PDO_MYSQL-1.0.2.tgz

进入解压后的目录,然后执行phpize。
# /usr/local/php/bin/phpize
Configuring for:
PHP Api Version: 20100412
Zend Module Api No: 20100525
Zend Extension Api No: 220100525

下面生成makefile。后面的两个参数必须要添加,一开始我没有添加,结果分别都提示找不到php-config和mysql的header文件。
# ./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql

在make之前还要做一个mysql的header文件的软连接。因为mysql安装的时候指定了目录,不做软连接的话,还是找不到header文件。
# ln -s /usr/local/mysql/include/* /usr/local/include/

然后make和make install。
# make
# make install

之后会提示如下,意思是扩展被安装到了如下目录里。
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/

为了方便,我把pdo_mysql.so文件移动到extensions目录下。
# mv /usr/local/php/lib/php/extensions/no-debug-zts-20100525/pdo_mysql.so /usr/local/php/lib/php/extensions/

随后就可以修改php.ini文件了。

找到; extension_dir = “./”这一行,去掉注释,并修改路径。
extension_dir = “/usr/local/php/lib/php/extensions/”
这里经过我测试,发现php只会从该目录寻找扩展so,而并不寻找该目录下的子目录。所以之前我为了统一管理,把so文件都移动到该目录下。

找到; extension=php_pdo_mysql.dll这一行,去掉注释,并修改后面的文件名。
extension=pdo_mysql.so
文件名不太一样,这里要把php_前缀去掉,否则找不到文件。后面的dll是windows下的文件名,我们改成so。

最后重启apache就可以了。用phpinfo()查看发现已经生效了。


方法二

PDO_MYSQL以下操作都在Linux 系统下操作

1、下载 文件 或者 进入 在PHP源码包中进入ext/pdo_mysql

http://pecl.php.net/get/PDO_MYSQL-1.0.2.tgz

2、解压文件
tar zxvf PDO_MYSQL-1.0.2.tgz

3、配置和编译文件
cd PDO_MYSQL-1.0.2
/usr/local/php/bin/phpize
./configure –with-php-config=/usr/local/php/bin/php-config –with-pdo-mysql=/usr/local/mysql
make
make install

注: 我的PHP安装在 : /usr/local/php/ mysql 安装在 : /usr/local/mysql 编译的时候注意你自己的安装目录在哪里
3、安装到PHP配置下

把这个记住,然后打开 php.ini文件,
并添加一行

extension=pdo_mysql.so

windows PDO MYSQL扩展安装


php.ini中没有开启pdo,故修改php.ini,将形如下面的代码前面去掉分号,修改后如下:

extension_dir="E:/amp/php/ext" //这里配置为你自己的ext目录路径
......
extension=php_mysql.dll
......
extension=php_pdo.dll
......
extension=php_pdo_mysql.dll

重启apache后访问又继续报以下错误:

CDbConnection 无法开启数据库连线: could not find driver
意思是无法找到数据库驱动,我又用phpinfo看了一下,PDO确实是开启了,但是PDO那一项中支持的数据库显示no value,说明无法加载php_pdo_mysql.dll这个扩展。经过多次尝试,包括更换php的版本,更换mysql的版本。但是均不奏效。难道真的无法开启php的mysql pdo扩展了吗?

在网上查了又查,终于找到解决方案

方法一:需要把php安装目录的路径加入到系统环境变量PATH中,这样就可以解决问题。
方法二:因为我是在服务器上部署的,正在运行着的服务器,所以无法重启,故也可将php安装目录下的libmysql.dll复制到windows目录下

重启apache

本教程总结了windows+php环境下memcache缓存和mongodb数据库安装和配置,还有Mongodb启动关闭。希望对学习memcache和mongodb的同学有所帮助。

mangodb安装

1. 下载mongodb的安装文件,我安装的windows 64位的,下载地址如下:

https://fastdl.mongodb.org/win32/mongodb-win32-x86_64-2008plus-2.6.6-signed.msi

2. 新建一个mongodb文件夹在E盘(随便放,如E:mongodb)

3. 将下载的安装文件解压,把解压的文件移动到E盘mongodb下

4. 建立mongodb数据存放目录E:mongodbdata

5. 启动mongodb(简单启动不配置服务)

E:mongodbbinmongod.exe --dbpath  E:mongodbdata

可以看到如下信息:

memcache和mongodb在windows+php环境下安装总结教程

说明安装启动成功了。

6. 在浏览器中输入http://localhost:27017/,会出现下面信息,表明mongdb已经启动好了

It looks like you are trying to access MongoDB over HTTP on the native driver port.

7、下载对应的mongodb php插件(不太好找,如果php是5.4-5.5版可用这个地址:http://pan.baidu.com/s/1sjJjsYh)并配置好。

8、在php中使用:

 代码如下 复制代码
try {
    $mongo = new Mongo('localhost');
} catch(MongoConnectionException $e) {
    var_dump($e);
}
$mongo_db = $mongo->selectDB('logdatastorage');


注:上面的代码是demo,不可在生产环境中使用。

 

memcache安装

1、64位下载

From: http://www.urielkatz.com/archive/detail/memcached-64-bit-windows/
下载:http://www.urielkatz.com/projects/memcached-win64/memcached-win64.zip
源码:http://www.urielkatz.com/projects/memcached-win64/memcached-src.rar

2、解压刚刚下载的压缩包,得到两个文件:memcached.exe(服务端主程序)、pthreadGC2.dll

3、以管理员权限运行命令提示符,定位到解压路径,安装Memcached服务,命令:

memcached.exe -d install

4、执行 开始→管理工具→服务 打开Windows服务查看工具,找到memcached服务(没找到证明没有安装成功)

5、启动Memcached:

memcached.exe -m 1024 -d start

-d为守护进程启动,不能指定端口 默认端口11211
-m为指定内存大小

6、配置Windows防火墙,为Memcached默认端口11211 添加入站规则(如果服务端和客户端都在本机,不需要这一步)

7、测试是否可以正常通讯,这里借助Telnet:

telnet 127.0.0.1 11211

如果进入一个空白的doc屏,估计OK了。第一行命令输入是看不见的,所以我一般先敲一次回车,回返回一个Error,没关系,这是说明你输入的是一个无法识别的命令;

接着看下状态,键入stats然后回车:

memcache和mongodb在windows+php环境下安装总结教程

8、下载对应的memcache php插件(如果php是5.5版可用这个地址:http://pan.baidu.com/s/1mgspf9e)并配置好。

9、在php中连接使用:

$memcache = new Memcache;
$memcache->connect('127.0.0.1', 11211);

Mongodb 安装配置,启动关闭

1.       下载mongodb的安装文件,我安装的windows 32位的,下载地址如下:

http://www.mongodb.org/dr//fastdl.mongodb.org/win32/mongodb-win32-i386-2.6.4.zip/download

2.       新建一个mongodb文件夹在E盘(随便放)

E:mongodb

3.       将下载的文件安装文件解压,把解压的文件移动到E盘mongodb下

4.       建立mongodb数据存放目录E:mongodbdata

5.       启动mongodb(简单启动不配置服务)

E:mongodbbinmongod.exe --dbpath  E:mongodbdata

E:mongodbbin>mongod.exe --dbpath  E:mongodbdata

2014-09-13T22:18:50.640+0800

2014-09-13T22:18:50.640+0800 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.

2014-09-13T22:18:50.640+0800

2014-09-13T22:18:50.765+0800 [initandlisten] MongoDB starting : pid=9204 port=27

017 dbpath=E:mongodbdata 32-bit host=20120621-1418

2014-09-13T22:18:50.765+0800 [initandlisten]

2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.

2014-09-13T22:18:50.765+0800 [initandlisten] **       32 bit builds are limitedto less than 2GB of data (or less with --journal).

2014-09-13T22:18:50.765+0800 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.

2014-09-13T22:18:50.765+0800 [initandlisten] **       See http://dochub.mongodb.org/core/32bit

2014-09-13T22:18:50.765+0800 [initandlisten]

2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB

2014-09-13T22:18:50.765+0800 [initandlisten] **       uses to detect impending page faults.

2014-09-13T22:18:50.765+0800 [initandlisten] **       This may result in slowerperformance for certain use cases

2014-09-13T22:18:50.765+0800 [initandlisten]

2014-09-13T22:18:50.765+0800 [initandlisten] targetMinOS: Windows XP SP3

2014-09-13T22:18:50.765+0800 [initandlisten] db version v2.6.4

2014-09-13T22:18:50.765+0800 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910

2014-09-13T22:18:50.765+0800 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack 1'BOOST_LIB_VERSION=1_49

2014-09-13T22:18:50.765+0800 [initandlisten] allocator: system

2014-09-13T22:18:50.765+0800 [initandlisten] options: { storage: { dbPath: "E:mongodbdata" } }

在浏览器中输入http://localhost:27017/,会出现表面mongdb已经启动好了

It looks like you are trying to access MongoDB over HTTP on the native driver port.

6.       启动好后连接到mongodb

E:mongodbbinmongo.ext

E:mongodbbin>mongo

MongoDB shell version: 2.6.4

connecting to: test

Welcome to the MongoDB shell.

For interactive help, type "help".

For more comprehensive documentation, see

        http://docs.mongodb.org/

Questions? Try the support group

        http://groups.google.com/group/mongodb-user

Server has startup warnings:

2014-09-13T22:18:50.765+0800 [initandlisten]

2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary.

2014-09-13T22:18:50.765+0800 [initandlisten] **       32 bit builds are limitedto less than 2GB of data (or less with --journal).

2014-09-13T22:18:50.765+0800 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.

2014-09-13T22:18:50.765+0800 [initandlisten] **       See http://dochub.mongodb.org/core/32bit

2014-09-13T22:18:50.765+0800 [initandlisten]

2014-09-13T22:18:50.765+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB

2014-09-13T22:18:50.765+0800 [initandlisten] **       uses to detect impending page faults.

2014-09-13T22:18:50.765+0800 [initandlisten] **       This may result in slowerperformance for certain use cases

2014-09-13T22:18:50.765+0800 [initandlisten]

>

Mongodb的关闭:

前台运行:

如果没有使用--fork,直接可以前台退出终端关闭。通过这种方式,Mongodb将会自己做清理退出,把没有写好的数据写完成,并最终关闭数据文件。要注意的是这个过程会持续到所有操作都完成。

后台运行:

如果使用--fork在后台运行mongdb服务,那么就要通过向服务器发送shutdownServer()消息来关闭。

1、普通命令:

$ ./mongod

> use admin

> db.shutdownServer()

> db.shutdownServer()

2014-09-13T22:25:07.843+0800 DBClientCursor::init call() failed

server should be down...

2014-09-13T22:25:07.890+0800 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed

2014-09-13T22:25:08.890+0800 warning: Failed to connect to 127.0.0.1:27017, reas

on: errno:10061由于目标机器积极拒绝,无法连接。

2014-09-13T22:25:08.890+0800 reconnect 127.0.0.1:27017 (127.0.0.1) failed failed

 couldn't connect to server 127.0.0.1:27017 (127.0.0.1), connection attempt failed

>

控制台显示如下:

2014-09-13T22:25:07.625+0800 [conn1] terminating, shutdown command received

2014-09-13T22:25:07.625+0800 [conn1] dbexit: shutdown called

2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close listening sockets.

..

2014-09-13T22:25:07.625+0800 [conn1] closing listening socket: 1632

2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to flush diaglog...

2014-09-13T22:25:07.625+0800 [conn1] shutdown: going to close sockets...

2014-09-13T22:25:07.625+0800 [conn1] shutdown: waiting for fs preallocator...

2014-09-13T22:25:07.625+0800 [conn1] shutdown: closing all files...

2014-09-13T22:25:07.625+0800 [conn1] closeAllFiles() finished

2014-09-13T22:25:07.625+0800 [conn1] shutdown: removing fs lock...

2014-09-13T22:25:07.625+0800 [conn1] dbexit: really exiting now

E:mongodbbin>

关闭成功

Mongodb启动帮助

E:mongodbbin>mongod --help

Options:

General options:

  -h [ --help ]               show this usage information

  --version                   show version information

  -f [ --config ] arg         configuration file specifying additional options

  -v [ --verbose ] [=arg(=v)] be more verbose (include multiple times for more

                              verbosity e.g. -vvvvv)

  --quiet                     quieter output

  --port arg                  specify port number - 27017 by default

  --bind_ip arg               comma separated list of ip addresses to listen on

                              - all local ips by default

  --maxConns arg              max number of simultaneous connections - 1000000

                              by default

  --logpath arg               log file to send write to instead of stdout - has

                              to be a file, not directory

  --logappend                 append to logpath instead of over-writing

  --timeStampFormat arg       Desired format for timestamps in log messages.

                              One of ctime, iso8601-utc or iso8601-local

  --pidfilepath arg           full path to pidfile (if not set, no pidfile is

                              created)

  --keyFile arg               private key for cluster authentication

  --setParameter arg          Set a configurable parameter

  --httpinterface             enable http interface

  --clusterAuthMode arg       Authentication mode used for cluster

                              authentication. Alternatives are

                              (keyFile|sendKeyFile|sendX509|x509)

  --auth                      run with security

  --noauth                    run without security

  --ipv6                      enable IPv6 support (disabled by default)

  --jsonp                     allow JSONP access via http (has security

                              implications)

  --rest                      turn on simple rest api

  --slowms arg (=100)         value of slow for profile and console log

  --profile arg               0=off 1=slow, 2=all

  --cpu                       periodically show cpu and iowait utilization

  --sysinfo                   print some diagnostic system information

  --dbpath arg                directory for datafiles - defaults to datadb

  --directoryperdb            each database will be stored in a separate

                              directory

  --noIndexBuildRetry         don't retry any index builds that were

                              interrupted by shutdown

  --noprealloc                disable data file preallocation - will often hurt

                              performance

  --nssize arg (=16)          .ns file size (in MB) for new databases

  --quota                     limits each database to a certain number of files

                              (8 default)

  --quotaFiles arg            number of files allowed per db, implies --quota

  --smallfiles                use a smaller default file size

  --syncdelay arg (=60)       seconds between disk syncs (0=never, but not

                              recommended)

  --upgrade                   upgrade db if needed

  --repair                    run repair on all dbs

  --repairpath arg            root directory for repair files - defaults to

                              dbpath

  --noscripting               disable scripting engine

  --notablescan               do not allow table scans

  --journal                   enable journaling

  --nojournal                 disable journaling (journaling is on by default

                              for 64 bit)

  --journalOptions arg        journal diagnostic options

  --journalCommitInterval arg how often to group/batch commit (ms)

 

Windows Service Control Manager options:

  --install                install Windows service

  --remove                 remove Windows service

  --reinstall              reinstall Windows service (equivalent to --remove

                           followed by --install)

  --serviceName arg        Windows service name

  --serviceDisplayName arg Windows service display name

  --serviceDescription arg Windows service description

  --serviceUser arg        account for service execution

  --servicePassword arg    password used to authenticate serviceUser

 

Replication options:

  --oplogSize arg       size to use (in MB) for replication op log. default is

                        5% of disk space (i.e. large is good)

Master/slave options (old; use replica sets instead):

  --master              master mode

  --slave               slave mode

  --source arg          when slave: specify master as <server:port>

  --only arg            when slave: specify a single database to replicate

  --slavedelay arg      specify delay (in seconds) to be used when applying

                        master ops to slave

  --autoresync          automatically resync if slave data is stale

Replica set options:

  --replSet arg           arg is <setname>[/<optionalseedhostlist>]

  --replIndexPrefetch arg specify index prefetching behavior (if secondary)

                          [none|_id_only|all]

Sharding options:

  --configsvr           declare this is a config db of a cluster; default port      27019; default dir /data/configdb

  --shardsvr            declare this is a shard db of a cluster; default port 27018

下面通过构造一个conf文件进行启动

文件内容如下mongodb.conf

dbpath=E:mongodbdata

logpath=E:mongodblog

logappend=true

bind_ip=127.0.0.1

port=27019

fork=true

master=true

启动:

E:mongodbbin>mongod --config E:mongodbmongodb.conf

2014-09-13T22:39:31.296+0800

2014-09-13T22:39:31.296+0800 warning: 32-bit servers don't have journaling enabl

ed by default. Please use --journal if you want durability.

2014-09-13T22:39:31.296+0800

连接mongodb报错,原因我启动时指定端口号了,不是默认的27017了,所以报错

E:mongodbbin>mongo

MongoDB shell version: 2.6.4

connecting to: test

2014-09-13T22:50:24.296+0800 warning: Failed to connect to 127.0.0.1:27017, rea

on: errno:10061由于目标机器积极拒绝,无法连接。

2014-09-13T22:50:24.312+0800 Error: couldn't connect to server 127.0.0.1:27017

127.0.0.1), connection attempt failed at src/mongo/shell/mongo.js:146

exception: connect failed

指定端口号连接:

E:mongodbbin>mongo 127.0.0.1:27019

MongoDB shell version: 2.6.4

connecting to: 127.0.0.1:27019/test

Server has startup warnings:

2014-09-13T22:50:13.593+0800 [initandlisten]

2014-09-13T22:50:13.593+0800 [initandlisten] ** NOTE: This is a 32 bit MongoDB b

inary.

2014-09-13T22:50:13.593+0800 [initandlisten] **       32 bit builds are limited

to less than 2GB of data (or less with --journal).

2014-09-13T22:50:13.593+0800 [initandlisten] **       Note that journaling defaults to off for 32 bit and is currently off.

2014-09-13T22:50:13.593+0800 [initandlisten] **       See http://dochub.mongodb.org/core/32bit

2014-09-13T22:50:13.593+0800 [initandlisten]

2014-09-13T22:50:13.593+0800 [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB

2014-09-13T22:50:13.593+0800 [initandlisten] **       uses to detect impending page faults.

2014-09-13T22:50:13.593+0800 [initandlisten] **       This may result in slowerperformance for certain use cases

2014-09-13T22:50:13.593+0800 [initandlisten]

>

PHP安装ORACLE扩展的方法比较复杂了,下文本文章就为各位介绍PHP安装ORACLE扩展(oic8安装教程),如果有需要了解ORACLE扩展安装方法的话我们就一起和小编来看看。

本文主要叙述,php环境与oracle数据库不在同一台服务器上时,php环境的安装编译

按照官方说明文档 http://cn2.php.net/manual/zh/oci8.installation.php
编译php的时候要加上这个参数–with-oci8,但是加这个参数有个前提,就是必须要安装了对应的库文件。

安装库文件有两种方法:

一. 你的php环境和oracle在同一台服务器上(通常oracle都很大,这方法不合适)
二. 在你的php服务器上安装 Oracle Instant Client libraries.(这个方法适合php与oracle不在一个服务器上)

Oracle Instant Client libraries的安装步骤:详见 这里
1. 针对自己的系统下载适合的Instant Client packages安装包。其中安装包都需要Basic或者Basic Lite包(根据本链接选择一个系统平台,然后进去下载对应的Basic或者SDK等等包)

这里我下载了三个zip的包,分别是:

 代码如下 复制代码
Instant Client Package – Basic
Instant Client Package – SQL*Plus
Instant Client Package – SDK

2. 解压包到一个单独的目录,比如 “instantclient”.(我把上述三个包放到一起,然后放到了/usr/local/instantclient)

3. 在环境变量里设置库的加载路径,路径为第二部设置的路径”instantclient”。多数UNIX平台环境变量设置LD_LIBRARY_PATH,而Windows系统应该用PATH

4. 可以开始你的应用了

加载库(上述第3步骤,环境变量)
上述所述的库,需要加载到linux系统才可以,那怎么加载呢
方法一:
编辑 /etc/ld.so.conf,在里面加入一行库文件路径/usr/local/instantclient(根据实际情况而定)
注意:centos的/etc/ld.so.conf文件里是用include包含加载了/etc/ld.so.conf.d/*.conf所有文件,所以我们可以创建一个文件/etc/ld.so.conf.d/oracle.conf,在里面加入一行库文件路径/usr/local/instantclient(根据实际情况而定),而不是直接编辑/etc/ld.so.conf文件。

方法二:

设置Linux系统设置环境变量

 

 代码如下 复制代码
vim ~/.bashrc

最后一行加入

 代码如下 复制代码


export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/instantclient

此处根据实际情况修改,因为上述第二步的instantclient位置放到了/usr/local/instantclient

编译PHP
如果是编译安装php则需要加上 –with-oci8参数,因为我把Instant Client packages放在了/usr/local/instantclient
所以–with-oci8参数可以这样写

 代码如下 复制代码

–with-oci8=shared,instantclient,/usr/local/instantclient

php实例编译如下:

 代码如下 复制代码

./configure --prefix=/usr/local/php-5.3 --with-config-file-path=/usr/local/php-5.3/etc --with-config-file-scan-dir=/usr/local/php-5.3/etc/php.d --with-mysql=/usr/local/mysql --with-mysqli=/usr/local/mysql/bin/mysql_config --with-iconv --with-freetype-dir --with-jpeg-dir --with-png-dir --with-zlib --with-libxml-dir=/usr --enable-xml --disable-rpath --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fpm --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-mhash --enable-pcntl --enable-sockets --with-xmlrpc --with-openssl --enable-soap --enable-safe-mode --enable-zip --with-oci8=shared,instantclient,/usr/local/instantclient

php官方实例,这样写的./configure –with-oci8=shared,instantclient,/usr/lib/oracle//client/lib
编译时如提示找不到libclntsh.so,可以加个软链

 代码如下 复制代码

ln -s /usr/local/instantclient/libclntsh.so.12.1 /usr/local/instantclient/libclntsh.so

安装oci8拓展

使用php的pecl安装拓展

 代码如下 复制代码
./pecl install oci8

在提示输入,Instant Client packages库的路径时候录入实际路径,此处录入:

 代码如下 复制代码

shared,instantclient,/usr/local/instantclient
 

[root@localhost bin]# ./pecl install oci8
downloading oci8-2.0.8.tgz ...
Starting to download oci8-2.0.8.tgz (190,854 bytes)
.........................................done: 190,854 bytes
11 source files, building
WARNING: php_bin /usr/local/php-5.3/bin/php appears to have a suffix -5.3/bin/php, but config variable php_suffix does not match
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
Please provide the path to the ORACLE_HOME directory. Use 'instantclient,/path/to/instant/client/lib' if you're compiling with Oracle Instant Client [autodetect] : shared,instantclient,/usr/local/instantclient

最后把oci8加入php.ini

 代码如下 复制代码

extension=oci8.so

查看phpinfo

PHP安装ORACLE扩展(oic8安装教程)

eAccelerator是一个自由开放源码php加速器,优化和动态内容缓存,提高了php脚本的缓存性能,使得PHP脚本在编译的状态下,对服务器的开销几乎完全消除。下面我们来看看eAccelerator扩展开启open_basedir报错解决办法。

eAccelerator扩展开启open_basedir报错

如果你在使用php加速扩展eAccelerator时发现开启open_basedir配置项目后程序页面或者PHP错误日志会提示.

open_basedir restriction. in Unknown on line 0

出现这个问题的原因是一般eAccelerator的缓存文件不在你配置的open_basedir目录之中,而eAccelerator也傻乎乎的遵守了open_basedir的设定.

在网上转了一圈发现了两种解决这个问题的办法

1. 给eAccelerator打补丁

下载本文附件中的补丁文件然后运行下面命令

cd eaccelerator-0.9.6.1

patch eaccelerator.c eaccelerator.c.2.patch

然后照常规步骤编译即可

2. 编译时增加参数

在配置eAccelerator的时候增加 “–without-eaccelerator-use-inode” 参数

./configure –without-eaccelerator-use-inode

补充:eAccelerator安装和配置


首先您要安装好PHP,然后再来编译安装 eaccelerator,过程如下。我们从官方下的版本是 eaccelerator-0.9.5.2.tar.bz2
编译安装;
# tar xvf eaccelerator-0.9.5.2.tar.bz2
# cd eaccelerator-0.9.5.2
# export PHP_PREFIX="/usr"
# $PHP_PREFIX/bin/phpize
# ./configure
--enable-eaccelerator=shared
--with-php-config=$PHP_PREFIX/bin/php-config
# make
# make install
注:通过export 来设置php所在的安装路径变量,我的PHP是安装在/usr目录下,系统用Slackware 12.0。其它系统如果默认安装也大体差不多;如果不一样,就自己指定一下;
完成安装后,eaccelerator.so模块位于 /usr/lib/php/extensions目录中,您的系统如果和我不一样,您自己应该安装在哪了;
# echo "/usr/lib/php/extensions" &gt; /etc/ld.so.conf
# ldconfig
注:更新动态链接库地址;
修改配置文件;
我们首先要修改;php.ini,然后重启Apache;
在php.ini文件中,加入;
zend_extension="/usr/lib/php/extensions/eaccelerator.so" 注:模块的具体位置;
eaccelerator.shm_size="16" 注:共享内存大小;
eaccelerator.cache_dir="/home/eaccelerator" 注:缓存目录;
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="0"
eaccelerator.shm_prune_period="0"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
注:其中,模块的具体位置必须正确,以您的系统为准;共享内存大小可以自己调整,感觉16M还是可以的,根据服务器的情况,你自己调一下。缓存目录可以自己指定,我们在这里指定的是 /home目录上的 eaccelerator 目录,如果没有,自己创建一个;权限是0777;
以上的配置是把 eaccelerator 做为 Zend 的扩展模块来编译的办法。如果您的PHP是用安装模式编译的,要把 zend_extension改为zend_extension_ts 。
如果您是把 eaccelerator 做为 PHP的一个扩展,要用下面的配置 ;
extension="eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/home/eaccelerator"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
是不是生效了,您要查看 /home/eaccelerator 目录中,当Apache服务器启动了,你随便点几个页面,如果在这个目录中,出现文件了。那就是生效了。如果没任何文件,就要找原因了 ……
这两个配置文件,是不是管用。要你自己根据情况来修改。
# mkdir /home/eaccelerator
# chmod 777 /home/eaccelerator
注:创建缓存目录池,权限是777
(较为安全的应该是0644,原文: A safer and cleaner way would be to change the owner of the directory to the same user PHP runs as (most of the time the same user as Apache or Lighttpd) and set 0644 permissions.)

下面小编找了一篇关于PhpStorm中使用 PHP_CodeSniffer的图文教程,希望此文章能帮助到各位朋友哦。
1. 点击菜单:File->Settings 或 按快捷键 Ctrl+Alt+S
2. 选择Project Settings下的:PHP->Code Sniffer
3. 设置PHP Code Sniffer(phpcs) path为:E:wampbinpearphpcs.bat

4. 点击Validate按钮,可以看到如下提示,说明设置OK

5. 选择Project Settings下的Inspections,展开PHP,勾选PHP Code Sniffer validation
php_code_shiffer_validation
6. 第一次打开的时候,需要点击一下刷新的按钮可以获取已安装的代码规范,如果无法获取到代码规范的话,先执行 phpcs -i 命令查看PHP_CodeSniffer中已经安装的编码风格,确定有之后,尝试重启一下PhpStorm在刷新看看
php_code_sniffer_validation_coding_standard
7. 选择一个你习惯的编码风格,然后Apply配置
coding_standard_area
8. 打开一个PHP文件,就可以看到不符合规则的提示
phpcs_show

 

标签:[!--infotagslink--]

您可能感兴趣的文章: