Uživatelské nástroje

Nástroje pro tento web


linux-apache2-vhosts

Rozdíly

Zde můžete vidět rozdíly mezi vybranou verzí a aktuální verzí dané stránky.

Odkaz na výstup diff

Obě strany předchozí revize Předchozí verze
Následující verze
Předchozí verze
linux-apache2-vhosts [2007/12/16 21:49]
petr
linux-apache2-vhosts [2013/08/06 21:41] (aktuální)
Řádek 1: Řádek 1:
-====== Apache2 a virtualhosts ​======+====== Apache2 a virtuální domény ​====== 
 + 
 +Apache umí virtuální hosty jmenné nebo definované přímo pomocí ip adresy.
  
 ===== default host ===== ===== default host =====
  
-Abychom mohli mít pro každou virtuální doménu svůj konfigurační soubor je třeba nadefinovat default hosta, na kterém další virtuální hosti budou:+Abychom mohli mít pro každou virtuální doménu svůj konfigurační souborje třeba nadefinovat default hosta, na kterém další virtuální hosti budou. U default hosta budou jako u jediného klausule **NameVirtualHost**. U virtuálních hostů už toto nebude: 
 + 
 +<​code>​ 
 +cat /​etc/​apache2/​sites-available/​default
  
-**  **** NameVirtualHost *:80 **+NameVirtualHost *:80
 <​VirtualHost *:80> <​VirtualHost *:80>
-        ServerName ​pklfkl.dyndns.org +        ServerName ​example.com 
-        ServerAdmin webmaster@pklfkl.dyndns.org +        ServerAdmin webmaster@example.com
         DocumentRoot /var/www/         DocumentRoot /var/www/
  
Řádek 21: Řádek 25:
                 Order allow,deny                 Order allow,deny
                 allow from all                 allow from all
-                # This directive allows us to have apache2'​s default start page 
-                # in /​apache2-default/,​ but still have / go to the right place 
-                #​RedirectMatch ^/$ https://​pklfkl.dyndns.org/​ 
-        </​Directory>​ 
- 
-        <​Directory /​var/​www/​temp/>​ 
-                Options FollowSymLinks MultiViews Indexes 
-                AllowOverride None 
-                Order allow,deny 
-                allow from all 
-        </​Directory>​ 
- 
-        <​Directory /​var/​www/​soft/>​ 
-                Options FollowSymLinks MultiViews Indexes 
-                AllowOverride None 
-                Order allow,deny 
-                allow from all 
-        </​Directory>​ 
- 
-        <​Directory /​var/​www/​czfree/​temp/>​ 
-                Options FollowSymLinks MultiViews Indexes 
-                AllowOverride None 
-                Order allow,deny 
-                allow from all 
-                # This directive allows us to have apache2'​s default start page 
-                # in /​apache2-default/,​ but still have / go to the right place 
-        </​Directory>​ 
- 
-        <​Directory /​var/​www/​nvp/>​ 
-                Options FollowSymLinks MultiViews Indexes 
-                AllowOverride None 
-                Order allow,deny 
-                allow from all 
-                # This directive allows us to have apache2'​s default start page 
-                # in /​apache2-default/,​ but still have / go to the right place 
         </​Directory>​         </​Directory>​
  
         ScriptAlias /cgi-bin/ /​usr/​lib/​cgi-bin/​         ScriptAlias /cgi-bin/ /​usr/​lib/​cgi-bin/​
- 
         <​Directory "/​usr/​lib/​cgi-bin">​         <​Directory "/​usr/​lib/​cgi-bin">​
                 AllowOverride None                 AllowOverride None
Řádek 68: Řádek 36:
  
         ErrorLog /​var/​log/​apache2/​error.log         ErrorLog /​var/​log/​apache2/​error.log
- 
-        # Possible values include: debug, info, notice, warn, error, crit, 
-        # alert, emerg. 
         LogLevel warn         LogLevel warn
- 
         CustomLog /​var/​log/​apache2/​access.log combined         CustomLog /​var/​log/​apache2/​access.log combined
         ServerSignature On         ServerSignature On
- 
-    Alias /doc/ "/​usr/​share/​doc/"​ 
-    <​Directory "/​usr/​share/​doc/">​ 
-        Options Indexes MultiViews FollowSymLinks 
-        AllowOverride None 
-        Order deny,allow 
-        Deny from all 
-        Allow from 127.0.0.0/​255.0.0.0 ::1/128 
-    </​Directory>​ 
 </​VirtualHost>​ </​VirtualHost>​
  
 +</​code>​
  
 +===== 1.virtuální doména =====
  
- +Zde máme příklad prvního virtuálního hosta
- +
-Převzato z http://​www.debianhelp.co.uk/​virtualhosts.htm+
  
 <​code>​ <​code>​
- ​Example for name based virtual host in debian:- +cat /​etc/​apache2/​sites-available/​01vhost 
- +<​VirtualHost *:80> 
-Apache 2.0, the default site is instead the first file (in alphabetical order) in the /​etc/​apache2/​sites-enabled directory. After initial installation,​ there will be a symlink from 000-default in this directory to /​etc/​apache2/​sites-available/​defaultAs you can see from this, Apache 2.0 offers another level of abstraction in the Virtual Hosts by recommending putting the actual files in /etc/apache2/sites-available and then symlinking from there to /​etc/​apache2/​sites-enabledI would recommend following this convention, but it's not mandatoryIn our example above, we would create two files, ​/etc/apache2/​sites-available/​default and /etc/apache2/sites-available/​example.com. Our /etc/apache2/sites-available/​default file would look like this: +    ServerAdmin 01vhost@example.com 
- +    DocumentRoot ​/home/01vhost/www 
-NameVirtualHost * +    ServerName 01vhost.example.com 
-<​VirtualHost *> +    ErrorLog ​/var/log/apache2/01vhost-error.log 
-ServerName incorrect.com +    CustomLog ​/var/log/apache2/01vhost-access.log common
-DocumentRoot /​home/​www/​html/​default+
 </​VirtualHost>​ </​VirtualHost>​
 +</​code>​
  
-And our /​etc/​apache2/​sites-available/​example.com would look like this:+===== 2.virtuální doména =====
  
-<​VirtualHost *> +Zde máme příklad druhého virtuálního hosta
-ServerName www.example.com +
-ServerAlias example.com +
-DocumentRoot /​home/​www/​html/​example.com/​html +
-CustomLog logs/​www.example.com-access_log common +
-</​VirtualHost>​+
  
-We would then create symlinks to the /​etc/​apache2/​sites-enabled directory with the ln -s +<​code>​ 
- +cat /​etc/​apache2/​sites-available/​02vhost 
-command: ln -s /​etc/​apache2/​sites-available/​example.com ​/​etc/​apache2/​sites-enabled/​example.com. +<​VirtualHost *:80> 
- +    ServerAdmin 02vhost@example.com 
-Now we have our Virtual Hosts configured, it's time to test. To start Apache 2, type /etc/init.d/apache2 start and fire up a browser and head to www.example.com +    ​DocumentRoot ​/home/02vhost/www 
- +    ServerName 02vhost.example.com 
-Example for IP based virtual host in debian:- +    ​ErrorLog ​/var/log/apache2/02vhost-error.log 
- +    ​CustomLog ​/var/log/apache2/02vhost-access.log common
- /etc/apache2/sites-available/​example.com would look like this: +
- +
-<​VirtualHost 192.168.1.20>​ +
-ServerName www.example.com +
-ServerAlias example.com +
-DocumentRoot ​/home/www/html/example.com/html +
-CustomLog logs/​www.example.com-access_log ​common+
 </​VirtualHost>​ </​VirtualHost>​
 +</​code>​
  
-We would then create symlinks to the /​etc/​apache2/​sites-enabled directory with the ln -s +Ostatní domény se už tvoří analogickyPak už jen přidáme default hosta virtuály do povolených domén a apache zrestartujeme.
- +
-command: ln -s /​etc/​apache2/​sites-available/​example.com /​etc/​apache2/​sites-enabled/​example.com. +
- +
-Now we have our Virtual Hosts configured, it's time to test. To start Apache 2, type /​etc/​init.d/​apache2 restart and fire up browser and head to www.example.com+
  
 +<​code>​
 +ln -s /​etc/​apache2/​sites-available/​default /​etc/​apache2/​sites-enabled/​default
 +ln -s /​etc/​apache2/​sites-available/​01vhost /​etc/​apache2/​sites-enabled/​01vhost
 +ln -s /​etc/​apache2/​sites-available/​02vhost /​etc/​apache2/​sites-enabled/​02vhost
 +/​etc/​init.d/​apache2 restart
 </​code>​ </​code>​
 +
linux-apache2-vhosts.1197838148.txt.gz · Poslední úprava: 2013/08/06 21:38 (upraveno mimo DokuWiki)