Win10 build Ubuntu 18.04 subsystem and build lnmp

Posted May 28, 20202 min read

Turn on developer mode

System Settings-> Update and Security-> For Developers-> Select Developer Mode

Enable Linux subsystem components

System settings-> Applications-> Programs and functions on the right-> Enable or disable windows functions-> Check the Windows subsystem for Linux.
After setting is complete, restart the update

Replace Alibaba Cloud Source

Alibaba Cloud Ubuntu 18.04 source

deb http://mirrors.aliyun.com/ubu... bionic main restricted universe multiverse

deb http://mirrors.aliyun.com/ubu... bionic-security main restricted universe multiverse

deb http://mirrors.aliyun.com/ubu... bionic-updates main restricted universe multiverse

deb http://mirrors.aliyun.com/ubu... bionic-proposed main restricted universe multiverse

deb http://mirrors.aliyun.com/ubu... bionic-backports main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubu... bionic main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubu... bionic-security main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubu... bionic-updates main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubu... bionic-proposed main restricted universe multiverse

deb-src http://mirrors.aliyun.com/ubu... bionic-backports main restricted universe multiverse

Replace apt source:(Back up first)

cd/etc/apt /
sudo cp sources.list sources.list.bak
sudo vim sources.list

Delete all the contents and replace with the top source content:(The command to delete all lines under vim:1, $d)

Then execute

sudo apt update
sudo apt upgrade

Install nginx

Install nginx

sudo apt-get install nginx

View nginx version

sudo nginx -v

Start nginx

sudo /etc/init.d/nginx start

Stop nginx

sudo /etc/init.d/nginx stop

Restart nginx

sudo /etc/init.d/nginx restart

Install apache2

Install apache2

sudo apt-get install apache2

View apache2 version

sudo apache2 -v

Modify the port number of apache2 to 8080(because it conflicts with the port number of nginx)
  1. Modify in the file ports.conf

sudo vi /etc/apache2/ports.conf

The content of the corresponding file is modified to:

NameVirtualHost \ *:8080
Listen 8080

  1. Modify VirtualHost in default

sudo vi /etc/apache2/sites-available/000-default.conf

The first line of the file is modified to:

<VirtualHost \ *:8080>

Start apache2

sudo /etc/init.d/apache2 start

Stop apache2

sudo /etc/init.d/apache2 stop

Restart apache2

sudo /etc/init.d/apache2 restart

Install php7.2

sudo apt-get -y install php7.2