I learned about the mono platform a few years ago, but I have never dared to touch it because I don't know Linux. I finally tried to use mono in the last month. It took nearly one month to deploy the service. After countless pains, the deployment was successful. Here, I want to give my friends a reference.
I. System Selection
I chose centos 6.2. If Ubuntu or opensusu is used, it may be so troublesome. Mono and opensusu are from the same company and have direct installation packages available.
Ii. Mono version Selection
I used mono2.6.7 and started to use 2.8, 2.10, but the results all produced various problems, of course, because of the Code
Iii. Compile the code
Mono is a cross-platform implementation of. net. You do not need to modify the code or some code to complete the migration of the platform. If you do not modify the code, the code is relatively simple and only used for testing or demonstration. Generally, recompilation is required. If you select mono2.6.7, your code has an extension method that will not pass compilation, and some references will also cause compilation failure under mono!
Iv. Ide Selection
Of course, the first choice is monodevelop. You can also use eclipse. In centos, do not try to install monodevelop. I tried it seven times but failed. Finally, I chose to debug the compilation code on Ubuntu. The mono version on Ubuntu is 2.6.7, therefore, I installed mono2.6.7 on the server. This ensures that any Linux system can run normally as long as the test is compiled.
V. Comparison
Here, I provide two sites for my friends to test www.xmwebs.com (Windows IIS) and www.ssite.info (centos mono)
You can enter a non-existent address to view the compiler type in the yellow pages, such:
I have not conducted a special test, and I hope to run it in Mono without consideration of stability. I often see foreign articles that mono performance may be better than windows. net implementation
6. Select a database
Mono supports databases other than access, such as MySQL, MSSQL, Oracle, posgresql, and SQLite. We recommend that you use MySQL
7. What is the support for Asp.net MVC?
The demo site shown above is also developed using MVC. The biggest problem is routing, which requires a lot of time to fix.
8. Deployment
You can also use Apache + mod_mono to deploy nginx + xsp.
The installation environment is briefly described here. There is a lot of information on the Internet. You can also click here to view details.
First install libgdiplus
Download source code
Tar jxvf libgdiplus-2.8.tar.bz2
CD libgdiplus-2.8
Yum install glib2-devel libpng-devel libX11-devel Cairo-devel
Yum install libjpeg-devel (JPG supported) giflib-devel (GIF supported) other formats, you can install the corresponding components
Then download the mono source code (Here we use 2.8)
A. Install mono
Tar jxvf mono-2.6.7.tar.bz2
CD mono-2.6.7
./Configure-Prefix =/opt/mono
Make & make install
After the installation is complete, run/opt/MONO/bin/mono-V to test whether the installation is successful. You can also add the following command to the environment variable.
export PATH=/opt/mono/bin:$PATH
export PKG_CONFIG_PATH=/opt/mono/lib/pkgconfig:$PKG_CONFIG_PATH
Run/opt/MONO/bin/mono-test-install to test the installation.
If libgdiplus cannot be found, add the path to/etc/lD. So. conf and load it in ldconfig.
B. Install xsp
Tar jxvf xsp-2.6.7.tar.bz2
CD xsp-2.6.7.tar.bz2
./Configure-Prefix =/opt/mono
Make & make install
Now mono has been installed, and then we can start a FastCGI process using the following command
fastcgi-mono-server4 /applications/:/var/www /socket=tcp:127.0.0.1:8080
Note: The fastcgi-mono-server4 represents the use of Asp.net 4.0, for which there should be fastcgi-mono-server2 and FastCGI-mono-Server
C. Configure nginx
Server {
Listen 80;
SERVER_NAME www. Ops. CC;
Access_log/var/log/xsp. log;
Location /{
Include fastcgi_params;
Root/var/www /;
Index index.html default. aspx;
Fastcgi_pass 127.0.0.1: 8080;
}
}
For ASP. NET and ASP. net mvc web applications to run nginx through the FastCGI protocol, you need to add:
Fastcgi_param path_info "";
Fastcgi_param script_filename $ document_root $ fastcgi_script_name;
Or directly add the fastcgi_params file to nginx.
D. Restart nginx and Test
If you are interested, give it a try. If you do not understand, please add QQ: 188867734