当主域位于 /var/www 时,Apache2 读取主文件夹目录

当主域位于 /var/www 时,Apache2 读取主文件夹目录

我正在为学生设置一个实验室来创建网页,这是我目前的设置:我对设置网络服务器还不太熟悉,所以请耐心等待:-)

操作系统 - Ubuntu 14.04,Apache 主域名/var/www/<name of domain>,conf 文件/etc/apache2/sites-available

现在我已经设置了一个具有此结构的用户帐户/home/<username>/public_html

我想创建一个这样的 URL:http://<domain>/~<username>

我当前的虚拟主机是:

 <Virtualhost *:80>
 ServerName default.only
 <Location />
 Order allow,deny
 Deny from all
 </Location>
 Redirect permanent / https://bcs.net.nz/s/
 </Virtualhost>

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>
            ServerAdmin [email protected]
            ServerName bcs.net.nz
            ServerAlias www.bcs.net.nz

            DocumentRoot /var/www/bcs.net.nz/s/


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

            SSLEngine On

            SSLCertificateFile      /etc/apache2/ssl/apache.crt
            SSLCertificateKeyFile /etc/apache2/ssl/apache.key

            <FilesMatch "\.(cgi|shtml|phtml|php)$">
                            SSLOptions +StdEnvVars
            </FilesMatch>
            <Directory /usr/lib/cgi-bin>
                            SSLOptions +StdEnvVars
            </Directory>

            BrowserMatch "MSIE [2-6]" \
                            nokeepalive ssl-unclean-shutdown \
                            downgrade-1.0 force-response-1.0

    </VirtualHost>
 </IfModule>


<VirtualHost 172.16.1.102:80 192.168.1.9:80>
ServerAdmin [email protected]
ServerName bcs.net.nz
ServerAlias www.bcs.net.nz
DocumentRoot /var/www/bcs.net.nz/


    <Directory /var/www/bcs.net.nz>
    RewriteEngine On
    RewriteBase /

    RewriteCond %{REQUEST_METHOD} ^(TRACE|TRACK|OPTIONS|HEAD)
    RewriteRule ^.* - [F]

    </Directory>

    ServerSignature off
    AliasMatch ^/parallel/propulsion(.*) "/var/www/bcs.net.nz/parallel/index.html"
    AliasMatch ^/parallel/(.*) "/var/www/bcs.net.nz/parallel/index.html"

    ErrorLog /var/log/apache2/error.log

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

    CustomLog /var/log/apache2/access.log combined
    ProxyBlock *
 </VirtualHost>

我需要解析 URL,但是由于文件不在/var/www/主域中,所以我有点不知道如何更改上述虚拟主机文件。

我该如何继续?

答案1

跑步

sudo a2enmod userdir

在命令行上启用 Apache 模块mod_userdir并确保/home/<username>/public_html网络服务器可以访问。

相关内容