• 内核版本号
  • uname -r
  • 系统版本号
  • sudo lsb_release -a
  • 提权
  • sudo -i
  • name: blissyang pwd: qwer123456
  • cmd 输入 bash 切换至Linux
  • sudo apt-get install python 安装Python报错:404 Not Found [IP: 91.189.88.162 80]
  • sudo apt-get update

Ubuntu安装yum

  • sudo apt-get install build-essential
  • sudo apt-get install yum

安装Nginx

  • sudo apt-get install nginx
  • ps -ef | grep nginx
  • sudo service nginx start
  • sudo nginx -t
  • sudo curl localhost
  • ifconfig
  • sudo apt install nginx-full
  • 查看进程:netstat -ntpl 或者
  • netstat -ltunp
  • Nginx默认安装目录:/etc/nginx
  • Nginx安装成功:
<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

配置编辑Nginx文件:

  • 参考:https://www.runoob.com/w3cnote/nginx-setup-intro.html

  • vim nginx.conf 键盘按下i开始编辑,Esc,:wq保存退出

  • Nginx重启 nginx -s reload

cat nginx.conf 查看Nginx配置文件

  • user www-data 改为当前账号 root

  • [x]server配置

  • server {
    listen 80;
    server_name 47.93.205.239;

       location / {
          root   /root/Vue-Music/dist/;
          index  index.html index.html;
      }
      
      location ~ /api/ {
      proxy_pass http://47.93.205.239:80;
      } 
    

    }

  • 整体配置参考:

user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;
 
        server {
         listen       80;
         server_name  47.93.205.239;

         location / {
            root   /root/Vue-Music/dist/;
            index  index.html index.html;
        }
	location /v1/ {
           proxy_redirect  off;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header Host $http_host;
           proxy_pass http://tingapi.ting.baidu.com/;
        }
        
        location /baidu_music_api/ {
#	   root /root/Vue-Music/dist/;
#	   fastcgi_pass  tingapi.ting.baidu.com:80;
#	   fastcgi_param   SCRIPT_FILENAME /scripts$fastcgi_script_name;
	   proxy_redirect  off;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
      	   proxy_set_header Host $http_host;
	   rewrite ^/baidu_music_api/(.*)$ http://tingapi.ting.baidu.com/$1 last;
	} 
        
       }
	server {
         listen       80;
         server_name  music.baidu.com;
		
	location / {
           proxy_redirect  off;
           proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
           proxy_set_header X-Real-IP $remote_addr;
           proxy_set_header Host $http_host;
           proxy_pass http://tingapi.ting.baidu.com/;
	}
	
	}        

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}

vue 项目打包发布

打包后的vue项目直接放在自定义的服务器位置,注意创建一个和本地项目同名的文件夹,记住服务端的dist的目录,用于在Nginx配置代理使用。
服务器的链接请参考:https://blog.csdn.net/qq_33036599/article/details/82789666
在这里插入图片描述

PS 关于Nginx的其他配置

1.安装git

 sudo apt-get install git

2.安装python

sudo apt-get install python

3.安装curl库

sudo apt-get install curl
  1. 创建bin文件,并加入到PATH中
mkdir ~/bin
PATH=~/bin:$PATH







Logo

前往低代码交流专区

更多推荐