Dies ist eine alte Version des Dokuments!
Tips for the configuration of the Apache webserver. Unless noted otherwise, the settings were performed on a Slackware Linux system. Necessary steps for other Systems my vary slightly.
Tips refer to apache 2.x.
chmod +x /etc/rc.d/rc.httpd is necssary to start apache automatically at system boot..htaccess files, you have to set the AllowOverride directive for the document root (usually /srv/httpd/htdocs) accordingly. Amongst others, this is usually necessary fot URL Rewriting. When on doubt, set AllowOverride to all. More InfoAddDefaultCharset UTF-8 to the DocumentRoot section (<Directory „/srv/httpd/htdocs“>)Include /etc/httpd/extra/httpd-autoindex.conf to enable fancy directory listings/etc/httpd/extra/httpd-userdir.conf to enable user home directories Include, eg. http://~sandy/…
Enable php by doing the following changes in /etc/httpd/httpd.conf (old: /etc/apache/httpd.conf):
< DirectoryIndex index.html --- > DirectoryIndex index.php index.html < #Include /etc/httpd/mod_php.conf --- > Include /etc/httpd/mod_php.conf
Make sure that /etc/httpd/php.ini is identical with /etc/httpd/php.ini-recommended.
(Re)start apache with /etc/rc.d/rc.httpd restart
Test apache & php by saving the following line as /var/www/htdocs/index.php
<?php phpinfo(); ?>
Point your browser to http://localhost/. You should see infomations about your php installation there. If you get a download dialog window with something about application/x-httpd-php instead the page, especially with firefox, then empty your browser cache (you go to tools>clear private data) and try again
Note: With Slack 13.0 (PHP 5.2.10) there is a problem with semaphore creating rights. To fix this change session.save_path from /var/lib/php/ back to /tmp in /etc/httpd/php.ini 1). An alternative might be to fix the permission settings of /var/lib/php/.
Note: PHP is also a great alternative to Perl or Bash command line scripts. See PHP Manual
This section refers to Slack 11.0 which ships with Php4. Download & install Php5 Slack package:
wget 'http://ftp.gwdg.de/pub/linux/slackware/slackware-11.0/extra/php5/php-5.2.0-i486-1.tgz' upgradepkg php-5.2.0-i486-1.tgz
The upgrade script of the package keeps old php.ini & mod_php.conf. We need the new files:
cp -a /etc/apache/php.ini /etc/apache/php.ini.bak cp -a /etc/apache/php.ini-recommended /etc/apache/php.ini cp -a /etc/apache/mod_php.conf.example /etc/apache/mod_php.conf
If you made manual changes in your old php.ini, do the same with the new php.ini now.
Note: Ulike in php4 short_open_tag is off by default in php5.
Quick and dirty example with these parameters:
Create password file .htpasswd with:
htdigest -c .htpasswd 'Digest Authentication Test' testuser
Create config file .htaccess (for Apache 1.x):
AuthType Digest AuthName "Digest Authentication Test" AuthDigestFile /var/www/htdocs/digestTest/.htpasswd Require valid-user
Create config file .htaccess (for Apache 2.x):
AuthType Digest AuthName "Digest Authentication Test" AuthDigestProvider file AuthUserFile /var/www/htdocs/digestTest/.htpasswd Require valid-user
Put .htpasswd and .htaccess into /var/www/htdocs/digestTest/
Note that the manual discourages to put .htpasswd into the same directory which is to be protected, however it seems common usage. Check at least .htpasswd and .htaccess will not be displayed in your webbrowser!
More useres can be added to .htpasswd with:
htdigest .htpasswd 'Digest Authentication Test' newusername
More details at Apache manual
Create an .htaccess file in the regarding directory and add this line:
Options +Indexes
Note that the AllowOverride Directive must allow this. More: htaccess, Options
You need the NameVirtualHost directive. On Debian Lenny it is already present in /etc/apache2/ports.conf: NameVirtualHost *:80