Jump to content


Photo

How do I configure mod_mono on Windows


  • Please log in to reply
34 replies to this topic

#16 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 11 January 2019 - 02:14 PM

If mean to start the server using xsp4 --port 2000, then I did as you said and I've got an Error 404 from ASP (mod_mono) and the server gets closed after visiting "127.0.0.1:2000" & even "127.0.0.1:2000/hello.aspx" but on visiting "localhost/hello.aspx" is showing Apache 503 Service Unavailable Error.

Here is the error.log:
[Fri Jan 11 19:32:17.808453 2019] [:error] [pid 1864:tid 1800] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:33:05.916807 2019] [:error] [pid 1864:tid 1800] Unknown command: 1347703880
[Fri Jan 11 19:41:54.044848 2019] [:error] [pid 1864:tid 1800] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:41:58.895062 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00424: Parent: Received restart signal -- Restarting the server.
[Fri Jan 11 19:42:00.183297 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:42:00.929365 2019] [mpm_winnt:notice] [pid 1864:tid 1032] AH00364: Child: All worker threads have exited.
[Fri Jan 11 19:42:01.198967 2019] [:error] [pid 3276] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:42:02.270816 2019] [:error] [pid 1864:tid 1032] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:42:02.371054 2019] [auth_digest:notice] [pid 3276:tid 1100] AH01757: generating secret for digest authentication ...
[Fri Jan 11 19:42:03.272498 2019] [:error] [pid 1864:tid 1032] mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000
[Fri Jan 11 19:42:03.272498 2019] [:alert] [pid 1864:tid 1032] (OS 6)The handle is invalid.  : Failed to acquire dashboard lock before destroying the dashboard
[Fri Jan 11 19:42:03.272498 2019] [:warn] [pid 1864:tid 1032] (OS 6)The handle is invalid.  : Failed to release dashboard lock after destroying the dashboard
[Fri Jan 11 19:42:03.272498 2019] [:warn] [pid 1864:tid 1032] (OS 6)The handle is invalid.  : Failed to destroy the dashboard mutex 'C:\\WINDOWS\\TEMP/mod_mono_dashboard_default_2.lock'
[Fri Jan 11 19:42:04.533764 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00455: Apache/2.4.23 (Win64) OpenSSL/1.0.2j mod_mono/3.12 mod_wsgi/4.6.5 Python/3.6 PHP/7.1.1 configured -- resuming normal operations
[Fri Jan 11 19:42:04.533764 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00456: Server built: Sep  6 2016 21:33:53
[Fri Jan 11 19:42:04.533764 2019] [core:notice] [pid 3276:tid 1100] AH00094: Command line: 'E:\\httpd\\bin\\httpd.exe -d E:/httpd'
[Fri Jan 11 19:42:04.549387 2019] [mpm_winnt:notice] [pid 3276:tid 1100] AH00418: Parent: Created child process 3524
[Fri Jan 11 19:42:05.520762 2019] [auth_digest:notice] [pid 3524:tid 1040] AH01757: generating secret for digest authentication ...
Here is a screenshot of Command Prompt Windows while running xsp4 --port 2000:
https://imgur.com/a/aoOjJrJ

And a screenshot of the page while visiting 127.0.0.1:2000/hello.aspx:
https://imgur.com/a/I5HjmuW

The screenshot of while visiting localhost/hello.aspx:
https://imgur.com/a/0L8k3cs
- By Sagnik

#17 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 January 2019 - 02:58 PM

That looks like Mono itself is broken. Are you running Mono as your own user, and does the folder shown in that Access Denied error in the cmd window exist? If not, create it. If it does, verify you can open it.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#18 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 11 January 2019 - 04:39 PM

I've not specified the directory shown in the command prompt. I want to change this directory. But I don't know how.
Yes I'm running mono as the account I use to logon to Windows at startup.

And the Directory: "C:\Users\sagni\AppData\Local\Application Data" exists I think but showing "Access is denied." And when I'm trying to create, it shows "The destination already contains a folder named 'Application Data'." But I can't see it even after turning on "Show Hidden Items".
- By Sagnik

#19 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 January 2019 - 05:20 PM

It's a fake system folder used to emulate Windows XP-era AppData...odds are the reason you're seeing this is because either your Mono version is too old to run on modern Windows, or more likely it has a bug that wasn't fixed because nobody ever bothered testing it on newer Windows (you're the first person I've ever met that wanted to run this on Windows...)

 

You can find the hidden folder by going into Folder Options->View->uncheck "Hide Protected Operating System Files"->Yes. Be aware that messing with this folder may break support for older software.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#20 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 11 January 2019 - 05:59 PM

Okay got it. But how can I fix the "Access Denied" issue on that folder.

By the way, you wanted to say that, I should use IIS instead of Apache. But if I do this, I need to change almost all the lines which uses an absolute path because I've installed Apache on "E:\httpd" and the installation of IIS will be in "C:\inetpub".

Here is why I'm not using IIS instead of Apache:
4 years ago I had a website built using site builder on a free hosting company "Serversforyou" or something like that. I've learnt the basics of PHP & MySQL by modifying the website I've built using the site builder and with the help of some Google searches. After few months after learning the basics of PHP & MySQL I've created an account on Heliohost as it offers a large amount of features compared to any other hosts and its features were very new to me on that time. What the common thing was that both hosting company included a server signature which was for Apache. That's why I've installed Apache on a Windows XP PC on that time as I didn't know what I'm doing. And all the websites built on that PC is continued till now.
- By Sagnik

#21 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 January 2019 - 06:21 PM

There's almost no reason to ever be using hard coded paths in software...I would start by fixing that issue. For example PHP gives a convenient way to get the folder containing the running script automatically, no hard-coded path needed.

$scriptdir = dirname(__FILE__);

A lot of time these variables will be initialized in a file that lives in your program's main folder alongside index.php. From there you can walk all the subfolders and even get the parent folder using dirname() or defined folder names:

$images_folder = $scriptdir.'/images';
$parent_folder = dirname($scriptdir);

With that fixed, the server being used no longer matters. Assuming you patch out the absolute paths, your software should run with few or no issues on IIS. I wrote most of the systems I'm running on Xampp (Apache)...many of them are now on IIS with zero issues. Of every program I wrote, I can think of exactly one that requires a hard coded absolute path, and it's because the alternative (enabling allow_url_include) is a massive security risk.

 

TL;DR: Fix your code instead of trying to make a non-standard configuration work.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#22 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 11 January 2019 - 06:26 PM

And what about the virtual hosts I've in Apache? And can I use Windows Hosts file as I did with Apache V Name-based irtual Hosts?
And can use MySQL (MySQL 8), PHP (PHP 7.1), Python/Django, Perl, CGI with IIS?
I use all of these for education purposes.
- By Sagnik

#23 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 January 2019 - 06:53 PM

No idea on if the Hosts file works with IIS or not. I've never used it in that manner. IIS does have an equivalent of virtual hosts (different domains with different doc roots) though. I have no idea on Python/Perl CGI, but PHP 7 will definitely run and MySQL is server-agnostic (it doesn't care what web server is running the PHP that talks to it). Installing PHP is a pain though because WPI is broken and you have to hunt down and manually install a component that always fails to get everything working.

 

If you really wanted, you could just run Apache on port 80 and ASP.NET on port 8080 through IIS, or since you have Mono working, just run that on 8080 and access it directly. In my experience, ASP.NET doesn't work well behind Apache anyway (I had to expose IIS directly on Lily for this exact reason. I couldn't get it working behind an Apache proxy).

 

Are the domains you're using real domains? Are they live now? If they're real and not already hosted here, you could test this stuff on Lily if you wanted. She runs IIS+PHP+ASP.NET+MariaDB. (Yes, we have an IIS server, we just don't advertise it). If they're not real, you could try the hosts file method to point them to Lily's IP, but no guarantee they'll work.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#24 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 11 January 2019 - 07:10 PM

That's why I don't want to use IIS. Apache provides lot more features than IIS. That's why I want to setup mod_mono with Apache server.
No doubt that IIS is very good when it comes to ASP.NET & SQL Server but to setup any other modules such as PHP it's very hard to setup even IIS doesn't allow PHP to be hosted as a module, it just allows to run PHP using FastCGI mode.
But with Apache we can run almost everything we want and is very easy to setup.

No the domains are not real.

Well I'll try to fix the "Access Denied" issue for the "Application Data" folder in the morning. I will let you know, what has happened next. Because setting the mod_mono with Apache is my only option to run ASP.NET pages. And can you tell me how can I change the Directory shown on the command prompt (the Application Data folder)?
- By Sagnik

#25 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 11 January 2019 - 07:28 PM

That's why I don't want to use IIS. Apache provides lot more features than IIS. That's why I want to setup mod_mono with Apache server.
No doubt that IIS is very good when it comes to ASP.NET & SQL Server but to setup any other modules such as PHP it's very hard to setup even IIS doesn't allow PHP to be hosted as a module, it just allows to run PHP using FastCGI mode.
 

You're aware we run PHP as CGI here right? The module method for running PHP in Apache has not been recommended since 5.4 came out. Web servers that aren't Apache don't support anything but CGI, and CGI is recommended for Apache as well. As for getting PHP working on IIS, it's just an MSI you run to install the missing component. The issue is that component's official installer doesn't like the 10.0 version number of all things...so someone made an installer that doesn't check.

 

The Application Data folder access denied message is normal and by design. It's part of Windows legacy support. Some old 2000/XP era programs hard coded the Application Data folder's path, but Windows Vista and up don't use the same profile folder structure as XP...these "dummy" folders exist so the compatibility of these programs isn't affected (they are aliases to %UserProfile%\AppData\Roaming or %UserProfile%\AppData\Local, and the access is intentionally denied to avoid an infinite loop when running directory listings since they point to their own parent folder...).

 

You need to find out how to change Mono's appdata folder (there's probably a setting somewhere) and point it to a folder that actually exists and it has permission to access.


Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#26 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 12 January 2019 - 05:13 AM

Sir, I couldn't find any way to change the AppData folder of mono. Can you tell me how can I do that?

One more thing, when I launched a Command Prompt using Administrator rights, I got the following error:
Access to the path 'C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\Windows\INetCache\Content.IE5' is denied.
Okay I've managed to run mod_mono with Apache. What I did is changed the MonoServerPath from xsp4.bat to mod-mono-server4.bat which I've created. But a problem is that I had to start the mod-mono-server4 manually as well as I had to supply few options along with it
C:\Program Files\Mono>mod-mono-server4 --address 127.0.0.1 --port 2000 --root E:\httpd\htdocs
Apache is not starting the server by itself. And If I don't start run the command manually the apache is showing a 503 Error. Also if I don't supply the options when starting the server Iget the following output:
C:\Program Files\Mono>mod-mono-server4
Listening on: C:\Users\sagni\AppData\Local\Temp\mod_mono_server
Root directory: C:\Program Files\Mono\
An address incompatible with the requested protocol was used.

  at System.Net.Sockets.Socket.Bind (System.Net.EndPoint localEP) [0x00043] in <524453535c1446469839c0b30a8ceaf1>:0
  at Mono.WebServer.ModMonoWebSource.CreateSocket () [0x0007e] in <17ccfba99d534c9e8d160e47815fbfe3>:0
  at Mono.WebServer.ApplicationServer.Start (System.Boolean bgThread, System.Int32 backlog) [0x00075] in <bbd0a9d3a0d349099be00550c37ebfb4>:0
  at (wrapper remoting-invoke-with-check) Mono.WebServer.ApplicationServer.Start(bool,int)
  at Mono.WebServer.Apache.Server.RealMain (System.String[] args, System.Boolean root, Mono.WebServer.IApplicationHost ext_apphost, System.Boolean v_quiet) [0x00384] in <17ccfba99d534c9e8d160e47815fbfe3>:0
Here is the mod_mono.conf:
# mod_mono.conf

# Achtung! This file may be overwritten
# Use 'include mod_mono.conf' from other configuration file
# to load mod_mono module.

<IfModule !mod_mono.c>
    LoadModule mono_module modules/mod_mono.so
</IfModule>
<IfModule mono_module>
    AddType application/x-asp-net .config .cs .csproj .dll .resources .resx .sln .vb .vbproj
    AddType application/x-asp-net .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo
    
	#AddHandler mod_mono .asax .ascx .ashx .asmx .aspx .axd .browser .licx .master .rem .sitemap .skin .soap .webinfo .config .cs .csproj .dll .resources .resx .sln .vb .vbproj

    MonoAutoApplication disabled
	MonoPath "C:\Program Files\Mono"
	#MonoServerPath "C:\Program Files\Mono\lib\mono\gac\mod-mono-server4\4.4.0.0__0738eb9f132ed756\mod-mono-server4"
	#MonoServerPath "C:\Program Files\Mono\lib\mono\4.5\mod-mono-server4.exe"
	MonoServerPath "C:\Program Files\Mono\bin\mod-mono-server4.bat"
	#MonoServerPath "C:\Program Files\Mono\bin\xsp4.bat"
	MonoListenAddress 127.0.0.1
	MonoListenPort 2000
	#MonoWapiDir "E:/httpd/htdocs"
	MonoApplications "/:E:\httpd\htdocs"
	#MonoApplicationsConfigFile "E:/httpd/htdocs/web.config"
	#MonoApplicationsConfigDir "E:/httpd/htdocs/webapp"
	MonoDebug true

    <IfModule dir_module>
		DirectoryIndex index.aspx
        DirectoryIndex Default.aspx
		DirectoryIndex default.aspx
    </IfModule>

    <DirectoryMatch "/(bin|App_Code|App_Data|App_GlobalResources|App_LocalResources)/">
        Order deny,allow
        Deny from all
    </DirectoryMatch>
	<Location "/">
		#MonoSetServerAlias default
		Allow from all
		Order allow,deny
		SetHandler mono
		SetOutputFilter DEFLATE
		SetEnvIfNoCase REQUEST_URI "\.(?:gif|jpe?g|png)$" no-gzip dont-vary
		AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript
	</Location>
    <Location "/mono">
        #Allow from 127.0.0.1::1
        SetHandler mono-ctrl
    </Location>
</IfModule>
Here is a screenshot:
https://imgur.com/a/AxSNJcW
- By Sagnik

#27 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 14 January 2019 - 06:24 AM

Why I had to start the server manually?
- By Sagnik

#28 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 14 January 2019 - 10:46 AM

More than likely mod_mono isn't passing something to Mono correctly, so a bug.

I sometimes have the same issue when dealing with pass thru on IIS for things like Ruby on Rails. Starting the second server manually usually fixes it.

Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...


#29 sagnik

sagnik

    Rank VI Member

  • Members
  • PipPipPipPipPipPip
  • 407 posts
  • Gender:Male
  • Location:Durgapur, West Bengal, India
  • Interests:Internet, Computer, Coding, Website Designing

Posted 14 January 2019 - 10:59 AM

Okay! Actually I've downloaded the mod_mono.so plugin and I don't know if it's compatible with the mono version I'm using! It maybe the cause. If it is, the mod_mono.so doesn't exist neither in the internet (except the website I've downloaded it) nor it comes with the MSI Installer. Then how can I get the right version of mod_mono?

I've just noticed that the "mod_mono: connect error (Unknown error). Address: 127.0.0.1 Port: 2000" is still exists in the error.log file of Apache. I can't figure out why even if I start the server manually.

And one more thing how can I change the AppData directory of mono?
- By Sagnik

#30 wolstech

wolstech

    Rank X Member

  • Root Admin
  • 10,271 posts
  • Gender:Male
  • Location:Pennsylvania

Posted 14 January 2019 - 11:16 AM

You'd have to build it from source, which on Windows is often not easy. Linux is usually an easier platform for building stuff on because all the requirements are conveniently available as packages. Windows means running around and installing tons of random stuff and knowing how to configure it. If you're lucky, some programs will build in msys2 (Linux compatibility environment) which makes it a little easier. Windows 10 also has WSL, but that's cheating (it's just a Ubuntu Linux VM running in the background with a seamless UI).

I can't find the answer for the app data folder. I suspect it may be built into the code that way and nobody ever bothered to update the code for modern windows. Back in the day, Mono sometimes found on Windows XP for testing because full ASP.NET wasn't available in workstation OSes (even though IIS was in XP Pro). With IIS 7 and newer (Vista and up), full ASP.NET is available on all non-Home OSes...which basically eliminated its use case for Windows.

Please do not PM me for support. Posting on our forums lets all of us learn.

Do you play Minecraft? | Server Monitors | And the Dumbass of the Decade award goes to...





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users