Archive for the PHP/Mysql Category

Error PHP Fatal error: Out of memory (allocated 24641536) (tried to allocate 24381441 bytes) on cPanel server with php scripts

Posted in Cpanel/WHM, PHP/Mysql on May 2, 2012 by Aparna Murthy

Today came across with the memory exhausted error and while investigation note that after increasing the memory in server php.ini file even though increased php memory limit for the particular user as server is suphp enabled, but did not help… 😦 😦

While browsing the site I find the error as below under error logs ::
==========================================
[root@server/home/username/public_html]# tail -f error_log
[01-May-2012 20:45:55] PHP Fatal error:  Out of memory (allocated 24641536) (tried to allocate 24381441 bytes) in /home/username/public_html/filename.php on line 117
==========================================

——————————————————
Soution 1 ::

1. If server is suphp enabled then do as below ::

>> create Or copy server php.ini under public_html as below :

#cp /usr/local/lib/php.ini /home/username/public_html

Then open the php.ini file

# vi  /home/username/public_html/php.ini

Find for the memory_limit parameter and change the value as below :

memory_limit = 32 MB

To

memory_limit = 64 MB

Save the file.

>> Now open the .htaccess file under your public_html

#vi /home/username/public_html/.htaccess

and enter the code below :

suPHP_ConfigPath /home/username/public_html

Save the file.

2. Now try to access your page again and check if that help to resolve the issue.
——————————————————

In my case solution 1 did not help and then I checked the issue further and came to know that the issue was with the apache memory limit. I did check as below :

——————————————————
Solutions 2::

1. Checked the parameter RLimitMEM  under apache configuration file.

# vi /etc/httpd/conf/httpd.conf

Find for RLimitMEM

you will see something like below :

RLimitMEM 154857600 154857600
RLimitCPU 150 200
RLimitNPROC 25 30

Just increase the value of RLimitMEM , In my case I did as below ::

RLimitMEM 184857600 184857600

NOTE :: if you don’t find the value in httpd.conf, please do check in the file /etc/httpd/conf/includes/pre_main_global.conf

and then restart apache on the server.

# service httpd restart
——————————————————

and now try to access your site. your site will work like a charm without any error.

PHP Setting change, register_globals and more using htaccess

Posted in PHP/Mysql on April 5, 2012 by Aparna Murthy

In order to change your PHP  setting, from upload limit to register_globals just do the follow:

1) Create a file called .htaccess inside your public_html
(Note: if you want to change PHP 5 settings, you need to put these values in a file called php.ini inside the folder of the php files and
remove the php_value part)

1) Create a file called .htaccess inside your public_html

(Note: if you want to change PHP 5 settings, you need to put these values in a file called php.ini inside the folder of the php files and  remove the php_value part)

2) Edit it and add the line below in this format

php_value value_name newvalue

example:

# to turn off register_globals

php_value register_globals off

#To change upload size limit to 100mb (Make sure add both lines below into htaccess)

php_value upload_max_filesize 100M

php_value post_max_size 100M

# to change php script execution time

php_value max_execution_time 1000

# to turn mod_rewrite on

RewriteEngine on

php_value upload_max_filesize 100M

php_value post_max_size 100M

php_value output_buffering on

php_value max_execution_time 1000

php_value max_input_time 1000

php_value session.gc_maxlifetime 14400

RewriteEngine On

# Turn off mod_security filtering.

SecFilterEngine Off

# The below probably isn’t needed,
# but better safe than sorry.
SecFilterScanPOST Off

Phpmyadmin error : “The Configuration File Now Needs A Secret Passphrase (blowfish_secret)”

Posted in Cpanel/WHM, PHP/Mysql on November 19, 2010 by Aparna Murthy

After installing phpmyadmin on one of my client server (Centos), I had to face above error after login into phpmyadmin at the bottom of the phpmyadmin page.

Error :

==============================================================”The Configuration File Now Needs A Secret Passphrase (blowfish_secret)”

==============================================================

I tried this Soution which resolved the issue :

Solution :
Copy sample Configuration File To Real Configuration File:
# cp -p config.sample.inc.php config.inc.php

If you have already copied the file just locate it and go to the file :
#vi config.inc.php
Find the below line :  ==============================================================$cfg[‘blowfish_secret’]  ‘ ‘; /* YOU MUST FILL IN THIS FOR COOKIE AUTH!  */

==============================================================
Probably on the line number 16 or 18.
You can see its not set, so you need to update  the Blowfish Secret here.
After doing this, Try to visit your phpmyadmin url again and you will see the error is disappeared.

 
Cheers!!!! Njoy!!!

 

 

 

 

How to check if a server is Suexec or not

Posted in PHP/Mysql on December 21, 2009 by Aparna Murthy

To check the server is Suexec or not? follow the one of the steps which suitable with your access rights:

1) Login into you server with the root login details and run following command

[root@ ~]#/usr/local/cpanel/bin/rebuild_phpconf –current

If server is Suexec then result would look like

DEFAULT PHP: 5
PHP4 SAPI: suphp
PHP5 SAPI: suphp
SUEXEC: enabled

>> If you are not sure about Shell commands then you can also check the SuExec is enabled or not? from your WHM. Login into your WHM  with root and in the menu find “Configure PHP and SuExec ”

Check the drop down box for “PHP 4/5 Handler” – and if beside that it says “suPHP” – Then your sever is SuExec enabled

>> If you are not having server root login details or WHM access.Then you can create a php file udner your account from cPanel >> File Manager and change the permissions on that file to 777 and open it in a browser. If it gives 500 Internal Server Error,  your most probably running suPHP.

>>As well as you can also create the phpinfo page under your account from your cPanel >> File manager For ex. phpinfo.php with the following code

<? phpinfo() ?>

After creating phpinfo.php page browse it http://yourdomainname.com/phpinfo.php and if it shows

<<Server API = Apache>>

then server is not running PHP in Suexec mode

And if

<<Server API = CGI>>

then the  server is running PHP in Suexec mode

Than you.

phpMyAdmin – Error (Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.)

Posted in PHP/Mysql on October 27, 2009 by Aparna Murthy

 

Problem:
Getiing “phpMyAdmin – Error  (Cannot start session without errors, please check errors given in your PHP and/or webserver log file and configure your PHP installation properly.)” error while accessing phpmyadmin for the domain.
1st Solution:
First thing you’ll neet to do is have a look at your error logs.(Generally its here /usr/local/apache/logs/error_log) You will probably see errors referencing permission errors writing to your session directory.
You’ll just to change the permission of the session directory (chmod 777) you should be good to go.
OR
2nd Solution::
1. Login in to the Shell with the root user and then open the file using your favorite editor.
vi /usr/local/cpanel/3rdparty/etc/phpmyadmin/php.ini
2. Search for [Session] and change the following
FROM:
—–
session.save_handler = sqlite
session.save_path  = /var/cpanel/userhomes/cpanelphpmyadmin/sessions/
—–
TO
—–
session.save_handler = files
session.save_path = /tmp
—–
Save & Exit
3. Restart apache  on the same.

 

🙂 🙂 🙂

 

How to install Zend Optimizer with Ioncube Loader on plesk

Posted in PHP/Mysql on July 30, 2009 by Aparna Murthy

Many users wanted to install these addon php modules to the Plesk VPS configurations.Please go thorugh the following instaructions:

Login to server as root

Run:

# wget -q -O – http://www.atomicorp.com/installers/atomic.sh | sh

This will download, and setup the atomic yum channel for you.

During this, you will be asked if you wish to “add the Plesk yum repository to the system?”. You must answer Yes to this, by press y and then pressing enter. You will also be asked for which version of Plesk – it is STRONGLY recommended to use plesk 8.

You now have everything you need to install Zend Optimizer and Ioncube easily. Run the following command:

# yum install php-zend-optimizer php-ioncube-loader

Press “Y”

You now have everything installed, Now restart the apache

# /etc/init.d/httpd restart

And these will now be available to any php application using its features.

How to check if a server is Suexec or not?

Posted in PHP/Mysql on July 29, 2009 by Aparna Murthy

To check the server is Suexec or not? follow the one of the steps which suitable with your privileges

1) Login into you server with the root login details and run following command

[root@xx.xx.xx.xx ~]#/usr/local/cpanel/bin/rebuild_phpconf –current

If server is Suexec then result would look like

DEFAULT PHP: 5
PHP4 SAPI: suphp
PHP5 SAPI: suphp
SUEXEC: enabled

Installing PHPmyadmin on Centos Server

Posted in PHP/Mysql on July 11, 2009 by Aparna Murthy

Login as root and follow the commands below:

# cd /var/www/html
# wget -c http://prdownloads.sourceforge.net/phpmyadmin/phpMyAdmin-2.11.3-english.tar.gz
# tar xvfz phpMyAdmin-2.11.3-english.tar.gz
# mv phpMyAdmin-2.11.3-english phpmyadmin
# cd phpmyadmin
# cp config.sample.inc.php config.inc.php
# vi config.inc.php
:
$cfg[‘Servers’][$i][‘auth_type’] = ‘http‘; # default is cookies
:
# service httpd restart

You can test by open phpmyadmin by this link :

http://your.domain.com/phpmyadmin/

You should be find pop up for insert your user name and password.

Creating database and adding user using CLI

Posted in PHP/Mysql on June 14, 2009 by Aparna Murthy

For Creating a MySQL database and adding a user from CLI go through the following: Go to the mysql prompt and run the following commands:

mysql -uroot -p mysql> CREATE DATABASE dbname;

mysql> GRANT ALL PRIVILEGES ON dbname.* TO user@localhost IDENTIFIED BY ‘password-goes-here’ WITH GRANT OPTION;

Where dbname will be replace with database name and user will with username which need to add.


PHP4 is showing instead of PHP5(which is installed on server)

Posted in PHP/Mysql on June 14, 2009 by Aparna Murthy

> Check the php verion installed on server 
Run: php -v

>>Search for the perticular:
/scripts/whoowns domainname

it will return with username of account.

>>Go into the home directory of the perticular account:
cd /home/~username

>>Check the .htaccess file
>>In.htaccess file look for the line:

# Use PHP4 as default
AddHandler application/x-httpd-php4.php

Replace this line with the following line:

# Use PHP5 as default
AddHandler application/x-httpd-php5 .php

It will run PHP5 by default.

>>Restart the httpd.
Run: /etc/init.d/httpd restart