简体   繁体   English

用于子域的DigitalOcean Apache 2 Debian 7虚拟主机

[英]DigitalOcean Apache 2 Debian 7 Virtual Host for subdomain

I have VPS on digitalocean.com. 我在digitalocean.com上有VPS。 To DNS for example.com I added cname subdomain. 在example.com的DNS中,我添加了cname子域。

Server work on Debian 7 with apache 2.2 and php 5.5 使用Apache 2.2和PHP 5.5在Debian 7上运行服务器

I have problem with subdomain configuration. 我对子域配置有疑问。 I tried all tutorial form first 4 google pages for "apache subdomain configuration". 我尝试了所有教程形式的“ apache子域配置”的前4个google页面。

But still after request subdomain.example.com response is example.com content. 但是,仍然在请求subdomain.example.com响应之后是example.com内容。

I use: 我用:

apachectl -t -D DUMP_VHOSTS

Result is: 结果是:

    apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
[Thu Nov 28 15:58:58 2013] [warn] VirtualHost xxx.xxx.xx.xxx:80 overlaps with VirtualHost xxx.xxx.xx.xxx:80, the first has precedence, perhaps you need a NameVirtualHost directive
[Thu Nov 28 15:58:58 2013] [warn] NameVirtualHost *:80 has no VirtualHosts
VirtualHost configuration:
xxx.xx.xxx.xxx:80     subdomain.example.com (/etc/apache2/sites-enabled/subdomain.example.com:1)
127.0.0.1:80           xxx.xxx.xx.xxx (/etc/apache2/sites-enabled/000-default:1)
xxx.xxx.xx.xxx:80      example.com (/etc/apache2/sites-enabled/example.com:1)

/etc/apache2/sites-available/example.com I have link i sites-enabled /etc/apache2/sites-available/example.com我已启用网站链接

<VirtualHost xxx.xxx.xx.xxx:80>
  ServerName  example.com
  ServerAdmin email@email.com
  DocumentRoot /var/www/example.com

  <Directory /var/www/example.com>
<IfModule sapi_apache2.c>
        php_admin_flag engine on
    </IfModule>
    <IfModule mod_php5.c>
        php_admin_flag engine on
    </IfModule>
    Options Includes FollowSymLinks MultiViews
    AllowOverride All
    DirectoryIndex index.php index.html index.html5
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  ErrorDocument 404 /404/

  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

</VirtualHost>

/etc/apache2/sotes-available/subdomain.example.com I have link in sites-enabled /etc/apache2/sotes-available/subdomain.example.com我在启用了网站的站点中具有链接

:80>
  ServerName  subdomain.example.com
  ServerAdmin mail@mail.com
  DocumentRoot /var/www/subdomain.example.com
 ServerAlias subdomain.example.com
  <Directory /var/www/subdomain.example.com>
<IfModule sapi_apache2.c>
        php_admin_flag engine on
    </IfModule>
    <IfModule mod_php5.c>
        php_admin_flag engine on
    </IfModule>
    Options Includes FollowSymLinks MultiViews
    AllowOverride All
    DirectoryIndex index.php index.html index.html5
  </Directory>

  ErrorLog ${APACHE_LOG_DIR}/error.log
  LogLevel warn
  CustomLog ${APACHE_LOG_DIR}/access.log combined

  ErrorDocument 404 /404/

  SetOutputFilter DEFLATE
  SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|ico|png)$ \ no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar)$ \no-gzip dont-vary
  SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary

  BrowserMatch ^Mozilla/4 gzip-only-text/html
  BrowserMatch ^Mozilla/4\.0[678] no-gzip
  BrowserMatch \bMSIE !no-gzip !gzip-only-text/html

</VirtualHost>

I tried too with ServerAlias, foledrs in /var/www have owner as www-data and 755 chmod. 我也尝试过ServerAlias,/ var / www中的文件拥有者为www-data和755 chmod。

Thanks in advance for any idea. 预先感谢您的任何想法。

Regards 问候

as you can see in your 2nd block, you are missing the this: 正如您在第二个区块中看到的那样,您缺少以下内容:

<VirtualHost xxx.xxx.xx.xxx:80>

and that should be configured at the beginning. 并且应该在开始时进行配置。 you need to have your server's fully qualified domain name by doing this: if you use root as user, then: nano /etc/hosts 您需要执行以下操作以获取服务器的标准域名:如果您以root身份使用root,则:nano / etc / hosts

then add this: 然后添加:

127.0.0.1       localhost

#Virtual Hosts 
12.34.56.789    example.com

then save it and restart Apache, and you're done. 然后将其保存并重新启动Apache,即可完成。

All you have to do is adding subdomain record to your domain you assigned. 您要做的就是将子域记录添加到您分配的域中。 to do so, follow the tutorial on their site at: How To Set Up and Test DNS Subdomains with DigitalOcean's DNS Panel 这样做,请按照其网站上的教程进行: 如何使用DigitalOcean的DNS面板设置和测试DNS子域

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM