I am running centos 7 and i have installed mono using the guide on the official website for centos http://www.mono-project.com/docs/getting-started/install/linux/ . This appears to be working fine as i can get the output from compiling .cs files. I am pretty confident this part is working fine.
The issue i am having is making it work with apache. I have setup a VPS to test everything with. Apache is live and i can access html files http://79.137.86.234/index.html, however when i try to access an ASP project i get errors. http://79.137.86.234/asptest/
Initially apache was just returning the content of the .cs file when i tried to access it. I installed mod_mono using the guide from the mono website and it appears to be working as mono is showing up in the list of modules when i run the command to see what is loaded. I have made no other changes to the apache conf or to a htaccess file. I am just using a basic hello world asp.net MVC 4 project. I built it in VS 2017 and made no changes to what is generated by default.
When i visit the page linked above, the following gets output to apaches error log
[Fri Apr 14 14:09:40.974689 2017] [:error] [pid 2675] Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_global --nonstop --master (null) (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
[Fri Apr 14 14:09:42.979830 2017] [:error] [pid 2677] Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_global --nonstop --master (null) (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
[Fri Apr 14 14:09:44.985495 2017] [:error] [pid 2679] Failed running '/usr/bin/mod-mono-server2 --filename /tmp/mod_mono_server_global --nonstop --master (null) (null) (null) (null) (null) (null) (null) (null)'. Reason: No such file or directory
[Fri Apr 14 14:09:46.987239 2017] [:error] [pid 2602] Failed to connect to mod-mono-server after several attempts to spawn the process.
One thing about the error i noticed was the directory "/usr/bin/mod-mono-server2" i checked and the file is /usr/bin/mod-mono-server4. I have no idea how to change this though.
This is very similar to this question Setting up Mono/ASP.NET 4.0 on Apache2/Ubuntu: Virtual hosts?
Following the link provided in one of the answers, I was able to solve this problem on my system by editing "/etc/apache2/mods-enabled/mod_mono_auto.conf" and appending "Include /etc/mono-server4/mono-server4-hosts.conf" to the end of the file. Found in step #2 from the following link:
http://r2d2.cc/2014/03/25/asp-net-mvc-under-linux-with-mono/
No further configurations were needed in my case, just be sure to restart apache.