Apache's configuration files can be used to configure how Apache operates, but they can also be used to configure PHP and how Apache httpd interacts with PHP. In this talk, Jeff explains the different ways Apache can be configured, explains many of the useful config options available for Apache modules, including our own mod_php, and showcases example of how they can be used with, and instead of, your PHP code.
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apache and PHP: Why httpd.conf is your new BFF!
1. &
PHP&Apache
Why httpd.conf is your new BFF!
Why httpd.conf is your new BFF!
PHP & Apache
Jeff Jones
AtlantaPHP
February 5th, 2009
Jump by reebs*
2. Web “Solutions Stacks”
(Thanks Wikipedia!)
LAMP
Linux Apache MySQL PHP
WAMP
Windows Apache MySQL PHP
WIMP
Windows IIS MySQL PHP
LAPP
Linux Apache PostgreSQL PHP
FAPP
FreeBSD Apache PostgreSQL PHP
Common denominator? Apache. “yellow lamp“
3. Apache Background
Since April 1996 Apache has been the most
popular HTTP server on the World Wide Web.
As of December 2008 Apache served over
51% of all websites.
“Fort Apache by PhillipC”
7. Full-Featured Web Server
Some Features...
Authentication, Authorization, Environment Variables
& Access Control Log Files
CGI: Dynamic Content w/ CGI Server Side Includes
Configuration Files URL Mapping
Content negotiation URL Rewriting
“Server” by existentist
8. Apache Configuration
By handjes
Contexts
Server config: Server wide httpd.conf and included files.
VirtualHost: <VirtualHost></VirtualHost>
Directory: Directory,DirectoryMatch,Files,FilesMatch
.htaccess: Per directory config files.
21. ErrorDocument “Coat Check Fail”
#Output a customized message.
ErrorDocument 403 quot;No Access”
#Redirect to a local URL-path.
ErrorDocument 404 /errors/404.php
#Redirect to an external URL.
ErrorDocument 500 http://example.com/5.php
22. 404 for pretty urls: Bad Idea!
(Hello mod_rewrite!)
ErrorDocument 404 index.php “Irony”
23. KeepAlive “Zombie Jeff”
KeepAlive on
KeepAliveTimeout 2
MaxKeepAliveRequests 100
44. MultiViews
Set as part of directory options
MultiViews tracks down the best file.
<Directory /usr/local/www>
Options Indexes MultiViews
</Directory>
foo
foo.html.es
foo.html.en.gz “Sniffin'”
49. Front Controller
The Front Controller Pattern is a
software design pattern listed in
several pattern catalogs. The pattern
relates to the design of web
applications. It quot;provides a
centralized entry point for handling
requests.quot;
Source: Wikipedia
50. mod_auth
Other Auth & Related Modules
mod_access
●
Access control based on client hostname or IP address
●
mod_auth_dbm
●
User authentication using DBM files
●
mod_auth_db
●
User authentication using Berkeley DB files
●
mod_auth_anon Apache 1.1 and up
●
Anonymous user access to authenticated areas
●
mod_digest
●
MD5 authentication
●
55. PHP's Apache Extension
apache_child_terminate — Terminate apache process after this request
●
apache_get_modules — Get a list of loaded Apache modules
●
apache_get_version — Fetch Apache version
●
apache_getenv — Get an Apache subprocess_env variable
●
apache_lookup_uri — Perform a partial request on a URI, returns info.
●
apache_note — Get and set apache request notes
●
apache_request_headers — Fetch all HTTP request headers
●
apache_reset_timeout — Reset the Apache write timer
●
apache_response_headers — Fetch all HTTP response headers
●
apache_setenv — Set an Apache subprocess_env variable
●
ascii2ebcdic — Translate string from ASCII to EBCDIC
●
ebcdic2ascii — Translate string from EBCDIC to ASCII
●
getallheaders — Fetch all HTTP request headers
●
“Trilions Served”
virtual — Perform an Apache sub-request
●
59. Tip of Iceberg
There are around 100 modules for Apache 1.3.x
●
There are about 300 modules for Apache 2.x
●
mod_rewrite can do amazing stuff with URIs
●
Apache can be expanded with custom modules!
●
“Ice Breaker”
60. “Books by Bowen”
Apache is a Web Server.
Don't rewrite a web server in PHP.
●
Unless you really have to.
●