Wordpress 将子域指向同一服务器上的目录

Wordpress 将子域指向同一服务器上的目录,wordpress,apache,debian,vps,Wordpress,Apache,Debian,Vps,我想将一个子域指向我的vps上的目录Apache/2.4.10(Debian)。我创建了一个子域,添加了一条记录和我服务器的ip。现在,当我在浏览器中打开它时,这个子域指向主域 主域名位于/var/www/wordpress。子域需要位于/var/www/Subdomain.example.com 所以在/etc/apache2/sites available我创建了subdomain.example.com.conf <VirtualHost *:80> ServerAd

我想将一个子域指向我的vps上的目录
Apache/2.4.10(Debian)
。我创建了一个子域,添加了一条记录和我服务器的ip。现在,当我在浏览器中打开它时,这个子域指向主域

主域名位于
/var/www/wordpress
。子域需要位于
/var/www/Subdomain.example.com

所以在
/etc/apache2/sites available
我创建了
subdomain.example.com.conf

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    ServerName subdomain.example.com
    DocumentRoot /var/www/subdomain.example.com

    <Directory /var/www/subdomain.example.com>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

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

</VirtualHost>
[Sat Feb 18 13:15:55.649294 2017] [alias:warn] [pid 4524] AH00671: The Alias directive in /etc/phpmyadmin/apache.conf at line 3 will     probably never match because it overlaps an earlier Alias.
VirtualHost configuration:
*:443                  examplevps.com (/etc/apache2/sites-enabled/default-ssl.conf:2)
*:80                   examplevps.com  (/etc/apache2/sites-enabled/wordpress.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
[Sat Feb 18 13:39:42.263129 2017] [alias:warn] [pid 4917] AH00671: The Alias dir                                                                   ective in /etc/phpmyadmin/apache.conf at line 3 will probably never match becaus                                                                   e it overlaps an earlier Alias.
VirtualHost configuration:
*:443                  examplevps.com (/etc/apache2/sites-enabled/default-ssl                                                                   .conf:2)
*:80                   is a NameVirtualHost
         default server subdomain.example.com (/etc/apache2/sites-enabled/subdomain.example.com.conf:1)
         port 80 namevhost subdomain.example.com (/etc/apache2/sites-enabled/                                                                   subdomain.example.com.conf:1)
                 alias subdomain.example.com
         port 80 namevhost examplevps.com (/etc/apache2/sites-enabled/wordpress.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
apache2ctl-S
after
a2ensite subdomain.example.com.conf

<VirtualHost *:80>

    ServerAdmin webmaster@localhost
    ServerName subdomain.example.com
    DocumentRoot /var/www/subdomain.example.com

    <Directory /var/www/subdomain.example.com>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride All
            Order allow,deny
            allow from all
    </Directory>

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

</VirtualHost>
[Sat Feb 18 13:15:55.649294 2017] [alias:warn] [pid 4524] AH00671: The Alias directive in /etc/phpmyadmin/apache.conf at line 3 will     probably never match because it overlaps an earlier Alias.
VirtualHost configuration:
*:443                  examplevps.com (/etc/apache2/sites-enabled/default-ssl.conf:2)
*:80                   examplevps.com  (/etc/apache2/sites-enabled/wordpress.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33
[Sat Feb 18 13:39:42.263129 2017] [alias:warn] [pid 4917] AH00671: The Alias dir                                                                   ective in /etc/phpmyadmin/apache.conf at line 3 will probably never match becaus                                                                   e it overlaps an earlier Alias.
VirtualHost configuration:
*:443                  examplevps.com (/etc/apache2/sites-enabled/default-ssl                                                                   .conf:2)
*:80                   is a NameVirtualHost
         default server subdomain.example.com (/etc/apache2/sites-enabled/subdomain.example.com.conf:1)
         port 80 namevhost subdomain.example.com (/etc/apache2/sites-enabled/                                                                   subdomain.example.com.conf:1)
                 alias subdomain.example.com
         port 80 namevhost examplevps.com (/etc/apache2/sites-enabled/wordpress.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/lock/apache2" mechanism=fcntl
Mutex mpm-accept: using_defaults
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

看起来你缺少引号了。试试这个:

<VirtualHost *:80>
    ServerName subdomain.example.com
    ServerAlias subdomain.example.com

    # DocumentRoot 
    DocumentRoot "/var/www/subdomain.example.com"

    <Directory "/var/www/subdomain.example.com">
        Options Indexes FollowSymLinks MultiViews
        AllowOverride All
        Require all granted
    </Directory>

    # Logging
    ErrorLog "${APACHE_LOG_DIR}/error.log"
    CustomLog "${APACHE_LOG_DIR}/access.log" combined
</VirtualHost>

ServerName subdomain.example.com
ServerAlias subdomain.example.com
#文档根
DocumentRoot“/var/www/subdomain.example.com”
选项索引跟随符号链接多视图
允许超越所有
要求所有授权
#伐木
ErrorLog“${APACHE\u LOG\u DIR}/error.LOG”
CustomLog“${APACHE_LOG_DIR}/access.LOG”组合

您的代码是否完整?缺少
。是的,它在我的文件中