- New in httpd 2.4: If, ElseIf, and Else. Over the coming weeks, I'm going to be writing several articles about new features in Apache httpd 2.4. To me the most compelling reason to upgrade to Apache 2.4 today is the directive, so that's where I'll start.
- The Apache HTTP Server Project is a collaborative software development effort aimed at creating a robust, commercial-grade, featureful, and freely-available source code implementation of an HTTP (Web) server.
- The Apache HTTP Server Project.
- An Apache web server, behind a load balancer or proxy server, must produce log records containing the client IP information as the source and destination and not the load balancer or proxy IP information with each event. Apache web server logging capability is critical for accurate forensic analysis.
Apache is a popular open-source, cross-platform web server that is, by the numbers, the most popular web server in existence. It’s actively maintained by the Apache Software Foundation.
Keep Server Online If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
Some high-profile companies using Apache include Cisco, IBM, Salesforce, General Electric, Adobe, VMware, Xerox, LinkedIn, Facebook, Hewlett-Packard, AT&T, Siemens, eBay, and many more (source).
In addition to its popularity, it’s also one of the oldest web servers, with its first release all the way back in 1995. Many cPanel hosts utilize Apache today. Like other web servers, Apache powers the behind-the-scenes aspects of serving your website’s files to visitors.
Because Apache doesn’t perform as well in some benchmarks, especially for static websites or websites with high traffic, Kinsta uses the NGINX web server instead of Apache. Though NGINX hasn’t been around for as long as Apache, it’s quickly grown in popularity and market share since its launch in 2004.
How Does Apache Work? Web Server Basics Explained
While there’s a lot of complexity underpinning how a web server functions, the basic job of all web servers is to accept requests from clients (e.g. a visitor’s web browser) and then send the response to that request (e.g. the components of the page that a visitor wants to see).
The Apache web server has modules which add more functions to its software, such as MPM (for handling multi-processing modes) or mod_ssl
for enabling SSL v3 and TLS support (suggested reading: TLS vs SSL). Some common features seen in Apache include:
- IPv6
- FTP
- Perl, Lua, and PHP
- Bandwidth throttling
- WebDAV
- Load balancing
- URL rewriting
- Session tracking
- Geolocation based on IP address
While a web server is an essential part of any website, it’s important to note that casual WordPress users are unlikely to interact with their web server directly most of the time.
Apache vs Nginx Usage Stats
When you look at every single website on the Internet, Apache is the most popular web server. It powers 47% of the websites with a known web server, according to W3Techs.
However, Apache’s usage greatly drops when you start looking at the web’s most highly trafficked sites. Apache only powers:
- 27.1% of the 100,000 most popular sites
- 21.5% of the 10,000 most popular sites
- 16.2% of the 1,000 most popular sites
This drop-off likely stems, at least in part, from Apache’s lower benchmarks for high traffic websites.
Conversely, NGINX, the web server that Kinsta uses, is used by a majority of high-traffic sites, powering:
- 56.1% of the 100,000 most popular sites
- 63.2% of the 10,000 most popular sites
- 57% of the 1,000 most popular sites
If you check the Google Search trends since 2004, you can see this trend play out where Apache’s popularity (as a search term) is decreasing while NGINX’s is creeping up.
How To Check Which Web Server You’re Using
If you want to see whether you’re using Apache or NGINX, you can often (but not always) look at your site’s HTTP header.
To view your site’s HTTP header, you can:
- Use the Network tab of Chrome Developer Tools
- Use a tool like Pingdom or GTmetrix
Apache HTTP header
This method may not work if you’re using a service like Cloudflare, though.
Apache and the Apache feather logo are trademarks of The Apache Software Foundation.
If you enjoyed this tutorial, then you’ll love our support. All Kinsta’s hosting plans include 24/7 support from our veteran WordPress developers and engineers. Chat with the same team that backs our Fortune 500 clients. Check out our plans
Apache Server 2.4.29
New in httpd 2.4: If, ElseIf, and Else
Over the coming weeks, I'm going to be writing several articles about new features in Apache httpd 2.4. To me the most compelling reason to upgrade to Apache 2.4 today is the <If> directive, so that's where I'll start.
Related documentation:
This is something that people have been asking for since the very first day I was involved in Apache stuff - the ability to insert conditional statements in configuration files. And now that it's here, it's everything we wanted. Even a bit more.
The <If> directive may be used in all contexts (server config, virtual host, directory, .htaccess) and is evaluated at request time to effect the behavior of the server.
Some of the things you might use this directive for, you've been using mod_rewrite for up until now, so one of the side-effects of this directive is that we can reduce our reliance on mod_rewrite's complex syntax for common situations. Over the coming months, more examples will be added to the documentation, and we'll have a recipe section with many of the same sorts of scenarios that are in the mod_rewrite recipe section.
Unix-like
Let's start with a few simple examples so that you can see how it might be used. Consider a case where you have a website, www.wooga.com, and you want to compel people to use the www prefix for all requests. In the distant past, you may have used mod_rewrite for this, but here it is stated more clearly with the If directive:
In plain language, that says 'if the host request header isn't www.wooga.com, redirect the request to www.wooga.com.'
In fact, most of the commonest uses of mod_rewrite can now be replaced with the If directive, making them easier to read, and, therefore, less prone to error, and the redirect looping that so often plagues RewriteRule-based solutions.
For more complex scenarios, there's also <ElseIf> and <Else> directives, so that you can create multi-step if ... elseif ... elseif ... else logic flows in your configuration files.
These directives may be used in any scope - main configuration, virtual hosts, directories, or .htaccess files - and so give you significantly more power for conditional configurations than you ever had before.
The term in the If statement can be any request header ($req) or environment variable ($env), or many other values. Expressions in these comparisons can be fairly complicated, as they can use the new expression syntax which is another major enhancements in httpd 2.4, and an article for another day.
See Full List On Stigviewer.com
As with many features that are brand new in 2.4, you can expect more detailed official documentation in the near future, complete with many examples. For now, I'd encourage you to study the expression syntax documentation, and experiment.
Posted at 02:34PM Mar 02, 2012 by rbowen in General | |