【问题标题】:Fail to start a mono site with Apache2, 404 error with mod_mono无法使用 Apache2 启动单站点,使用 mod_mono 时出现 404 错误
【发布时间】:2013-10-09 17:57:36
【问题描述】:

我的家庭系统是一个 Ubuntu 13.4(从 12.10 升级)桌面系统,我在其中进行了一些开发,主要使用 PHP,并且我安装了 Apache 并且工作正常。

我需要在 ASP.NET 中进行一些开发,并且我安装了 MonoDevelop 以及 XSP 服务器。我可以从 MonoDevelop 启动 XSP,它服务于端口 8080 (localhost:8080)。这在开发会话期间是可以的,但由于某种原因,XSP 似乎超时了,而且我的路由器不服务于端口 8080;此外,XSP 一次只服务一个单声道项目。

我尝试使用 Apache 配置虚拟主机,但它不起作用。静态文件、aspx 文件和不存在的文件都出现 404 错误。

我的虚拟主机配置如下:

<virtualhost *:80>
    ServerAdmin webmaster@mydomain.net
    ServerName  myproject.local
    ServerAlias myproject.mydomain.net

    DocumentRoot    /home/myuser/source/myproject/myproject
    <Directory /home/myuser/source/myproject/myproject>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        Allow from all
        SetHandler  mono
        DirectoryIndex  Default.aspx index.aspx index.html
    </Directory>

    LogLevel    debug
    ErrorLog    /var/www/vhosts/myproject/log/error.log
    CustomLog   /var/www/vhosts/myproject/log/access.log combined
</virtualhost>

查看错误日志,我发现以下消息:

[Mon Oct 07 00:42:45 2013] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 279 to 214 : URL /
[Mon Oct 07 00:43:00 2013] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 291 to 223 : URL /Default.aspx
[Mon Oct 07 00:43:04 2013] [error] [client 127.0.0.1] script '/home/myuser/source/myproject/myproject/Default.php' not found or unable to stat
[Mon Oct 07 00:43:04 2013] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 290 to 222 : URL /Default.php
[Mon Oct 07 00:43:14 2013] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 292 to 222 : URL /Template.css
[Wed Oct 09 12:36:00 2013] [debug] mod_deflate.c(615): [client 127.0.0.1] Zlib: Compressed 290 to 221 : URL /favicon.ico

文件Default.phpfavicon.ico不存在,其他文件Default.aspxTemplate.css存在。

提前谢谢你。


更新

我错过了部分配置:webapp 文件。我添加到/etc/mono-server4/debiab.webapp 添加项目。

<apps>
<web-application>
    <name>myproject</name>
    <vhost>myproject</vhost>
    <vport>80</vport>
    <vpath>/</vpath>
    <path>/home/myuser/source/myproject/myproject/</path>
    <enabled>true</enabled>
</web-application>
</apps>

现在可以了!


现在,我无法让它适用于不同应用的虚拟目录。

【问题讨论】:

    标签: asp.net apache mono monodevelop xsp4


    【解决方案1】:

    好的,通过将 Web 应用程序包含在 /etc/mono-server 目录中的 .webapp 文件中,可以回答我最初的问题。在此过程中,我决定尝试为所有相关的 Mono/ASP 项目仅使用一个虚拟主机,因此我对虚拟目录(别名)进行了以下配置。

    mytestsite.local 虚拟主机(/etc/apache2/sites-available/ 并链接在 /etc/apache2/sites-enabled/

    <virtualhost *:80>
        ServerAdmin webmaster@interlecto.net
        ServerName  mytestsite.local
        ServerAlias mytestsite.mydomain.net *.mytestsite.mydomain.net
    
        MonoAutoApplication disabled
        AddHandler  mono    .aspx .ascx .asax .ashx .config .cs .asmx .axd
    
        DocumentRoot    /var/www/vhosts/mytestsite/root
        <Directory /var/www/vhosts/mytestsite/root>
            Options Indexes FollowSymLinks MultiViews
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
        DirectoryIndex  Default.aspx index.aspx index.html
    
        Alias   /myproject  "/home/myuser/source/myproject/myproject"
        Alias   /othertest  "/home/myuser/source/othertest/othertest"
        MonoApplications    default "/myproject:/home/myuser/source/myproject/myproject,/othertest:/home/myuser/source/othertest/othertest"
    
        <Location /myproject>
            SetHandler  mono
        </location>
        <Location /othertest>
            SetHandler  mono
        </location>
    
        <Directory /home/myuser/source/myproject/myproject>
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
        <Directory /home/myuser/source/othertest/othertest>
            AllowOverride None
            Order allow,deny
            Allow from all
        </Directory>
    
        LogLevel    debug
        ErrorLog    /var/www/vhosts/mytestsite/log/error.log
        CustomLog   /var/www/vhosts/mytestsite/log/access.log combined
    </virtualhost>
    

    debian.webapp 文件(/etc/mono-server4/

    <apps>
        <web-application>
            <name>My Project</name>
            <vpath>/myproject</vpath>
            <path>/home/myuser/source/myproject/myproject</path>
            <vhost>mytestsite.local</vhost>
        </web-application>
        <web-application>
            <name>Other Test</name>
            <vpath>/othertest</vpath>
            <path>/home/myuser/source/othertest/othertest</path>
            <vhost>mytestsite.local</vhost>
        </web-application>
    </apps>
    

    在我的虚拟主机根目录 (/var/www/vhosts/mytestsite/root/) 我有一个简单的 index.html 文件,允许我选择哪个测试。

    所以现在我有 Mono(用于 ASP.NET 的 mod_mono)在 Ubuntu 上的 Apache 上的虚拟主机上处理几个虚拟目录。

    【讨论】:

      猜你喜欢
      • 2020-07-26
      • 2018-03-14
      • 2016-09-27
      • 2020-03-01
      • 1970-01-01
      • 2021-02-20
      • 1970-01-01
      • 2013-04-01
      • 2019-11-05
      相关资源
      最近更新 更多