一个新服务器操作

    技术2022-07-11  125

    1.初始化 sudo apt update 2.安装node --方法未知 # apt-get update # apt-get install -y python-software-properties software-properties-common # add-apt-repository ppa:chris-lea/node.js # apt-get update # apt-get install nodejs 3.node -安装最新版本的node curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash - sudo apt-get install -y nodejs 4. npm 安装 sudo apt install npm 更新npm的包镜像源,方便快速下载 sudo npm config set registry https://registry.npm.taobao.org sudo npm config list 5. 克隆代码git clone https:xxx 6. pm2 下载 npm install pm2 -g 7. yarn 安装 //步骤1.添加GPG密钥 curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - //步骤2.添加Yarn存储库 deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list //步骤3.更新包列表并安装Yarn sudo apt update sudo apt install yarn 8.如果您的系统上尚未安装 Node.js,则上面的命令将安装它。 那些使用 nvm 的人可以跳过 Node.js 安装 sudo apt install --no-install-recommends yarn nginx配置 个人配置 /etc/nginx/conf.d/www.conf 无论写在conf.d 或者 sites-enables 两者相同写完之后重新启动下 sudo nginx -s reload server { listen 80; //80端口不需要添加端口号19950之类的 server_name www.chen1995.com或者服务器ip地址; location / { ## proxy_pass http://127.0.0.1:19950; root /root/micystore/dist; //项目打包的dist目录 } location /manage { proxy_pass http://127.0.0.1:6600; ## root /root/micystore/dist; } } mysql有关的。 报错1: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' 解决方案: 1:首先检查是否安装了mysql-server了 sudo apt-get install mysql-server to install mysql on ubuntu, 如果mysql-server已经存在了,那么在去尝试一下是否成功,如果还是这个错误的话那么就是文件/var/run/mysqld/mysqld.sock 不存在。 2:如果/var/run/mysqld/mysqld.sock文件不存在应该怎么办? 执行 vim /etc/mysql/my.cnf # # The MySQL database server configuration file. # # You can copy this to one of: # - "/etc/mysql/my.cnf" to set global options, # - "~/.my.cnf" to set user-specific options. # # One can use all long options that the program supports. # Run program with --help to get a list of available options and with # --print-defaults to see which it would actually understand and use. # # For explanations see # http://dev.mysql.com/doc/mysql/en/server-system-variables.html # # * IMPORTANT: Additional settings that can override those from this file! # The files must end with '.cnf', otherwise they'll be ignored. # !includedir /etc/mysql/conf.d/ !includedir /etc/mysql/mysql.conf.d/ 你的mysql的配置在/etc/mysql/mysql.conf.d目录下的mysqld.cnf文件,打开如下: 可以看到:bind-address = 127.0.0.1 socket = /var/run/mysqld/mysqld.sock 等信息 我的虚拟机是/var/run下面没有mysqld目录,执行下面命令,然后目录和sock文件就都有了 sudo mkdir -p /var/run/mysqld sudo chown mysql /var/run/mysqld/ sudo service mysql restart 现在就都有了: 然后执行:mysql -u root -p 然后提示你输入密码,即可, 如下图所示: 就可以了 报错2: 2003报错。 因为我的服务器是新服务器。所以没有设置mysql 白名单。链接不上去就是没有设置白名单 ```bash MySQL设置白名单教程--我个人操作登录 1 登录mysql mysql -h host -u username -p password 2 切换至mysql库--- use mysql; 3 查看当前允许登录IP及用户 select Host,User from user; 4 删除不必要而表中存在的IP和用户 DELETE FROM user WHERE User='username' and Host='host'; (host值为“%”或空表示所有IP都可登录,一般来说此类行需要删掉) 5 增加需要而表中没有的IP和用户 /* * username : 我的username 是root * host : 我的host 是 本机IP地址 * password : 我的password 是服务器mysql-密码 */ GRANT ALL PRIVILEGES ON *.* TO 'username'@'host' IDENTIFIED BY 'password' WITH GRANT OPTION; 6 使更新的配置生效 FLUSH PRIVILEGES;
    Processed: 0.011, SQL: 9