Apache: Difference between revisions
New page |
→ServerName and VirtualHosts: pluralized |
||
| (2 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Main documentation: http://httpd.apache.org/docs/ | Main documentation: http://httpd.apache.org/docs/ | ||
= ServerName and VirtualHosts = | |||
<p>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.</p> | |||
<p>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.</p> | |||
<p>Plesk and Interworx like to keep the specific VirtualHost data in .conf files within subdirs of the user directories. More to be added later. </p> | |||
= 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== | |||
<p>Only a very few will be listed with an '''apache2ctl -l''' command. Check /etc/apache2/mods-enabled and compare with /etc/apache2/mods-available.</p> | |||
<p>To load a module:</p> | |||
a2enmod moduleIwant | |||
<p>To unload a module:</p> | |||
a2dismod moduleIdonotwant | |||
Restart Apache to implement the change. | |||
=mod_rewrite= | |||
# Make sure it is compiled in. | |||
# Make sure it is turned on: RewriteEngine On | |||
# Add the line you want to rewrite. RewriteCond <whatever> | |||
# Add the instructions for what to do with it. RewriteRule <whatever> | |||
# 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 | |||
Latest revision as of 04:34, January 15, 2021
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
- Make sure it is compiled in.
- Make sure it is turned on: RewriteEngine On
- Add the line you want to rewrite. RewriteCond <whatever>
- Add the instructions for what to do with it. RewriteRule <whatever>
- 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