[英]DigitalOcean Apache 2 Debian 7 Virtual Host for subdomain
我在digitalocean.com上有VPS。 在example.com的DNS中,我添加了cname子域。
使用Apache 2.2和PHP 5.5在Debian 7上運行服務器
我對子域配置有疑問。 我嘗試了所有教程形式的“ apache子域配置”的前4個google頁面。
但是,仍然在請求subdomain.example.com響應之后是example.com內容。
我用:
apachectl -t -D DUMP_VHOSTS
結果是:
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我已啟用網站鏈接
<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我在啟用了網站的站點中具有鏈接
: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>
我也嘗試過ServerAlias,/ var / www中的文件擁有者為www-data和755 chmod。
預先感謝您的任何想法。
問候
正如您在第二個區塊中看到的那樣,您缺少以下內容:
<VirtualHost xxx.xxx.xx.xxx:80>
並且應該在開始時進行配置。 您需要執行以下操作以獲取服務器的標准域名:如果您以root身份使用root,則:nano / etc / hosts
然后添加:
127.0.0.1 localhost
#Virtual Hosts
12.34.56.789 example.com
然后將其保存並重新啟動Apache,即可完成。
您要做的就是將子域記錄添加到您分配的域中。 這樣做,請按照其網站上的教程進行: 如何使用DigitalOcean的DNS面板設置和測試DNS子域
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.