1.启动MySQL:
brew services start mysql
2.登入MySQL:
mysql -u root -p
然后输入密码
3.MySQL如果无法成仓登录就用下面方式登录
4.退出MySQL
Ctrl+D
5.关闭MySQL服务
brew services stop mysql
服务器相关
Nginx部署和使用
安装:(已安装可以忽略此步骤)
sudo yum install nginx
启动:
sudo systemctl start nginx
将 Nginx 服务设置为在系统启动时自动启动
sudo systemctl enable nginx
进入Nginx配置危机
sudo vim /etc/nginx/conf.d/default.conf
检查配置是否正确
sudo nginx -t
更新Nginx配置
sudo systemctl reload nginx
检查Nginx服务状态(显示active (running)是已启动)
sudo systemctl status nginx
重启Nginx
sudo systemctl start nginx
创建前端网页的目录(mkdir -p递归创建)
sudo mkdir -p /var/www/html
设置权限
sudo chown -R nginx:nginx /var/www/html
sudo chmod -R 755 /var/www/html
sudo chmod 644 /var/www/html/index.html
进入配置文件
sudo vim /etc/nginx/conf.d/default.conf
配置内容
server {
server_name 121.41.97.247;
root /var/www/html;
**index** index.html;
location / {
try_files **$uri** **$uri**/ /index.html;
}
# 代理所有以/api开头的请求到后端
location /api {
rewrite ^/api(.*)$ **$1** break;
proxy_pass http://localhost:8080; # 后端服务地址
**proxy_http_version** 1.1;
**proxy_set_header** Upgrade **$http_upgrade**;
**proxy_set_header** Connection 'upgrade';
**proxy_set_header** Host **$host**;
**proxy_cache_bypass** **$http_upgrade**;
}
}
退出后检查和更新配置(检查配置是否正确:sudo nginx -t 更新Nginx配置:sudo systemctl reload nginx)
上传前端包到服务器
scp -r 本地路径 root@ECS的IP:/var/www/html
示例:
scp -r /Users/guochangzheng/Desktop/探究/Java学习/Full_Stack_Vue/www/fh_lesson/* root@121.41.97.247:/var/www/html