Thursday, 8 October 2015

Web Hosting at Your Home : PHP and Port Forwarding Conflicts

(For the latest PDF files Merger Software please have a look at the top of the left margin, inside the red box.)
From the time that I wrote Web Hosting at Your Home (Revisited) Apache httpd server has seen many revisions. Also people might like to have PHP installed on their web server to be able to load PHP pages.

Assume your web serving computer is clean of any Apache httpd sever of previous versions such as Apache httpd server 2.2. The latest version for Windows operating system is not in the form of an exe file to be run by double clicking and automated install; it even is not compiled for Windows. It is a source file in C programming language that needs compilation.

If you know how to use MinGw or NetBeans IDE or Visual Studio then you need to compile the source and then follow other steps, you even can build an automated EXE file for execution.

The good news is that some people, Apache Lounge, already have done the compilation but still no executable GUI for installation exists. You do not need this far. You can get the compiled server, most likely a zip file, from those people and install it in your comfort.

Create an Apache server folder as near as possible to the root; that is, C:\; for instance, C:\ApacheWeb.

Then download the compiled folder. Mine is Note vc11 inside the name of the file. It shows the Visual C distribution version. You need to have your PHP to be of the same flavour, which you can download from PHP download site. Mine is, the same vc11 again. Note please that your PHP is the thread safe. Please, even if your Windows is x64 bits, do not use httpd server x64 or PHP x64 or non thread safe version if you do not like to struggle with forums and their moderators. Also use short names without dot, dash, space and such things for the folders. Behind the scene of software still we are in many aspects at 1999.

Unzip these folders one by one. Bring two unzipped folders into C:\ApacheWeb. Cut Apache24 folder from inside the httpd-2.4.16-win32-VC11 folder nd paste it in C:\ApacheWeb Rename it as Apache. Rename php-5.6.14-Win32-VC11-x86 as just Php, such that now you have two folders as C:\ApacheWeb\Apache, and C:\ApacheWeb\Php. Create a notepad txt file as MyReminder.txt and write in it, "My Apache version is and my PHP is (thread safe version)." This helps you to remember later what software you have used. Delete every other thing, but these three.

Put your folders and files of your website into C:\ApacheWeb\Apache\htdocs such that your home page to be naked there; that is C:\ApacheWeb\Apache\htdocs\home.html. Change the existing index.htm that comes as default with the Apache httpd server to indexOld.html. Copy and paste your home.html as index.html there, such that now you have both of them.

Now go to the C:\ApacheWeb\Apache\conf. Open httpd.conf file. Add three lines at the bottom

#Following  3 lines have been added by the webserver designer.
LoadModule php5_module "C:/ApacheWeb/Php/php5apache2_4.dll"
PHPIniDir "C:/ApacheWeb/Php"
AddHandler application/x-httpd-php .php

Please note that in the last line there is a space before .php

Change line 37 of the file from ServerRoot "c:/Apache24" to ServerRoot "c:/ApacheWeb/Apache"
Change line 242 of the file from DocumentRoot "c:/Apache24/htdocs" to DocumentRoot "c:/ApacheWeb/Apache/htdocs"
Change line 243 of the file from <Directory "c:/ApacheWeb/Apache/htdocs"> to <Directory "c:/ApacheWeb/Apache/htdocs">

Now you are ready to go. Open a command prompt "As Admin." Change directory to C:/ApacheWeb/Apache/bin and then type httpd.exe -t and run it, where in response you should get "syntax OK;" otherwise, correct the errors that are mentioned. If your config file becomes accepted in this way, then from the same command line run httpd.exe -k install that creates Windows service to run automatically your webserver every time that you turn on your computer. This service is named as Apache2.4 and can be checked for its properties and specifications inside the Windows management for Services. You can see that the "Description" of service comes as Apache/2.4.16 (Win32) PHP/5.6.14. This completes installation of Apache httpd server and PHP.

As in the previous post ( Web Hosting at Your Home (Revisited) ) mentioned you need to do port forwarding and inbound rule for firewall and other things mentioned in previous post.

Problem : Apache default port 80  may conflict with Skype.

Before running the install command, you might like to change the port that listens to inbound traffic. It is due to the fact that in Windows most of the people have Skype installed. Skype allows using default listening ports 80 which is also default for your Apache. Many believe that they should remove Skype to solve the conflict. This is not necessary.

Change your httpd.conf file listening port wherever you find in the text to, say, 8085, or 9191 and such. Then log into your router and change the port forwarding to 8085; also rename this rule to something else from HTTP to, say, MyWeb in the router. Go to your Windows firewall rule, too, and check if you have configured it with port 80, then change it to the new figure.

If you want to test your local host instead of http://localhost/ type it as http://localhost:8085/ .

Additionally you need to change the free dynamic host IP forwarding from the IP of your home to the new assigned port; for example if your redirecting IP is change it to All such hosts have certain helpful facility to implement this.

Problem : Visitor browser shows IP and does not show the domain name URL (IP address is shown in address bar instead of domain).

Regretfully, this shows your IP in the address bar of the visitors' browsers. For instance, you have acquired free dynamic and pointed it to, then visitors' browsers never show; but shows and you do not like your IP becomes revealed for security reasons.

Most of the free dynamic dns providers, like the one I use, NoIP, allow acquiring more than one free host name. If allowed you can solve the problem by getting a second name, e.g., Now, go and configure your free domain names in the dashboard of free provider in the following way.
  • redirect to
  • redirect to your dynamic IP, say, to
Now visitor's browser shows which is secure.

Please click on my first free domain name, and notice that you'll be redirected to my second domain name on port 8085.
Please note: this is my hobby home server and might be shut down or under my constant tweaking. Mostly it is up between 7.00 AM to 10.00PM (GMT)