PHP JSON Module Bug Fix
If you are encountering any weird stuff with your PHP-JSON module installation, you might want to reinstall JSON using this link, this might get rid of the bug that is pestering you and your application.
First, uninstall any previous JSON installation you have so as not to conflict with the new one. To make sure you got the old JSON out, check your list of PHP modules by running:
php -m
JSON should not be listed and make sure you do not see any errors either. Doing this will prevent further headaches, trust me.
Perform the following steps to install the bug-free version of JSON from source:
1. Download the JSON source from here. You can use wget to download the source if you are using CLI
wget http://aurore.net/projects/php-json/php-json-ext-1.2.1.tar.bz2
2. Uncompress the archive and change directory.
tar jxf php-json-ext-1.2.1.tar.bz2
cd php-json-ext-1.2.1
3. Run phpize. Make sure that phpize is installed before proceeding to this step. phpize is included in the php-devel package.
phpize
4. Configure, make and make install
./configure
make
make install
JSON is now installed, but make sure that json.so is loaded in your php.ini file.
1. Open php.ini file. If you are unsure about the location of your php.ini file, run
php -i | grep php.ini
You should see something like this:
Loaded Configuration File => /etc/php.ini
2. Add this at the last line of the configuration file:
extension=json.so
3. You might want to restart Apache to make sure everything is still working.
To check if JSON is loaded as module, run php -m again, make sure JSON is in the list.
Now, to test JSON, open an editor and copy these lines:
< ?php
$input = '{ "test" : 12121211212121 }';
$val = json_decode($input, true);
print $val["test"];
?>
Save the file (json-test.php is the filename in this case).
Execute the file by running php json-test.php
The result should be 12121211212121
How To Reset MySQL Password
If you are like me who tend to forget passwords almost every time, then this tip might help you reset your MySQL password just in case.
To begin, you must have access to the server, one that can stop and start the MySQL process, such as a root account. Sudo account can also be used, just as long that the user can control the MySQL service.
Begin the process by stopping the MySQL process. This can be done by executing /etc/init.d/mysqld stop command, but this can vary depending on how you setup your server. Also, be careful of users who might be using the MySQL service as stopping the service might disrupt their work.
Once the MySQL process is killed, execute the following command:
mysqld-safe --skip-grant-tables
This will run the MySQL process so you need to open another terminal to be able to reset the password. On the new terminal, you will now be able to login to MySQL to reset the password.
On the shell prompt of the new terminal, open the MySQL console:
mysql
mysql> use mysql;
mysql> UPDATE user SET Password=PASSWORD(‘YOUR_NEW_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;
mysql> exit
This will change the password for the user ‘root’. Kill the MySQL process running in the first terminal, either by killing the PID or executing CTRL+C. Then start the process again, this time with the proper procedure:
/etc/init.d/mysqld start
Try logging in to the MySQL console using the new password:
mysql –uroot -p
You should now be able to use the new password for your MySQL.
Fix Fatal error: Allowed memory size of 8388608 bytes exhausted
I was installing xdebug a few days back to one of the production servers when I encountered this beautiful error message:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 143 bytes) in /usr/share/pear/PEAR/PackageFile/v2/Validator.php on line 1608 Allowed memory size of 8388608 bytes exhausted (tried to allocate 64 bytes)
So my instinct tells me to look inside the php.ini file and find for this line:
memory_limit = 12M
The server’s php.ini file is already set to 256M so I should go look for something else. Luckily, I found this tip from www.agileapproach.com.
Open the file /usr/share/pear/pearcmd.php and add this right after the < ?php line:
@ini_set('memory_limit', '16M');
That should fix the “Fatal error: Allowed memory size” error. I can now resume installing xdebug without any errors.
The reason why editing the php.ini will not fix the issue is because PECL/PEAR does not use the PHP settings, so the PEAR settings needs to be adjusted.
Hope this helps.
Search PinoyTux
Subscribe to Email Feeds
Blog Lounge
Popular Posts
Recent Posts
Drop your Card Here
Recent Comments
- Anidich1 on Tip: Add User and Generate Password Script
- Tom S on Cebu Pacific Sucks
- kadersardar on PinoyTux Spreads Some CommentLuv
- Steve on Creative Labs Threatens Third Party Driver Modder
- Barry on Free Laptops with Broadband Connection








