In my previous article, we have seen how to install the Apache Server. Now, after installation we can confirm that whether the installation was a successful one or not, because many times even after successful installation the server doesnot starts or it doesn’t work. So lets check the it before using it with any script.
This check is very simple and effective. If the Apache server is installed successfully it will start running just after installation like any other service, also, when the system shuts down it will stop and starts automatically at the next reboot. However you can check this, and start and stop the server manually. For this just check out the right bottom end of your system, there you can see the icon. This icon shows that the apache server is installed and its service is running (green defines service started / red defines service not started), you can click on the icon and manage the server i.e. Start-Stop-Restart the service/server. If the server shows the red icon then this means the server is installed and started but its service is not running and you wont be able to run the scripts for you. This may be due to the port 80 of your system is busy with another server. For this to refer, please click here.
In this way you can test or change the Apache Service. This is at the configuration level, but how we can check whether the service helps the script to run on the server or not. Ok, lets check this too. Just go to the browser and write “htttp://localhost/” and run, if the browser prints “It Works” then it really works, 🙂 it means the server is working and can run scripts.
Or you can go to the folder – “..Apache Software FoundationApache2.2htdocs” and run the index.html file. This file will run same as that of but the path this time will be different something like-
“file:///C:/Program Files/Apache Software Foundation/Apache2.2/htdocs/index.html”
which is nothing but the path of index file. But, what can we conclude from this, its very simple, if we have to run our scripts using “localhost/code2java.html” the we have to put all our html/php/anyother files on /htdocs folder.
However, you can change this path to your level of customization. For this, you have to make the change in httpd.conf file in “..Apache Software FoundationApache2.2conf”. Open the file httpd.conf in edit mode and search for “Document Root” (around line number 175) and comment the default path, then add your customized path similar to shown in the below image.
After this, you have to do one more change, now search for “Directory” and come across something like shown in below snap. Here, just comment the default code and add the same path that you have added earlier in the Document Root.
Now, save this file and restart the Apache server and then create one test.html document and put in the customized folder, in this case the path will be “C:Examplestest.html”. Now go to the browser and run “localhosttest.html” the file will run and if it doesnt run then there has been some incorrect changes made in httpd.conf file. So, it is recommended to use the default settings.
Note : Please make it sure that you make the changes properly as it may affect the working of the server and you may get Forbidden Error message while running the scripts.
Hope this information will really help you.