laravel httpd.conf DirectAdmin中的文档根路径将SUB添加到路径的末尾

utugiqy6  于 2022-12-27  发布在  其他
关注(0)|答案(1)|浏览(128)

我的laravel网站托管在versio.nl上。最近他们对服务器进行了维护,从那时起我的子域就关闭了。
我发现了一组奇怪的文档根目录。
在DirectAdmin面板中的自定义httpd配置下,我添加了:

|*if !SUB|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/public|
|*endif|

|*if SUB="demo"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/demo/public|
|*endif|

|*if SUB="avn"| 
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/avn/public|
|*endif|

laravel应用程序位于这些目录中。
现在,我看到在httpd.conf的内容中,路径更改为:

<VirtualHost 185.xxx:80 >
    ServerName www.ai.netwerkspel.nl
    ServerAlias www.ai.netwerkspel.nl ai.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.ai.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch>
    </Directory>
</VirtualHost>

<VirtualHost 185.xxx:443 >
    SSLEngine on
    SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.cert.combined
    SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.key
    ServerName www.ai.netwerkspel.nl
    ServerAlias www.ai.netwerkspel.nl ai.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.ai.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.ai.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/ai/public/ai>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch> 
    </Directory>
</VirtualHost>

<VirtualHost 185.xxxx:80 >
    ServerName www.avn.netwerkspel.nl
    ServerAlias www.avn.netwerkspel.nl avn.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn    <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.avn.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch>
    </Directory>
</VirtualHost>

<VirtualHost 185.xxx:443 >
    SSLEngine on
    SSLCertificateFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.cert.combined
    SSLCertificateKeyFile /usr/local/directadmin/data/users/admin/domains/netwerkspel.nl.key
    ServerName www.avn.netwerkspel.nl
    ServerAlias www.avn.netwerkspel.nl avn.netwerkspel.nl 
    ServerAdmin webmaster@netwerkspel.nl
    DocumentRoot /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn   <<--------
    ScriptAlias /cgi-bin/ /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn/cgi-bin/
    UseCanonicalName OFF
    <IfModule !mod_ruid2.c>
        SuexecUserGroup admin admin
    </IfModule>
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.bytes bytes
    CustomLog /var/log/httpd/domains/netwerkspel.nl.avn.log combined
    ErrorLog /var/log/httpd/domains/netwerkspel.nl.avn.error.log
    <Directory /home/admin/domains/netwerkspel.nl/public_html/avn/public/avn>
        <FilesMatch "\.(inc|php|phtml|phps|php74)$">
            <If "-f %{REQUEST_FILENAME}">
                #ProxyErrorOverride on
                AddHandler "proxy:unix:/usr/local/php74/sockets/admin.sock|fcgi://localhost" .inc .php .phtml .php74
            </If>
        </FilesMatch> 
    </Directory>
</VirtualHost>

并且配置检查发出警告:

AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/ai/public/ai] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/ai/public/ai] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/avn/public/avn] does not exist
AH00112: Warning: DocumentRoot [/home/admin/domains/netwerkspel.nl/public_html/avn/public/avn] does not exist

有谁能明白为什么SUB本身突然被添加到路径中吗?我在上面的代码中用箭头表示。
我如何把它转回来,使他们指向正确的根目录?

fquxozlt

fquxozlt1#

已解决问题。问题与模板有关。
在DirectAdmin -〉自定义HTTPD配置中,单击域名,然后在可用令牌列表的正下方可以看到“模板”。这些似乎是DirectAdmin在使用您定义的虚拟主机构建httpd.conf时使用的模板。
在我的例子中我定义了

|*if SUB="demo"|
|?DOCROOT=/home/admin/domains/netwerkspel.nl/public_html/demo/public|
|*endif|

直接管理员将其转换为〈Directory /home/admin/domains/ www.example.com〉之类的目录netwerkspel.nl/public_html/demo/public/demo
我发现负责翻译的模板是:

/usr/local/directadmin/data/templates/custom/virtual_host2_sub.conf     
 /usr/local/directadmin/data/templates/custom/virtual_host2_secure_sub.conf

可以编辑这些模板并将其放置在自定义目录中,以向DirectAdmin指出这些模板是要使用的模板。
首先,我创建了自定义文件夹(使用sudo,否则拒绝访问)

mkdir -p /usr/local/directadmin/data/templates/custom/
chmod 711 /usr/local/directadmin/data/templates/custom/
chown diradmin:diradmin /usr/local/directadmin/data/templates/custom/ -R

并将相关模板复制到其中:

sudo cp -p virtual_host2_secure_sub.conf custom
sudo cp -p virtual_host2_sub.conf custom

下一步是编辑自定义文件夹中的两个模板。找到如下行:

|?SDOCROOT=`DOCROOT`/'SUB'|

把它变成

|?SDOCROOT=`DOCROOT`|

现在DirectAdmin中的模板如下所示:

/usr/local/directadmin/data/templates/custom/virtual_host2_sub.conf     *** Custom Template ***
 /usr/local/directadmin/data/templates/custom/virtual_host2_secure_sub.conf     *** Custom Template ***

DirectAdmin将使用自定义模板。再次保存配置后,子域将再次工作!

相关问题