Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

Jan 012010
 

Increase PHP memory limit

Answer:

If you experienced error such as "Fatal error: Allowed memory size of 16777216 bytes exhausted ", you would need to increase the memory limit of your PHP, by editing the php.ini

vi /etc/php.ini

Locate and set

memory_limit = 32M ;

Try it with the number you need.

Jan 012010
 

Turn off PHP error messages?

Answer:

In a production server, you should always turn off PHP error messages to be displayed for public, to do so, edit the php.ini

E.g.

vi /etc/php.ini

And turn off display_errors

display_errors = Off

Oct 092009
 

Should I always use single-quotes for PHP strings?

Answer:

Some people say single-quotes string is faster than double-quotes string in PHP. But this have been rejected by the PHP's developer

Benchmarks run against PHP 5.2 and 5.3 show that parsing double-quoted 
strings with interpolation is no slower (and often faster) than single- 
quoted strings using concatenation. When simple strings with no 
variables in them are used, the performance is clearly better with 
double-quoted strings due to implementation details in the engine. See 
the benchmark posted at . 

Reference: http://groups.google.com/group/make-the-web-faster/browse_thread/thread/ddfbe82dd80408cc?pli=1

Jun 022009
 

How to compile APC module for PHP

Answer:

The following steps works in RHEL/CentOS

1. Download the latest APC from PECL

wget http://pecl.php.net/get/APC

2. Extract the APC source package and compile/install it

tar -xvf APC
cd APC-X.X.X (replace with your downloaded version)
phpize
./configure
make && make install

3. Enable APC in PHP configuration

echo "extension=apc.so" > /etc/php.d/apc.ini

4. Restart the httpd and use phpinfo() to verify if APC is running