VirtualHost Apache 问题 - 子域名

VirtualHost Apache 问题 - 子域名

这开始让我发疯,我确信这很容易解决,我只是错过了一些东西。

我在服务器上安装了 ISPConfig 3,并且正在调整一些 apache 配置文件以尝试获取以下设置:

  • dbadmin.pixelfolio.co.uk - 显示 phpmyadmin
  • panel.pixelfolio.co.uk - 显示 ISPConfig 面板
  • www.pixelfolio.co.uk 显示客户文件夹
  • pixelfolio.co.uk 显示与上面相同的客户端文件夹

我有指向所有这些的同一 IP 的 DNS 记录。

在我当前的设置中,所有内容都显示当前页面,除了 pixelfolio.co.uk(没有 www),出于某种原因,它显示 phpmyadmin。如果我注释掉 phpmyadmin vhost,它会显示 ISPConfig 面板!我希望它显示与 www.pixelfolio.co.uk 相同的内容

apache/conf.d/phpmyadmin.conf

#Alias /phpmyadmin /usr/share/phpmyadmin

<Directory /usr/share/phpmyadmin>
        Options FollowSymLinks
        DirectoryIndex index.php

        <IfModule mod_php5.c>
                AddType application/x-httpd-php .php

                php_flag magic_quotes_gpc Off
                php_flag track_vars On
                php_flag register_globals Off
                php_value include_path .
        </IfModule>

</Directory>

# Authorize for setup
<Directory /usr/share/phpmyadmin/setup>
    <IfModule mod_authn_file.c>
    AuthType Basic
    AuthName "phpMyAdmin Setup"
    AuthUserFile /etc/phpmyadmin/htpasswd.setup
    </IfModule>
    Require valid-user
</Directory>

# Disallow web access to directories that don't need it
<Directory /usr/share/phpmyadmin/libraries>
    Order Deny,Allow
    Deny from All
</Directory>
<Directory /usr/share/phpmyadmin/setup/lib>
    Order Deny,Allow
    Deny from All
</Directory>

<VirtualHost *:80>
        ServerName pixelfolio.co.uk
        ServerAlias dbadmin.pixelfolio.co.uk
        DocumentRoot /usr/share/phpmyadmin
</VirtualHost>

apache/站点可用/ispconfig.vhost

######################################################
# This virtual host contains the configuration
# for the ISPConfig controlpanel
######################################################

# Listen 8080
#NameVirtualHost *:80

<VirtualHost *:80>
  ServerAdmin webmaster@localhost
  ServerName pixelfolio.co.uk
  ServerAlias panel.pixelfolio.co.uk

  <IfModule mod_fcgid.c>
    DocumentRoot /var/www/ispconfig/
    SuexecUserGroup ispconfig ispconfig
    <Directory /var/www/ispconfig/>
      Options Indexes FollowSymLinks MultiViews +ExecCGI
      AllowOverride AuthConfig Indexes Limit Options FileInfo
      AddHandler fcgid-script .php
      FCGIWrapper /var/www/php-fcgi-scripts/ispconfig/.php-fcgi-starter .php
      Order allow,deny
      Allow from all
    </Directory>
  </IfModule>

  <IfModule mod_php5.c>
    DocumentRoot /usr/local/ispconfig/interface/web/
    AddType application/x-httpd-php .php
    <Directory /usr/local/ispconfig/interface/web>
      Options FollowSymLinks
      AllowOverride None
      Order allow,deny
      Allow from all
          php_value magic_quotes_gpc        0
    </Directory>
  </IfModule>

  # ErrorLog /var/log/apache2/error.log
  # CustomLog /var/log/apache2/access.log combined
  ServerSignature Off

  <IfModule mod_security2.c>
    SecRuleEngine Off
  </IfModule>

  # SSL Configuration
 # SSLEngine On
 # SSLCertificateFile /usr/local/ispconfig/interface/ssl/ispserver.crt
 # SSLCertificateKeyFile /usr/local/ispconfig/interface/ssl/ispserver.key

</VirtualHost>

<Directory /var/www/php-cgi-scripts>
    AllowOverride None
    Order Deny,Allow
    Deny from all
</Directory>

<Directory /var/www/php-fcgi-scripts>
    AllowOverride None
    Order Deny,Allow
    Deny from all
    </Directory>

apache/sites-available/pixelfolio.co.uk.vhost

<Directory /var/www/pixelfolio.co.uk>
    AllowOverride None
    Order Deny,Allow
    Deny from all
</Directory>

<VirtualHost *:80>
    DocumentRoot /var/www/pixelfolio.co.uk/web

    ServerName pixelfolio.co.uk
    ServerAlias www.pixelfolio.co.uk pixelfolio.co.uk
    ServerAdmin [email protected]

    ErrorLog /var/log/ispconfig/httpd/pixelfolio.co.uk/error.log

    Alias /error/ "/var/www/pixelfolio.co.uk/web/error/"
    ErrorDocument 400 /error/400.html
    ErrorDocument 401 /error/401.html
    ErrorDocument 403 /error/403.html
    ErrorDocument 404 /error/404.html
    ErrorDocument 405 /error/405.html
    ErrorDocument 500 /error/500.html
    ErrorDocument 502 /error/502.html
    ErrorDocument 503 /error/503.html

    <IfModule mod_ssl.c>
    </IfModule>

    <Directory /var/www/pixelfolio.co.uk/web>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
        Options FollowSymLinks
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>

     # Clear PHP settings of this website
    <FilesMatch "\.ph(p3?|tml)$">
        SetHandler None
    </FilesMatch>
    # php as fast-cgi enabled
        # For config options see: http://httpd.apache.org/mod_fcgid/mod/mod_fcgid.html
    <IfModule mod_fcgid.c>
        IdleTimeout 300
        ProcessLifeTime 3600
        # MaxProcessCount 1000
        DefaultMinClassProcessCount 0
        DefaultMaxClassProcessCount 100
        IPCConnectTimeout 3
        IPCCommTimeout 360
        BusyTimeout 300
    </IfModule>
    <Directory /var/www/pixelfolio.co.uk/web>
        AddHandler fcgid-script .php .php3 .php4 .php5
        FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
        Options +ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    <Directory /var/www/clients/client1/web1/web>
        AddHandler fcgid-script .php .php3 .php4 .php5
        FCGIWrapper /var/www/php-fcgi-scripts/web1/.php-fcgi-starter .php
        Options +ExecCGI
        AllowOverride All
        Order allow,deny
        Allow from all
    </Directory>
    # add support for apache mpm_itk
    <IfModule mpm_itk_module>
      AssignUserId web1 client1
    </IfModule>

    <IfModule mod_dav_fs.c>
          # Do not execute PHP files in webdav directory
      <Directory /var/www/clients/client1/web1/webdav>
            <FilesMatch "\.ph(p3?|tml)$">
          SetHandler None
        </FilesMatch>
      </Directory>
      DavLockDB /var/www/clients/client1/web1/tmp/DavLock
      # DO NOT REMOVE THE COMMENTS!
      # IF YOU REMOVE THEM, WEBDAV WILL NOT WORK ANYMORE!
      # WEBDAV BEGIN
      # WEBDAV END
    </IfModule>


</VirtualHost>

apache/站点可用/默认

<VirtualHost *:80>
        ServerAdmin webmaster@localhost

        DocumentRoot /var/www
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

答案1

ServerName是虚拟主机的规范名称;你应该不是在每个 VirtualHost 中输入pixelfolio.co.uk。如果虚拟主机只有一个名称,则不需要任何ServerAlias

就你的情况来说,你应该:

ServerName dbadmin.pixelfolio.co.uk

在 PHPMyAdmin 的配置文件中,

ServerName panel.pixelfolio.co.uk

在 ISPConfig 的配置文件中,等等。

在主网站的配置文件中,您应该有:

ServerName www.pixelfolio.co.uk
ServerAlias pixelfolio.co.uk

我希望这可以解决问题!

相关内容