Testing Your Website Using an Apache Test Environment
Learn how to host your website on Apache Web Server and set up an Apache test environment to verify functionality.
Join the DZone community and get the full member experience.
Join For FreeLaunched in 1995, Apache Web Server has sometimes been considered the most popular web server on the internet. The name in itself is said to have rewritten history.
What Is Apache Web Server?
Apache Web Server is the most widely used open-source, cross-platform web server for hosting HTTP-based websites. It is free to download and is considered to be a reliable platform by a majority of internet consumers on a global scale. By November 2013, it was responsible for running 67% of all the web servers around the globe, though that popularity is now steadily decreasing.
Apache is developed and maintained by an open community of developers under the auspices of the Apache Software Foundation.
The software is available for the below mentioned operating systems:
- Unix
- FreeBSD
- Linux
- Solaris
- Novell Netware
- OS X
- Microsoft Windows
- OS/2
- TPF
- OpenVMS
- eComStation
Key features:
- Support for numerous programming languages
- Provides an authentication mechanism for user login
- Facilitates database support
- Supports Server Side Scripting
With the gradual passage of time, the popularity of Apache has been slowly fading. The major reason behind that is Nginx.
According to the above statistics presented by W3Techs.com, Nginx has developed an eminent place among web servers.
Some popular sites using Nginx are
- WordPress.com
- Pinterest.com
- 360.cn
- Twitch.tv
- Mail.ru
- Csdn.net
Wondering Which Web Server You're Using?
The answer to that lies in your website’s HTTP header, although, it is not always visible.
You may view the website’s HTTP header by using the Network tab in Chrome Dev Tools, or you can use tools like Pingdom or GTmetrix.
This method is not feasible if you are using Cloudflare or a similar service provider.
Decided on Apache? First, Set Up a Local Apache Environment
Service providers like XAMPP, LAMP, and WAMP have made it all too easy to deploy an Apache web server for hosting your locally stored website.
Step 1 → Download XAMPP → https://www.apachefriends.org/download.html
Step 2 → Start the installation and provide a directory for it.
Installation may take a couple minutes. This is how it should look once the setup is complete. Click Finish.
Step 3 → You will get a window for selecting the language. Hit Save on your preferred one.
Step 4 → After selecting the language, XAMPP will open. You need to hit Start on Apache, and that’s it! You will have Apache running.
Step 5 → Go to your browser and type http://127.0.0.1 or http://localhost:80 to verify Apache web server hosting by XAMPP by visiting the dashboard.
Local Hosting a Website Through XAMPP
I will be demonstrating this with the help of the Road Trip template.
Step 1 → Head to the Road Trip template’s link and download it.
Step 2 → Extract the download folder into XAMPP (root directory) → htdocs
Step 3 → Run Apache on XAMPP.
Step 4 → Go to your browser and enter in the URL → localhost/roadtrip.
Note that I am mentioning Road Trip after localhost because that is how I named the template’s folder in my htdocs. If you have come up with some other name, say, “roadtrip-template” then your URL would be localhost/roadtrip-template.
Now that your website is hosted, you can go on ahead and make changes in its source code using any text editor. Notepad++ and Sublime Text are my personal favorites.
To check the back-end functionality of your website, you will have to start MySQL along with Apache under the XAMPP Control Panel.
If you are not willing to use XAMPP, then you can download and install Apache from Apache Lounge.
Once you are on the website, then download either 32-bit or 64-bit, depending upon your Windows Server setting.
I will be using Apache 2.4.34 Win64 for this tutorial.
Step 2 – Extract the downloaded zip file. Extract it to the location of your server.
Step 3 – Configuring Apache:
- Locate the “httpd.conf” file and open it in any standard text editor.
- If you extracted Apache at any other directory than the default C:\Apache24 then you ought to update the configuration file accordingly.
ServerRoot C:/Apache24
→ServerRoot D:/Apache
DocumentRoot C:/Apache24/htdocs
→DocumentRoot D:/Apache/htdocs
Directory C:/Apache24/htdocs>
→Directory D:/Apache/htdocs
ScriptAlias /cgi-bin/ C:/Apache24/cgi-bin/
→ScriptAlias /cgi-bin/ D:/Apache/cgi-bin/
- You would also need make the following modification in the configuration file.
Options Indexes FollowSymLinks
→Options Indexes FollowSymLinks ExecCGI
- Remove the # symbol at the start of this line to uncomment:
AddHandler cgi-script .cgi
- Also add the line,
AddHandler cgi-script .pl
- At the end of the file, you must add this line:
ScriptInterpreterSource Registry
Step 4 – Launch Apache by going into the extracted directory. → Apache → Bin → Open Powershell here or Open Command Prompt here(Shift + Right click)
Step 5 – Test if your Apache is running by typing http://127.0.0.1. You should get the below response:
Test Your Locally Hosted Websites and Web Apps Using LambdaTest
If you are looking for something simpler than XAMPP to serve your purpose of testing on Apache test environment, then let me inform you about LambdaTest.
LambdaTest provide a feature to test your locally hosted webpages using the tunnel hosted through LambdaTest cloud servers. You can perform testing on simple and plain HTML, CSS, Python, PHP etc. similar web files that are stored on your local system.
Performing a real-time interactive cross browser testing is not only easy but is also helpful in figuring out whether the new feature is supported through multiple browsers prior to launching it into your Production environment.
LambdaTest has a Step-by-Step guide related to Tunnel configuration for Testing Locally Hosted Websites and Web apps.
You can also check how the template would appear on a different browser in a different OS.
Published at DZone with permission of Harshit Paul, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.
Comments