What do I really need to know about Apache?
December 31, 2009 9:58 AM
As a self-taught PHPer, how much do I need to understand about Apache HTTP Server? Can you recommend any sites or books that would give me a good start?
Everything I know about coding I learned informally through books and tutorials on the web. Periodically I feel like I need to backtrack and fill in some background knowledge.
I'm not asking anyone to explain Apache to me, just point me toward a resource of appropriate scope.
Thanks for your help!
Everything I know about coding I learned informally through books and tutorials on the web. Periodically I feel like I need to backtrack and fill in some background knowledge.
I'm not asking anyone to explain Apache to me, just point me toward a resource of appropriate scope.
Thanks for your help!
There is quite a bit to understand, the good news is that it's all online. The Apache documentation covers pretty much everything, but I have found most of my solutions through google questions that tackle individual problems.
Some of the things that require work setting up a site as a developer:
-as above, mod_rewrite
-similarly, installing, enabling and disabling modules
-installing php, MySQL. This is often automated, but can fail and require manual editing
-virtualhosts
-changing of basic Apache settings such as documentRoot, directory permissions, logging options, mime-types.
-htaccess, htpasswd.
posted by Sonic_Molson at 10:51 AM on December 31, 2009
Some of the things that require work setting up a site as a developer:
-as above, mod_rewrite
-similarly, installing, enabling and disabling modules
-installing php, MySQL. This is often automated, but can fail and require manual editing
-virtualhosts
-changing of basic Apache settings such as documentRoot, directory permissions, logging options, mime-types.
-htaccess, htpasswd.
posted by Sonic_Molson at 10:51 AM on December 31, 2009
The only thing you absolutely need to understand is how to keep your site secure, especially when PHP is involved. The Apache website has reasonably good general documentation, you can start here.
That said, when an Apache + PHP site has a catastrophic security failure, it is usually on the PHP side. Make sure you understand issues like SQL injection, cross site scripting (XSS), filesystem permissions, etc.
posted by worpet at 11:02 AM on December 31, 2009
That said, when an Apache + PHP site has a catastrophic security failure, it is usually on the PHP side. Make sure you understand issues like SQL injection, cross site scripting (XSS), filesystem permissions, etc.
posted by worpet at 11:02 AM on December 31, 2009
I started learning Apache using a method I have used for many computer-oriented things over the years: look up all of the configuration directives in the default httpd.conf. Just start at the top! For most purposes the default conf has too much stuff in it, which has the benefit of giving you a great overview of the server's available functionality. After that, read up on the modules that *are* installed by default and figure out if and what you want and what you don't want.
posted by rhizome at 11:10 AM on December 31, 2009
posted by rhizome at 11:10 AM on December 31, 2009
"how much do I need to understand about Apache HTTP Server?"
To answer that part of your question, I would say "not much" and qualify that with "depends what you want to do." Beyond the initial setup, I hardly ever touch httpd.conf or whatever it's moral equivalent might be on the Linux distro I'm using. If you need to install or enable the modules or software mentioned above, you will probably find the distro's package manager (e.g. apt-get or yum) will install and enable the module flawlessly, without any config editing required. If you're using a commercial hosting service, they have probably already installed and configured everything you are likely to want, and any additional stuff should be installable via their web-based control panel. If you're on Windows, the additional software like MySQL and the packages to make it work with PHP and Apache are standard Windows-style installers which you just click your way through.
If you want to learn Apache because you find it interesting or have a distinct need (feel free to share what it is, btw ;) then follow the other recommendations here. But if you want to be a better PHP programmer, just keep programming PHP until you're dreaming in it. Then hack on it some more.
posted by BrokenEnglish at 11:15 AM on December 31, 2009
To answer that part of your question, I would say "not much" and qualify that with "depends what you want to do." Beyond the initial setup, I hardly ever touch httpd.conf or whatever it's moral equivalent might be on the Linux distro I'm using. If you need to install or enable the modules or software mentioned above, you will probably find the distro's package manager (e.g. apt-get or yum) will install and enable the module flawlessly, without any config editing required. If you're using a commercial hosting service, they have probably already installed and configured everything you are likely to want, and any additional stuff should be installable via their web-based control panel. If you're on Windows, the additional software like MySQL and the packages to make it work with PHP and Apache are standard Windows-style installers which you just click your way through.
If you want to learn Apache because you find it interesting or have a distinct need (feel free to share what it is, btw ;) then follow the other recommendations here. But if you want to be a better PHP programmer, just keep programming PHP until you're dreaming in it. Then hack on it some more.
posted by BrokenEnglish at 11:15 AM on December 31, 2009
Knowing how to configure virtual hosts and mod_rewrite are both important for certain tasks that you may encounter. However, I think one of the most beneficial things you can learn is HTTP itself. It's good to at least know the basics: what a typical session looks like, the headers a typical browser will send in the request, and most importantly the headers the server will send as part of the response. As a PHP programmer in particular this last point is crucial because the duty of generating response headers is shared between those that the server itself generates and those that you as the application programmer generate (or modify from what the server has in mind.) And once you understand the semantics of these headers, you are in a much better position to solve real problems with all those configuration knobs that Apache gives you. Or in other words if you're reading about the configuration knobs that Apache offers but you're not familiar with how it will affect the response the server generates, then you can never really hope to grok the meaning behind those knobs.
On a more practical level, knowing the details of how HTTP works is truly essential for a number of areas of web development. For example performance tuning depends greatly on things like HTTP persistent connections and pipelining, as well as all the various headers relating to caching. Content encoding issues are another area that can drive you crazy unless you understand the corresponding HTTP headers, and any time you deal with file downloads you need to know about headers like Content-Type and Content-Disposition. Finally if you ever work in a high availability setting you will most likely be dealing with reverse proxys which is a situation that often requires manipulating request headers en route for various reasons.
And should you ever have to work in a different environment such as IIS or lighttp or nginx, all of the above knowledge still applies.
posted by Rhomboid at 2:12 PM on December 31, 2009
On a more practical level, knowing the details of how HTTP works is truly essential for a number of areas of web development. For example performance tuning depends greatly on things like HTTP persistent connections and pipelining, as well as all the various headers relating to caching. Content encoding issues are another area that can drive you crazy unless you understand the corresponding HTTP headers, and any time you deal with file downloads you need to know about headers like Content-Type and Content-Disposition. Finally if you ever work in a high availability setting you will most likely be dealing with reverse proxys which is a situation that often requires manipulating request headers en route for various reasons.
And should you ever have to work in a different environment such as IIS or lighttp or nginx, all of the above knowledge still applies.
posted by Rhomboid at 2:12 PM on December 31, 2009
I agree with what rhizome, brokenenglish, and rhomboid said. For the most part, what you need is a solid understanding of HTTP, and a general idea of what facilities Apache provides you. You can always look up the details, as long as you know what you don't know.
Apache's documentation is fairly clear and well-organized. Bookmark the docs page for the version of Apache you're using and refer to it when needed. Read the how-tos and tutorials bits on the side, since those will describe solutions to problems that people encounter often.
The HTTP RFC (2616) is unfortunately a bit much to digest; it's big, and a lot of the important details are actually pulled in from other RFCs (all the email and MIME stuff, plus little subprotocols like the authentication methods, are inother RFCs, and these the kinds of things you need to actually know in order to write a web application properly). I'd recommend reading their tables of contents and studying enough to generally understand what each entry in their table of contents is for but don't worry about learning the individual pieces until you need them. For the most part, Apache deals with all the finicky HTTP stuff so you don't need to. But you still need to understand the meaning and syntax of a lot of the entity headers.
posted by hattifattener at 3:31 PM on December 31, 2009
Apache's documentation is fairly clear and well-organized. Bookmark the docs page for the version of Apache you're using and refer to it when needed. Read the how-tos and tutorials bits on the side, since those will describe solutions to problems that people encounter often.
The HTTP RFC (2616) is unfortunately a bit much to digest; it's big, and a lot of the important details are actually pulled in from other RFCs (all the email and MIME stuff, plus little subprotocols like the authentication methods, are inother RFCs, and these the kinds of things you need to actually know in order to write a web application properly). I'd recommend reading their tables of contents and studying enough to generally understand what each entry in their table of contents is for but don't worry about learning the individual pieces until you need them. For the most part, Apache deals with all the finicky HTTP stuff so you don't need to. But you still need to understand the meaning and syntax of a lot of the entity headers.
posted by hattifattener at 3:31 PM on December 31, 2009
I really appreciate all these answers. This gives me plenty to start with.
"You can always look up the details, as long as you know what you don't know."
-That's how I roll!!
rhizome, great suggestion about working through httpd.conf.
Thanks again everyone!
posted by verymystery at 9:27 PM on December 31, 2009
"You can always look up the details, as long as you know what you don't know."
-That's how I roll!!
rhizome, great suggestion about working through httpd.conf.
Thanks again everyone!
posted by verymystery at 9:27 PM on December 31, 2009
This thread is closed to new comments.
posted by gregjones at 10:20 AM on December 31, 2009