Apache

From My Wiki
Jump to navigation Jump to search

Main documentation: http://httpd.apache.org/docs/

ServerName and VirtualHosts

Apache can be configured to only serve one site, or to serve multiple sites. If multiple sites are to be served, VirtualHosts need to be set up. If it is only serving a single site, it may either use or not use a VirtualHost entry. If no such entry is used, ServerName needs to be the name of the site. If one or more VirtualHost entries are used, then ServerName (outside of the VirtualHost tags) may be completely different from the sites, i.e. the hostname may be used.

When using cPanel, cPanel likes to have all VirtualHosts within httpd.conf, but it doesn't want you to edit the file directly. You either need to use includes or update the templates, or use cPanel or WHM itself. See the cPanel Apache page for details.

Plesk and Interworx like to keep the specific VirtualHost data in .conf files within subdirs of the user directories. More to be added later.

Check for a module

CentOS

The httpd -l command doesn't always show everything. Grep for the module:

grep -i module /etc/httpd/conf/httpd.conf

Debian/Ubuntu

Only a very few will be listed with an apache2ctl -l command. Check /etc/apache2/mods-enabled and compare with /etc/apache2/mods-available.

To load a module:

a2enmod moduleIwant

To unload a module:

a2dismod moduleIdonotwant

Restart Apache to implement the change.

mod_rewrite

  1. Make sure it is compiled in.
  2. Make sure it is turned on: RewriteEngine On
  3. Add the line you want to rewrite. RewriteCond <whatever>
  4. Add the instructions for what to do with it. RewriteRule <whatever>
  5. Repeat RewriteRule for multiple RewriteCond statements. Close with L. May be able to use an OR after each RewriteCond instead of repeating the RewriteRule, I need to test this.

More in: htaccess

PHP Handler

Remember to check for SuExec as well.

cPanel

 /usr/local/cpanel/bin/rebuild_phpconf --current

Anything else

Check output of httpd -M or /etc/httpd/conf.d/php.conf