Questions you may encounter:
- Nginx doesn’t start
- Where is the front pack
- The nginx server is up and the local server can access the Internet
When I configured my own project, I met some problems. After searching online for a long time, I found that all I said was not complete. So I sorted out the problems I met and summarized them
Download and start nginx
Nginx can be downloaded from nginx.org/en/download… It is recommended to download the stable version directly:
Install nginx in the root directory, hold down shift and right click to invoke the command window to enter the command
start nginx
Copy the code
You’ll see a box pop up and disappear, and that’s fine by the time you go to http://localhost/ in a crappy browser on the server, the link will say Welcome to Nginx, indicating that Nginx started successfully
Configure nginx
Nginx \conf\nginx.conf is the configuration file of nginx.
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
indexindex.html index.htm; }}Copy the code
The root file is the directory file, So now the default is to go to the root HTML folder and index is the entry file and the default means the entry file is index.html or index.htm and you don’t need to change its configuration, you can put the files that we packed in the front end in the HTML folder, You can also create a folder and put the contents of the dist packed in the front end into the HTML folder:
You need to restart Nginx to modify the configuration
You need to restart Nginx to modify the configurationSay the important things twice
nginx -s reload
Copy the code
Go to http://localhost/ and you should see your project. PS: Because the browser is so bad, it might only load a title
Configure a Windows Serve server
Now you can see that you can access it from inside the server, but you can’t access it from outside the public IP and that’s what bothers me the most, First you need to turn off the firewall in the server in control Panel => System and Security => Windows Firewall => Enable and Disable Windows Firewall => All set to Off click OK and then go to advanced Settings
So close
At this time you may have been able to access the Internet, but I still can not access, I am Ali cloud server, this needs to set up the server
The solution is that the public IP address of ali Cloud server cannot be accessed
- First go to your instance click on security Group and then click
Adding to a Security Group
- After joining, there will be a security group, click on the security group
Configuration rules
- After clicking on
Quick add
, normally only selectedhttp
Just in case we have to go the other way, I suggest just shuttle haThe selectedAll click ok
After saving, you can visit your website freely, wuhu takeoff
Try_files $uri $uri/ /index.html;
location / {
root html;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
Copy the code
conclusion
This is my summary of the problems Windows Serve Nginx deployment may encounter as my own notes if can help others that much the better, finally