Project Practice Mono + Linux configuration for ASP. NET running

Source: Internet
Author: User

Recently, the company received a ticket in HK. The other party wants to use its own server, but does not want to buy windows server or use linux and mysql as the platform, because a genuine system is required in HK, microsoft server is a little expensive. however, the company's php is not enough, but does not want to give up the business, so I want to run asp.net on the linux platform. as a result, I have just come into contact with linux server as a linux cainiao. If there is something wrong or unreasonable, please point it out.

This article is suitable for users who are not familiar with linux as I do.

Test environment: VMware + Ubuntu Server 10.0.4 32bit + MONO 2.4.4 + MySql 5.1

Software Download: http://down.51cto.com/data/136387

First, install Ubuntu. You can download it from the official Ubuntu website. The installation process is simple.

During the installation process, you will be prompted to select the services or software to be installed. I did not select the software here, and then install it manually in the system.

Note: our topic is to run asp.net through mono. In the test, we use a root account. Therefore, security issues are completely ignored. For linux security configuration, you can find relevant information.

After the installation is complete, the system will prompt you to log on. We will log on with the account set during the installation process.

After successful login, we will set the root account password, root has the highest permission, because we test, so all the following operations are based on the root account

Enter the following command:

 

After the modification is complete, we log in as root

 

Configure the network because I have installed the VM. Set the VM Network option to NAT. During the installation process, Ubuntu has been assigned an IP address and can be connected to the Internet.

You can use

Ifconfig

To view the network configuration information.

If you install it independently or use other network modes, you may need to manually set the ip address. Here is a brief description. For details, go to google.

Modify the network configuration file

Add or modify part of auto eth0:

OK. Next we will install some basic software or services.

Auto eth0

Replace the above content with your own

Modify dns

 

Modify the nameserver value.

Use

 

To make the network settings take effect immediately

Well, we will not talk about these parts. If you don't understand them, you can go to google.

Next we will install open ssh. It is very important to allow us to remotely manage our servers. The installation is very simple:

 

The installation is successful. Now we can connect to it through the open ssh client.

PuTTy is used here.

After the connection is successful, you can remotely control the ubuntu server and execute shell

Speaking of this, I will provide you with two tools, which will be downloaded later. One is the PuTTy mentioned above, which is used to manage linux and execute shell. The other is winscp, which can manage files on linux.

Use winscp to manage server files

 

 

 

After the installation is complete, we can immediately test it in the browser and enter the Server ip Address:

 

Install mono

 

Here encountered a problem, after installing the libapache2-mod-mono will appear for a long time can not return to the situation, every time is restarted to solve, restart after

When you execute the next command, the system will prompt

E: dpkg was interrupted, you must manually run 'sudo dpkg -- configure-a' to correct the problem

The cause of this prompt is that the installation was interrupted just now, but the execution of the libapache2-mod-mono and so on for a long time can not return, so only restart. But it does not matter, according to his execution

 

I don't know if it is a software bug or an operation error. If you know it, please remind me.

OK. Now, it's almost the same, so I uploaded a help. aspx file to/var/www/. I found it at runtime.

The. net code is not executed at all, and the server control is basically invalid, as shown in figure

 

Finally, find the cause. mono does not correctly configure the. net Engine Directory. Of course, it will not be executed. So find the/etc/apache2/mod-available/mod_mono.conf file.

Edit using commands

 

To:

 

After editing, restart apache

 

Refresh the page. The page is normal. There is no problem with simple server control and event sending.

 

Run the following command to view mono version information:

Mono-V

OK. Now our apache + mono can run the asp.net file. We will perform a more complex test later.

Next we will install and configure mysql. This part is a simple description. There are many tutorials on the Internet.

 

During installation, you will be prompted to enter the root account password.

After the installation is complete, log on to mysql and log on as root.

Mysql-u root-p

Create a Test user AAA with a password of 123456. Only the database Test has all permissions.

 

For mysql management commands, go to the Internet to search for them.

Now we use a client (windows) to connect to mysql. I use Navicat Lite (free version). The basic operation is sufficient.

To allow external connections, modify the configuration file/etc/mysql/my. cnf in mysql and remove bind-networking.

If the connection still fails, use the following method: (excerpt)

1. Change the table. It may be that your account is not allowed to log on remotely, but only on localhost. At this time, you only need to log in to mysql on the computer of localhost, and change the "host" entry in the "user" table in the "mysql" database to "%" from "localhost"

 

2. Authorization method. For example, if you want myuser to use mypassword to connect to the mysql server from any host.

 
 
  1. GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;   

If you want to allow myuser to connect to the mysql server from a host whose ip address is 192.168.1.3, and use mypassword as the password

 

OK, it's almost over,

A simple web project contains common c # logic code, external dll, httphandler, cookies, session, upload, webservice call, And vs2008 normal compilation, then upload the file to the apache directory.

The test is completely normal. You need to note that linux is case sensitive. Therefore, you must batch configure the case when entering the url. if apache is case-insensitive, search for it by yourself.

Ubuntu server 10.0.4 is a shell interface by default and has no graphical interface.

If you need a graphical interface, you can install it and restart it to enter the graphical interface.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.