Showing posts with label apache. Show all posts
Showing posts with label apache. Show all posts

Thursday, December 20, 2012

PHP Script Execution Nature, A Problem and Solution

Do you know that a php script cannot be executed simultaneously on a single server. Even another script which is included with a executing script also becomes unavailable for execution or being included with other script. Usually a php script with complex algorithms and multiple mysql operations takes approximately 0.005 seconds for completing execution. For usual scripting with some mysql operations and an limited amount of users, the execution nature of apache server (PHP) is perfect. But, suppose, if a script has single or multiple API request to remote servers, then it will take some extra seconds to accept the reply. By the mean time other requests will be queued and will be processed while the script becomes free.

Recently, I have created a script which has more than 25 API requests and requires around 1-2 minutes for completing the whole execution. As the script has some dependencies over some universal scripts of my application, so I needed to change something to make the system always accessible for other users. First thing came to mind was to divide the whole execution and run it on multiple execution to make sure it frees the related scripts for other users for some while. I have used a Session Variable ($_SESSION) where I have put all information required for requesting API request. For every execution of the script, now it sends only a single API request, and then frees the script and redirect to the same script for rest of the requests.

Wednesday, July 11, 2012

Apache Conflicts with Skype: Step by Step Solution

Problem:
Apache doesn't start and shows "Busy".

Description:
After installation of WAMP or XAMPP server, sometimes apache doesn't start. But other services like mysql-server or php are running perfectly. But everytime, it is showing "Busy" as warning and doesn't start when apache is commanded to "start".

Reason:
Every program uses a different port number to run on computer. Some port numbers are allocated for a specific program. Port number 80 is default for webservers. Apache is webserver and it uses "80" as default port number. If this port is already being used by another program, then it will show an warning "Busy" and cannot be started when apache is commanded to start.


Solution:
Try to find out the program which is using port number "80" and quit it. Usually "Skype" uses port number 80 as an alternative port. It is possible to make that port available without quitting "Skype".

From skype toolbar, go to Tools > Options > Advanced Settings > Connection. Then un-check Use port 80 and 443 as alternatives for incoming connections.


Saturday, March 10, 2012

Testing Webserver (httpd) at VirtualBox

Now, my challenge is to browse websites hosted in CentOS which is running in a VirtualBox window. Already installed httpd, php, mysql, perl etc. and they are working fine. I could manage to test a script using text based web browser lynx.

Now, I am going to try from host pc using graphical browser. I'll have to define a ip address at guest CentOS then try to browse it.

Before starting, I have to change network settings of virtual box for CentOS installation. I changed it at virtualBox>Settings>Network>Attached to, choose "Host-only Adapter" then clicked "Ok". Now it's ready for doing the rest.

I forgot the way how to change ip, searching, but finding nowhere. What happened!! Better keep searching my notes of my B.Sc networking classes. I don't know where to find them. Wow, I have found those notes, but they are about Red Hat, I have to make them useful for my current CentOS.

Yeah, I can now browse hosted files from guest pc. Let me tell what I have done:

First, I have checked virtual host-only network ip address of host pc.
Then, I have edited ip address of guest "centos" by the following command prompt codes:

vi /etc/sysconfig/network-scripts/ifcfg-eth0

pressed "i" for inserting text into the script, started from at end of the lines there. Added these following lines:

BOOTPROTO=static
IPADDR=192.168.56.5
NETMASK=255.255.255.0
GATEWAY=192.168.56.1

For your information 192.168.56.1 is the ip address of host-only network card (virtual).

Then restarted network by the following command prompt code:

service network restart

Then, went to my graphical browser at host, and got the default centos-apache page. And also could browse my hosted files.