vue + express + mysql Project Summary (node project deployment Ali cloud General)

Original posted on my personal blog: original text click here

  The previous experience untold hardships, finally put all things blog are ready, now just waiting for deployment. Here I was introduced to my deployment process:

First, purchase a server and domain name

  If desired domain name (without the domain name can also be accessed via ip, though inconvenient, but can save hundreds of dollars a year for domain names, ha ha), the proposed purchase in advance, because the domain name for the record of a long time.

  I was in the Ali goes to buy the domain name and server, the server is in aliyun purchase of products on the mobile phone side activities, six months ¥ 9.9 (renewals after six months if that is the original price to buy !!! Here is the screenshot), the domain name is ¥ 55 year (.com expensive), click here to select the right your server it ~ ~image description

Second, the server environment to build

  The new servers have nothing to buy, you need to set up the environment according to their own needs, my blog server node is built, so I built a node to the server environment, other environments your own Baidu ~ ~ ~ (my server is CentOS 7).

My remote connectivity tools are used is: XShell , file upload are: FileZilla . Of course, you can also use other tools, please download ~ ~

1. Format and mount the dial
First put the original address " Linux data format and mount the disk ", shining like a step by step tutorial.

  在教程的第6步执行完之后,我执行了这条命令:mkdir /brand,创建了一个 brand 的文件夹来存放我自己上传的东西,没有放在教程的那个 /mnt 文件夹中,从第7步开始把 /mnt 换成 /brand 就好了。执行完这些后第一步就算是完成了,现在就可以在你的安装你所需要的东西了~~

2.安装数据库
原文地址《 centos7 mysql数据库安装和配置
  • 第二步的时候先执行以下两行代码,然后直接按 方法二 进行mysql的安装。数据库远程工具我用的:Navicat Premium
# yum install mysql
# yum install mysql-devel

  按照教程执行完毕后,如果有需要,可以修改数据库默认的存放位置(请看下面教程),如果不想修改,就可以使用 Navicat Premium 远程上你的远程数据库上进行建库建表的操作了。

2.1.修改数据库文件默认存放位置
1.检查mysql数据库存放目录
先登录数据库
mysql -u root -p "password"

查看sql存储路径(查看datadir 那一行所指的路径)
show variables like '%dir%'; 
2.停止mysql服务
service mysqld stop
3.创建新的数据库存放目录
mkdir /data/mysql
4.移动/复制之前存放数据库目录文件,到新的数据库存放目录位置
cp -R /usr/local/mysql/data/* /data/mysql/
5.修改mysql数据库目录权限以及配置文件
chown mysql:mysql -R /data/mysql/

打开/etc下的my.cnf文件

vim /etc/my.cnf

将[mysqld]条目下的datadir和socket这两栏注释掉,并重新改新成你当前的路径,我的是在/home/data/目录下的,以下是我的修改内容供大家参考。

#datadir=/var/lib/mysql
datadir=/home/data/mysql
#socket=/var/lib/mysql/mysql.sock
socket=/home/data/mysql/mysql.sock)

在最后一行新增一个[mysql]的条目,并在下面新增以下内容:

[mysql]
socket=/home/data/mysql/mysql.sock
6.启动数据库服务
service mysqld start

然后再执行第1步可以看到路径已经改了
3.node环境的搭建
原文地址《 部署Node.js项目(CentOS)

  I follow the tutorial executing the step 2 of the step 4 did not follow its course to do.

  Executing the step 2 of the first 4 steps , I installed cnpm:

npm install -g cnpm --registry=https://registry.npm.taobao.org

  Cnpm After the installation is complete, create a soft link, the cnpm effective global command:

ln -s /root/node-v6.9.5-linux-x64/bin/cnpm /usr/local/bin/cnpm

4. Install pm2 node daemon process

1.安装
cnpm install -g pm2

2.创建软链接,使cnpm命令全局有效:
ln -s /root/node-v6.9.5-linux-x64/bin/pm2 /usr/local/bin/pm2

3.运行
cd node/
pm2 start ./bin/www

5. Installation zip, unzip application

In order to avoid uploading large files may upload time, or during transmission file is missing, I usually first to the server in the local compressed and then decompressed, so the need to use this
1、安装zip、unzip应用:

yum install zip unzip

2、压缩和解压文件

  以下命令均在你 '上传文件' 的目录下操作
    cd /home #进入/home目录
  a、把/home目录下面的mydata目录压缩为mydata.zip
    zip -r mydata.zip mydata #压缩mydata目录
  b、把/home目录下面的mydata.zip解压到mydatabak目录里面
    unzip mydata.zip -d mydatabak
  c、把/home目录下面的abc文件夹和123.txt压缩成为abc123.zip
    zip -r abc123.zip abc 123.txt
  d、把/home目录下面的wwwroot.zip直接解压到/home目录里面
    unzip wwwroot.zip
  e、把/home目录下面的abc12.zip、abc23.zip、abc34.zip同时解压到/home目录里面
    unzip abc\*.zip
  f、查看把/home目录下面的wwwroot.zip里面的内容
    unzip -v wwwroot.zip
  g、验证/home目录下面的wwwroot.zip是否完整
    unzip -t wwwroot.zip
  h、把/home目录下面wwwroot.zip里面的所有文件解压到第一级目录
    unzip -j wwwroot.zip

6.nginx installation, configuration, binding domain

1, install nginx

yum -y install nginx

2, start nginx

service nginx star

3. Access (nginx default is port 80)

If the content of the following figure appears, the installation is successful.
image description

4, binding domain

Into the folder /etc/nginx/conf.d/, I put in this folder below the 3 config file, as shown, the front end (wen.conf) are binding, back-end (admin.conf) and server (the server.conf) domain where a configuration as shown below, other similar image description

image description

5, restart nginx

service nginx restart
(上面代码不行可以试试: nginx -s reload)
重启完毕后就可以通过域名访问了~~~

So far, the deployment is complete, you can play the happy

Welcome to my personal blog and write new code github ~ very bad, seek guidance on January Gangster

Online blog address click here

Github Click here

(First edition with vue written version is online now react version, the back-end node express is used), the code feel bad stroke. . . Gangster wooden door you have a good point of learning resource recommendation.

Guess you like

Origin www.cnblogs.com/baimeishaoxia/p/12036806.html