First try. net core2 and ubuntu16.04core2 in ubuntu16.04
There are already many examples and articles about. net core running in Linux. After reading some articles, I also want to try it out. By the way, I will record it ......
Environment: win10 1709 and its built-in Linux subsystem (Ubuntu 16.04 is installed here)
1. Install Ubuntu 16.04
1. Enable Linux
In win10 1709, the built-in Linux version is no longer a Beta version, "Control Panel \ Programs and functions", click "enable or disable Windows functions ", enable "Windows subsystem for Linux"
2. install Linux
Enter bash in cmd and it will prompt you to download it from the Microsoft app store. Enter https://aka.ms/wslstorein the browser to automatically open the Microsoft app store.
I chose Ubuntu and the version is 16.04 LTS. The file size is smaller than 200 MB.
For example, the installation is successful, and the Start Screen is fixed here for your convenience ...... The first time you open it, you will first be asked to enter the user name and password:
Then you can enter lsb_release-a to view the Linux version:
I didn't expect it to be as simple as installing software. The software has its installation directory, and I want to know where the Linux File System is stored ...... after searching for a long time, I finally found C: \ Users \ XXX \ AppData \ Local \ Packages \ CanonicalGroupLimited. ubuntuonWindows_79rhkp1fndgsc \ LocalState \ rootfs
Ii. Install. net core2
This is relatively simple, refer to the official basically no problem, Reference URL: https://github.com/dotnet/core/blob/master/release-notes/download-archive.md
Install. NET Core SDK 2.0.2 with. NET Core 2.0.0
View dotnet information after successful installation
View the built-in dotnet template: dotnet new -- list
3. Run an MVC Template
1. Create a working directory
2. Create an MVC application: dotnet new mvc-n test1. Create the application and run it. Switch to the program root directory and run the following command: dotnet run.
3. Type http: // localhost: 5000/in the browser)
4. Stop the application
5. release dotnet publish-c release.
6. Switch to the "publish" directory and run the following command: dotnet test1.dll.
4. Install nginx
1. sudo apt-get install nginx
2. Check whether nginx is successfully installed. By the way, check the help: nginx-h.
3. start nginx: sudo service nginx start
I failed for the first time. I don't know why. Because it was linux, I checked it for half a day before I knew that nginx had the-t command. I tried it.
Port 80 is occupied. After Ubuntu is installed, why is port 80 occupied? It confirms that the network is shared with win10. Modified the nginx configuration file etc \ nginx \ sites-available \ default.
Check again.
4. Configure the proxy and modify the configuration file again.
5. Access 10020
Oh, the MVC application is off !!! Start again
Another big push error was reported. The original root directory of the application was not configured (circled in the figure above), and the nginx configuration file was modified.
The next visit is finally completed, and this error will be ignored ......
5. Install supervisor
1. install sudo apt-get install supervisor
2. Check whether the supervisor is successfully installed.
3. Configuration
Create test. conf in the etc/supervisor/conf. d directory and enter the following content, depending on your application
Start the supervisor service: sudo service supervisor start. Run the following command: sudo supervisord-c/etc/supervisor/supervisord. conf. If this error occurs
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.For help, use /usr/bin/supervisord -h
Run the following command: sudo unlink/var/run/supervisor. sock.
Check whether your configuration program is successful: ps-ef | grep test1
If dotnet test1.dll is displayed, it indicates that it is successful.
Now let's try to access http: // localhost: 5000. It can be accessed normally. It won't be available here. There are too many images ...... Now, you can access http: // localhost: 5000/without manually executing dotnet test1.dll In the publish directory.
Now we are starting nginx and use the IP address to access: http: // 192.168.1.8: 10020/
So far, install Ubuntu,. net core2, mvc demo, install and configure nginx proxy, install and configure the supevisor daemon, and complete the drill. Haha