Jexus deployment asp.net mvc website guide, during this time I need to deploy the website developed using traditional asp.net mvc technology on the Centos 7 server, the original Centos 7 deployment of asp.net webform development of the website is not Supported, or you need to use mono.
Fortunately, now you only need to install Jexus on the Linux server to deploy the asp.net webform website or asp.net mvc website on the Linux server. By the way, you can now use asp.net core to develop websites, you don’t have to be so troublesome, because .net core itself supports cross-platform deployment, the website mentioned in this post was a company that used asp.net more than 10 years ago It is developed by webform, and the client needs it to run on a Linux server for some reason, and I chose Centos 7 as the server.
Before starting, you need to install the Centos server, because various management operations of the Centos server are performed using the command line (terminal), in order to manage the Centos server more conveniently, I installed aapanel, a visual Linux server management panel, It allows you to manage Linux servers in a very comprehensive way. The key point is that it is free and open source, and provides Chinese and English versions.
Install the aapael panel
aapael is a visual web panel for managing Linux servers. After installing the panel, server management can be done directly on the browser, such as website deployment, database installation, port opening or disabling, scheduled tasks, backup, file management, and more.
aapael official website: www.bt.cn (Chinese)
aapael official website: www.aapanel.com (English)
When using it for the first time, log in to the Centos server (other servers are similar, such as Ubuntu, Debian, etc.) through a client such as putty using the root account, and then execute the following command to install:
Centos install script:
yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
Ubuntu/Deepin installation script
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && sudo bash install.sh
Debian installation script
wget -O install.sh http://download.bt.cn/install/install-ubuntu_6.0.sh && bash install.sh
Fedora installation script
wget -O install.sh http://download.bt.cn/install/install_6.0.sh && bash install.sh
Note: aapanel must be installed for a new system that has not installed other environments such as Apache/Nginx/php/MySQL, it is recommended to use centos 8.X systems
After aapanel is installed, in the last prompt text there is aapanel’s login entry address, user name, password and other information that needs to be recorded and copied and saved directly. User name and password can be modified in aapanel. If you forget the user name and password, please use SSH (such as putty) to log in to the server. Run the following commands to see the login address, user name, password and other information.
View aapanel login entry, user name, password command: /etc/init.d/bt default
Just install the latest version of Jexus. It should be noted that when installing Jexus, you need to distinguish between the X86_64 system and the ARM64 system. Like some cloud servers, the ARM64 system may be used, so you need to pay attention. When installing Nexus, execute the following command:
The command to install jexus standalone is:
Jexus deployment asp.net mvc website guide
The command to install jexus standalone is:
Jexus deployment asp.net mvc website guide
Jexus deployment asp.net mvc website
The asp.net webform website and the asp.net mvc website cannot be deployed across platforms originally. The Jexus installed in the previous step has its own Linux mono runtime to support .net programs.
In this way, the website program developed by .net can be deployed to the Linux server, but it should be noted that Mono does not support the latest .net environment and needs to be downgraded, compiled and released.
After testing, especially for the reference class library of mvc, it should be noted that the latest version cannot be used. The specific reference class libraries and versions that can be used are as follows:
MVC class library reference version
Other things to note
- URL addresses (routing) and static resource addresses are strictly case-sensitive
- Set of applications under virtual directory is not supported (described separately later)
- The file path is based on Linux, Win path such as “D:\” is not supported
The system.web configuration node is updated to solve the problem of System.Net.Http.
<compilation debug="true" targetFramework="4.7.2"> <assemblies> <add assembly="System.Net.Http, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </assemblies> </compilation>
set of applications under virtual directory
On Windows servers, the deployment website can nest applications under virtual directories, as shown in the following figure:
The uploadserver in the figure above is nested into the virtual directory of service as an application. If you want to access the page in the uploadserver, the request address is:
When uploadserver is deployed to Jexus, if the link style of /service/uploadserver is still maintained, and the website is developed using asp.net mvc, there will be a problem that the root directory of the website cannot be correctly located and report to System .InvalidOperationException error. As shown below:
Solving this problem requires two aspects:
First: configure the website in the siteconf file of Jexus, do not configure the second-level or two-segment path. The following figure is the original configuration.
You only need to modify the configuration in the above figure to one level or one path. As shown below:
Second: Configure the reverse proxy, find the root file in the Jexus siteconf to modify, and add the node as shown in the figure below for reverse proxy.
The reproxy=/service/uploadserver on the left indicates that when the requested address matches https://jhrs.com/service/uploadserver, it is actually a reverse proxy request for the server https://jhrs.com/uploadserver This Address, if you will configure nginx reverse proxy, this is not difficult to understand.
Through the reverse proxy, the URL address before the migration can be kept the same, so there is no need to modify any code to keep the request interface or URL consistent.
Webform deployment tips
Recently, I finally completed the migration of the webform website. In addition to paying attention to the capitalization of all resources (URL capitalization), it is the bug repair and compatibility processing in the program.
Deploying the asp.net webform website to the centos system requires the help of the jexus server. In the actual operation process, I publish the website directly through FTP. The general steps are as follows:
First: Install Pure-Ftpd in the pagoda panel, that is, install the FTP service first.
Second: Create an FTP account and point the FTP directory to the website directory. It should be noted here that if your website uses a virtual directory in the original IIS deployment, or if it is deployed as a separate application under the main site, in Visual Studio When configuring FTP publishing, the FTP site path can be configured according to the path hierarchy. Below is the illustration:
For example, on IIS, a virtual directory rzjh (人在江湖) is built under the main site of jhrs.com, and then a mnjh (人在江湖) application is built under rzjh (美女江湖), and the corresponding access address is : https://jhrs.com/rzjh/mnjh
The Visual Studio publish configuration steps are as follows:
After the configuration is complete, click Configure, as shown in the figure below, to verify whether the FTP connection is successful.
Next, click the Settings tab, as shown below.
Through this configuration, you can directly publish the asp.net webform website to Centos through FTP in VS, saving the trouble of copying files through the client. For dozens of websites to be published and deployed to centos, this kind of This method is more convenient in the development stage. Of course, you may say that it is possible to use continuous integration tools to automatically release.
Sometimes when FTP publishing is configured, an FTP publishing error will appear when you click publish, and you will get the following tips.
Failed to add 'bin/jhrs.com.dll' to website when FTP publish error. Ready to proceed (200)
The solution is: 1. Delete the release configuration and create a new one. 2. Check the FTP directory permissions, you can directly give 777 permissions, that is, both read and write permissions. You can directly set the corresponding directory permissions in the pagoda panel. Of course, you can also use the command: chmod -R 777 /www/jhrs.com, and directly set the permissions for the jhrs.com directory to fully open. Change to 777 to indicate that the user, other users in the user group, and other users can read, write and execute, which is a full permission.