Posts Tagged ‘Apache’

PHP Fatal Error: Call To Undefined Function Json_encode()

I just run into a problem, I deployed my php application on one of the production sever and a link started throwing the error PHP Fatal error: Call to undefined function json_encode()in the apache error logs. Here is what I did to fix it.

The code was working fine on my localhost machine because the local machine contained php of version 5.2.4 and php versions greater than 5.2 have json module built in. But on my production sever, Php version was 5.1.6. It was hactic process to upgrade the php version on non managed server.

Dont go around, the module can easily be installed via Pecl Module. But for Pecl module, its necessary that pear should be already present on your server. Install Pear Library with the following command:

yum install php-pear

Once the installation is over, you are ready to rock, run the following command to install json.

pecl install json

Once the installation is over, you will find json.so file located in you php modules directory. Normally php modules directory is /usr/lib/php/modules. Once you are sure that this module is available, simple add the following line to you /etc/php.ini file.

extension=json.so;

Now dont forget to restart apache service.

service httpd restart

Type php -m and you will find json loaded along with other modules of the php. Now your code will also work fine. Cheer!

How To Calculate The Current Process Size Of Apache

Apache is a well known web server which is used to handle enterprise level applications. When tweaking and optimizing apache, many factors are involved. One of the core thing is determine the process size of apache and according to this process size value, adjust the level of your system’s RAM.

Determining the process size is very easy, you can find it by running ps command with the appropriate switches. In the out put have a look at the RSS entry and you will find value of apache process size in KiloBytes there.

ps -ylC httpd --sort:rss

Whats Is Apache Status Worker And How To Configure It

Apache is one of the most commonly used web server around the world. It has the ability to host mid level to enterprise applications and offers many areas to optimize and tweak its different factors. I was preparing my Redhat Enterprise box for high load and apache status worker is one of the core thing that should be taken care of.  It offers a very useful web based interface to view the status of the apache. You can see the consumed and free RAM along with detailed information about each httpd process.

Lets see how we can configure it in Apache, it very simple. First of all make sure that you have ExtendedStatus flag set to On in httpd.conf.

ExtendedStatus On

» Read more

How To Password Protect Directory Access Via Apache (HTTP)

I ran into a problem today, my team member asked me to password protect a directory in such a way that when someone access it via Web URL, it should first ask for password. Once user is validated then it should lead him/her to the actual web page.

Guess what is the most easy way to do it, I followed the following method and it worked perfectly. Since Apache is the web server and usually it is handling hundreds of websites on a single server so it is not a wise way to make changes in its configuration file often. We will achieve it via .htaccess.

Now go into the directory in which you wish to apply this restriction and create a .htaccess file (off-course if this does not exist already) and add the following lines with necessary modifications ( The only modification will be that you will need to change the path of the root directory of your applicaton).

AuthType Basic

AuthName “Admin”

AuthUserFile “/var/www/html/MYAPP/passwd”

require valid-user

Now create a file with name passwd at /var/www/html/MYAPP/ path and add the username and password in the following formate:

admin:K1/BaQTbqe0Eo

where admin is the username and the encrypted value after: is the password.

Restart apache service and you will be seeing the login prompt appearing on application launch.