---------------------------- This section helps you to setup Apache to require authentication for accessing a certain resource from your webserver. To do this you need to do some modifications in httpd.conf file, or if you are not allowed, in a .httaccess file which you place in the directory that you want to protect. If you have access to httpd.conf file, you should place the following lines into Directory tag for your location: <Directory "/path/to/your/directory"> AuthType Basic AuthName "Restricted Files" AuthUserFile /path/to/your/directory/.htpasswd Require valid-user </Directory> and after that restart httpd server. If you cannot access httpd.conf file you should place a file named .htaccess in the root of your directory that you want to protect containing th e followings: AuthType Basic AuthName "Restricted Files" AuthUserFile /path/to/your/directory/.htpasswd Require valid-user For this to take effect, httpd.conf file must contain the following into Directory tag for your location: <Directory "/path/to/your/directory"> AllowOverride AuthConfig </Directory> To generate the .htpasswd file, run: htpasswd -c /path/to/your/directory/.htpasswd user where user is the user that you want to have access to that directory. You will be asked for password and the .htpasswd file will be generated.
------------------------------------ Apache allows you to run multiple web sites on just one IP address, by setting up multiples virtual hosts. To setup a virtual host on Apache web server you must add the following to httpd.conf: httpd.conf ------------------------------------------------------------------------------------------------------ NameVirtualHost * <VirtualHost *> ServerAdmin root@example DocumentRoot /home/www/htdocs ServerName www.example.com ServerAlias example.com ErrorLog /home/www/logs/example.com_error_log CustomLog /home/www/logs/example.com_access_log common </VirtualHost> ------------------------------------------------------------------------------------------------------ end httpd.conf The explanations for the above are: ServerAdmin - the mail for the person responsable for the website DocumentRoot - the path on the server where the documents for the site are located ServerName - the domain/subdomain name for which this server will respond ServerAlias - if you want your server to respond for other aliases, for example for domain name without a leading www. ErrorLog, CustomLog - the paths to the logs Repeat last section ( between VirtualHost tag) for all the domains and subdomains you want to setup.
|