1. 首页
  2. IT资讯

Windows和linux环境下PHP扩展的开启

“u003Cdivu003Eu003Cpu003EPHP在Windows和linux的环境运行少不了需要开启这种扩展,但是由于环境的差异,扩展开启的方式也有不同,现在以PHP操作memcache的场景演示在Windows和Linux环境下开启memcache扩展u003Cu002Fpu003Eu003Cpu003E1、window下开启PHP的memcache扩展u003Cu002Fpu003Eu003Cpu003E①创建查看PHP环境信息文件u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F1239495a78664d0fa8af806241bb28e2″ img_width=”720″ img_height=”180″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E②访问u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002F7aeb714f45674e3fb3e5a49d895e27fa” img_width=”720″ img_height=”392″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E确认PHP的版本、位数、编译器 是否为线程安全(nsu002Fnts)u003Cu002Fpu003Eu003Cpu003E③根据前面所确认的信息下载对于的扩展文件u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp9.pstatp.comu002Flargeu002Fpgc-imageu002Fc250f3fd851c41269144cb8ef8f5fc6e” img_width=”720″ img_height=”171″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E④确认PHP的扩展目录的地址u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002Fcb97a432537b420ebd15bcaab838cc25″ img_width=”720″ img_height=”314″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑤将下载的扩展文件拷贝到扩展目录下u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp9.pstatp.comu002Flargeu002Fpgc-imageu002F88246153c68b497db8dbcafc719578ad” img_width=”720″ img_height=”314″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑥修改配置文件u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002F0f904ef3baff42f992fb35f9a55d7931″ img_width=”720″ img_height=”285″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑦重启Apache查看u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F0e9cf1ffef2149869399fa6616696f71″ img_width=”720″ img_height=”349″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E注意所开启的为PHP所开启的扩展名称为memcache。关于PHP下可以操作到memcache服务器中数据的扩展有两种分别叫做memcache与memcached。两种扩展在PHP下的使用方式略微有区别u003Cu002Fpu003Eu003Cpu003E2、Linux下运行php操作memcache的代码u003Cu002Fpu003Eu003Cpu003E此处Linux下的是nginx+php+memcache环境u003Cu002Fpu003Eu003Cpu003E①修改虚拟主机的配置u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F177794517d0c42e7afb7189d0d900db2″ img_width=”568″ img_height=”315″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E②重启Nginxu003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002Fb79d93172f7443a4b1e3fab03d35eace” img_width=”720″ img_height=”66″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E③创建测试文件u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F6ae58787813a4e5e8edb51a8794fadf2″ img_width=”720″ img_height=”258″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E④访问虚拟机u003Cu002Fpu003Eu003Cpu003E此处我的ip为192.168.150.132u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002Fe32d6048ca0845cd81eae0a4fc16e371″ img_width=”720″ img_height=”237″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E出现上图的问题是由于PHP服务没有启动u003Cu002Fpu003Eu003Cpu003E⑤启动PHP的服务u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F587ec2d3574948d1a7d44cb1ebf69a60″ img_width=”720″ img_height=”67″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑥再次访问u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp9.pstatp.comu002Flargeu002Fpgc-imageu002F9afc7c8d1a3a45ad8b4e58e0bf155f5c” img_width=”720″ img_height=”120″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E3、为Linux下的PHP开启扩展u003Cu002Fpu003Eu003Cpu003E在window下扩展文件一般为dll后缀。但是在Linux平台下扩展文件一般为so后缀。Linux下的扩展文件需要源码编译生成出so文件u003Cu002Fpu003Eu003Cpu003E①关于扩展文件包说明u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002F871cef3e34004e6895859426c9004094″ img_width=”720″ img_height=”289″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E②将扩展文件上传到服务器下u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002Fdbcf604c1e2c443587eabc1fa043e077″ img_width=”665″ img_height=”289″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E③安装unzipu003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002Fc74a7f489402463bb1cc881d2f2570c9″ img_width=”719″ img_height=”59″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E④解压u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F324dfa90e788401daa2764fdbf83dce7″ img_width=”720″ img_height=”85″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑤进入解压目录执行phpize[u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002Ffdbd41a7db0044bc942054347483c812″ img_width=”720″ img_height=”249″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑥安装依赖u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F5d3797cba36a4fd185d15a47570b207f” img_width=”720″ img_height=”42″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑦再次执行phpize工具u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002F9a03d98599474e9e8b0b08f00236704a” img_width=”720″ img_height=”235″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑧执行configure工具u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp3.pstatp.comu002Flargeu002Fpgc-imageu002Fd2c3ef5b82024364b7af6936ad5c33e1″ img_width=”720″ img_height=”54″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑨安装u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp9.pstatp.comu002Flargeu002Fpgc-imageu002F2951929ea8754937a2164a3d80b40868″ img_width=”720″ img_height=”67″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E安装完成后的结果u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F78d6ef6db0f3477d87568ed7aaaa8e3d” img_width=”720″ img_height=”132″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E⑩修改php.ini引入扩展u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp9.pstatp.comu002Flargeu002Fpgc-imageu002F860696c05f904aa38698b01365123e60″ img_width=”720″ img_height=”273″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E重启phpu003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F54fbf3d2ad77471986ee1d0f7796dfb2″ img_width=”720″ img_height=”65″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cpu003E效果u003Cu002Fpu003Eu003Cdiv class=”pgc-img”u003Eu003Cimg src=”http:u002Fu002Fp1.pstatp.comu002Flargeu002Fpgc-imageu002F6c9343008fcb47c9a7eabf5d483eba8a” img_width=”720″ img_height=”136″ alt=”Windows和linux环境下PHP扩展的开启” inline=”0″u003Eu003Cp class=”pgc-img-caption”u003Eu003Cu002Fpu003Eu003Cu002Fdivu003Eu003Cu002Fdivu003E”

原文始发于:Windows和linux环境下PHP扩展的开启

主题测试文章,只做测试使用。发布者:玩家L-,转转请注明出处:http://www.cxybcw.com/26880.html

联系我们

13687733322

在线咨询:点击这里给我发消息

邮件:1877088071@qq.com

工作时间:周一至周五,9:30-18:30,节假日休息

QR code