Most of the methods shared online by the experts rely on Apache working together with Nginx, which felt rather cumbersome to me, and my own approach meets my needs just fine, so I'm sharing it here. I won't go into preparing the Linux server itself, but since you'll need to install Mono (http://www.mono-project.com), I recommend Debian, Ubuntu or CentOS. As for Nginx, I recommend the LNMP one-click installer (https://lnmp.org). The name stands for L: Linux, N: Nginx, M: MySQL, P: PHP.
Using an SSH client, first install LNMP (https://lnmp.org/install.html), then install Mono (http://www.mono-project.com/download/#download-lin) using the install command for your distribution. On Ubuntu and Debian, make sure to install mono-devel and mono-xsp4; on CentOS, install mono-devel and xsp. mono-devel is definitely required, but I was worried about running into errors, so I installed mono-complete instead. The key difference is mono-xsp4 versus xsp, which depends on the distribution, but in the end both run the fastcgi-mono-server4 service.
Once everything is ready, we can start configuring. Use an SFTP client to open (edit) /usr/local/nginx/conf/nginx.conf, which is the Nginx configuration file. Pay attention to the path: it is this path because the LNMP one-click package was used, and the same goes for all the paths that follow. Modify it as follows (reference: http://www.mono-project.com/docs/web/fastcgi/nginx):
server {
listen 80;
server_name www.domain.com;
root /home/wwwroot/default;
location / {
index index.html index.htm default.aspx Default.aspx;
fastcgi_index Default.aspx;
fastcgi_pass 127.0.0.1:9000;
include /usr/local/nginx/conf/fastcgi_params;
}
}
Open (edit) /usr/local/nginx/conf/fastcgi_params and add the following at the bottom:
fastcgi_param PATH_INFO "";
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
Open (edit) /etc/init.d/nginx, the Nginx service control script, and add the following command at the appropriate place inside the if block for start, so that the fastcgi-mono-server4 service starts together with Nginx:
fastcgi-mono-server4 /applications=/:/home/wwwroot/default/ /socket=tcp:127.0.0.1:9000 &
That's it for the configuration. Restart Nginx:
service nginx restart
Create a .NET Framework 4.0 ASP website and take a look. At this point you also need to think about connecting to MySQL. Of course, if your VPS or other cloud server has 2 GB of memory or more and 6 GB of disk or more, you can keep using SQL Server; see: https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-setup
As for MySQL, LNMP has already installed it in one click! You only need to set up the connection. Open https://dev.mysql.com/downloads/connector/net/ and choose Generally Available(GA) Releases, set Select Operating System: to .NET & Mono, and click Download. On the next page choose No thanks, just start my download. There's no need to Login or Sign Up. After downloading and extracting, use Visual Studio to add a reference to the MySql.Data.dll component in the version-number folder to your solution. Make sure port 3306 is open and the MySQL user has been granted access from the right IP, and the MySQL connection is sorted. The connection string syntax is similar to SQL Server's.
Next, let's take care of the PHP site. In your domain's DNS settings, first add a subdomain, e.g. php.domain.com. Choose explicit URL forwarding as the record type (if you choose implicit URL forwarding, the site title won't be displayed; only the subdomain you set will be shown), enter php as the host record and http://domain.com:XXXX as the record value (the port number you want to use, anywhere from 1024 to 65535; it's best to check first to avoid port conflicts), and leave everything else at the defaults.
Open your SSH client and add a website (virtual host); see: https://lnmp.org/faq/lnmp-vhost-add-howto.html Note that you should not add an SSL certificate here, although port 443 (https) can be assigned to the default port 80.
When that's done, open (edit) /usr/local/nginx/conf/vhost/php.domain.com.conf, copy everything in it, paste it below the last server block in /usr/local/nginx/conf/nginx.conf, and change the port in the listen line to the same port number you entered as the record value in the DNS settings. The line include vhost/*.conf; at the bottom can be commented out with #. Save the file. The /usr/local/nginx/conf/vhost/php.domain.com.conf file can then be deleted.
And with that, all the configuration is done. Upload your website code to the corresponding directory and you can access it~~~!