I had numerous requests for info and questions relating to JSON extension in CentOS. To enable these functions in RedHat and CentOs 5, the process is really simple and fast.
NOTE: As of PHP 5.2, json extension is now standard. If you’re running PHP 5.2 or later, or like to upgrade instead, you can skip this!
- Ensure you have the necessary dependecies (php, php-pear, php-devel,
gcc, make):
- $ sudo yum install gcc make
- $ sudo yum install php php-pear php-devel
- Use PECL (P
HP E
xtension C
ommunity
L
ibrary) to download the json package:
- $ sudo pecl download json
- Use PEAR (P
HP E
xtension and A
pplication
R
epository) to extract and install the extension:
- $ sudo pear install json-1.2.1.tgz
- Create a file in
/etc/php.dcalled “json.ini”, and add the following lines:- ; php-json extension
- extension=json.so
- Restart apache (gracefully if you’re running a live site:
- $ sudo service httpd restart (apachectl graceful)
- Check for availability by creating an info.php file in the web root
with the following line:
- <?php phpinfo(); ?>
- Load info.php in your browser and check for JSON. You now should be all set, but if it doesn’t appear, verify all of the above steps very carefully.

本文介绍如何在CentOS 5中快速安装并启用JSON扩展。适用于运行PHP版本低于5.2的环境。教程覆盖依赖安装、使用PECL下载扩展包、通过PEAR进行安装配置及重启Apache服务等内容。
5485

被折叠的 条评论
为什么被折叠?



