如何在 Apache 2.4.7 上将 PHPMyAdmin 设置为子域?

如何在 Apache 2.4.7 上将 PHPMyAdmin 设置为子域?

我目前在将 PHPMyAdmin 设置为子域时遇到问题。我能够在 Ubuntu 12.04 上顺利完成此操作,但升级后似乎无法正确配置。这是我尝试加载的配置文件:

    <VirtualHost *:80>
    ServerName sub.domain.com
    ServerAlias www.sub.domain.com
    DocumentRoot "/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_admin_flag allow_url_fopen Off
    php_value include_path .
    php_admin_value upload_tmp_dir /var/lib/phpmyadmin/tmp
    php_admin_value open_basedir /usr/share/phpmyadmin/:/etc/phpmyadmin/$
    </IfModule>
    </Directory>
    <Directory /usr/share/phpmyadmin/libraries>
    # AllowOverride All
    # Require all granted
    Order Deny,Allow
    Deny from All
    </Directory>
    <Directory /usr/share/phpmyadmin/setup/lib>
    # AllowOverride All
    # Require all granted
    Order Deny,Allow
    Deny from All
    </Directory>
    </VirtualHost>

答案1

请按照以下步骤操作。我将使用“example”作为文件/子域名。您可以将其命名为“phpmyadmin”

sudo nano /etc/apache2/sites-available/example.conf

在 example.conf 中添加此内容

<VirtualHost *:80>

    ServerAdmin [email protected]
    ServerName domain.com
    ServerAlias example.domain.com
    DocumentRoot /usr/share/phpmyadmin

        <Directory /usr/share/phpmyadmin>
            Require all granted
        </Directory>

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

</VirtualHost>

保存文件然后从终端运行

sudo a2ensite example.conf

现在只需重新启动 apache2

sudo service apache2 reload

这就是您要做的,让它在 Ubuntu 14.04 和 Apache 2.4.7 中运行,并访问您的 PHPMyAdmin,只需在您的浏览器中输入此内容即可。

http://example.domain.com

相关内容