Configure Nginx on the virtual machine (cannot access the Internet after solving the configuration problem)

Nginx summary

  1. Nginx installation

You can install it using virtual machines such as Vmware, Virtualbox, Parallels, etc.

I am using VMware here for demonstration.

1.1. Create a virtual machine

1.2. Find the image file you downloaded. It is recommended to use version 7.*.

1.3. Name the virtual machine and set the installation path.

1.4. The default allocated 20G is enough

1.5. Click OK to complete the default configuration.

1.6. After the installation is completed, a black window will appear when you open it.

The window will display login:

You enter your username and press Enter

Password will be displayed:

When you enter the password, it will not be displayed. It is hidden by default. After you complete the input, press Enter and it will be OK.

1.7. After entering the virtual machine, the gateway is closed by default.

You can enter ping qq.com to check the status. If 192.168 is not returned... it means it is not enabled.

After entering this command, the configuration file will be opened.

There is ONBOOT=no in the last line. Change no to yes and it will be ok.

After modification is completed, enter

Restart the gateway and enter the ping qq.com command again

Return the IP address and it will be opened successfully.

1.8. Connect ip through Xshell

Enter ip addr in the virtual machine to view the virtual machine IP address

1.8.1. Open the new Nginx01 connection window

You will be prompted whether to save the secret key, click Accept and Save, then enter the username and password of your virtual machine (you can click to remember the username)

1.8.2. When the icon is green, the connection is successful.

1.8.3. Change to static IP address

Because the virtual machine IP just shown is dynamic, it will change every time it is restarted, so it needs to be changed to static.

After the modification is completed, save it and restart the IP

1.8.4. Modify IP address

Because I just changed the IP address

Therefore, if the IP address is different from the original connected IP address, you need to reconnect (you can check ping 8.8.8.8)

1.8.5. Modify the configuration of being unable to access the Internet

Because after changing the IP, I still can’t access the Internet, so I need to modify some configurations.

Open the Edit-Virtual Network Editor in the upper left corner of VMware

Find NAT mode and click Change settings in the lower right corner

修改成功后 可以点击NAT设置去查看正确的网关 就是设置了的GETWAY

我这里显示的网关IP是192.168.245.2

所以我要把我GATWAY的设置改为192.168.245.2

Guess you like

Origin blog.csdn.net/GSl0408/article/details/129653005