Apache
From Logicalwebhost-Wiki
apache is called apache2 in debian/ubuntu and httpd in Centos/Fedora, it lives in /etc/apache2/
- tutorials here or more in-depth here
- Securing an apache server here
- main conf file is either httpd.conf or apache2.conf
- find out if apache is running
pgrep apache
- you put the virtual sites in either /etc/apache2/sites-available or /etc/httpd/conf.d
- when you get done with changing config, run /etc/init.d/apache2 reload to refresh apache
- apache 2.2 is stickier about permissions, and more likely to lock you out of a folder for shady reasons
- an example of a virtual host that works:
<VirtualHost *>
ServerName www.scooby.com
DirectoryIndex index.php
ServerAdmin your@email.com
ErrorLog /var/log/apache2/error.log
DocumentRoot /var/www/scooby/
<Directory /var/www/scooby>
Options Indexes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
or more complex with more goodies:
<VirtualHost www.example.com:80>
ServerAdmin webmaster@example.com
DocumentRoot /clients/example.com/www/
ScriptAlias /cgi-bin/ /clients/example.com/cgi/
ServerAlias example.com *.example.com
ServerName www.example.com
AddType application/x-httpd-php .html
AddHandler server-parsed .shtml
ErrorLog /clients/example.com/logs/example.com-error_log
LogFormat "%h %l %u %t \"%r\" %>s %b" common
CustomLog "|/usr/bin/cronolog /clients/example.com/logs/%Y/%m/%d/example.com-access_log" common
<Directory />
Options -Indexes FollowSymLinks MultiViews
AllowOverride None
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
- a simple alias in the beastly 2.2.52 without the dreaded 403 error, in this case to make a mirror site
Alias /mirror/ /var/mirror/
<Directory "/var/mirror">
Options Indexes Includes FollowSymLinks Multiviews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
| a2enmod rewrite | enabled modrewrite so you can make sane URL's from gobleygook |
| chmod 744 foldername | you have to chmod 744 your folders you want the browser to see, otherwise it won't |
| chmod 644 foldername/* | changes all the files in that folder to 644, the minimum permission apache will see |
| ServerAlias example.com *.example.com | points all stuff to example.com, so ftp.example.com, bob.example.com would both go to example.com |
