Article Directory
First, buy server
- 1, Ali cloud into the official website, select the server ECS, I bought the students, of course, if you are students, students can buy a dedicated server through preferential status, 9.5 month
- 2, then there will be a password, the password will be used from start to finish will be oh
- 3, after the purchase is successful, the instance is created successfully, it will have its own server a
- 4, the console can see your instance, there will be ip address of the server you are buying, and the show is running, this can begin preparations for the deployment of
Second, download and install putty Xftp
注意:此教程针对windows系统,mac可根据如下参考本教程
- Connect to the server: the
windows
byputty
,mac
in needputty
, directly through the command linessh [email protected] -p 22
, since the latter are connected to the server inlinux
executing the command, the command with thewindows
same - File transfer: the
mac
next downloadFileZilla
,FileZilla
withXftp
basically the same set ip and port can be connected, use
putty
And Xftp
free to download and install the Internet
putty connection server
1, open PuTTY
2, set ip according to Figure
3, the following screen appears, set the login name for root, password is the password for registration service (password character does not appear, rest assured that it wants to enter the finished press Enter)
4. after successful login, you enter into the Linux
system the
Installation node
1, the first update to the latest version of yum
yum -y update
2, we will use the latest source code to build Node.js, to install the software, you need to compile a set of source code development tools
yum -y groupinstall "Development Tools"
3, into the / usr / src folder, the folder is usually used to store the software source code
cd /usr/src
4, from Node.js
the site to obtain the source code archive, I selected versionv10.13.0
wget http://nodejs.org/dist/v10.13.0/node-v10.13.0.tar.gz
5, unzip the file, folder and enter
tar zxf node-v10.13.0.tar.gz
cd node-v6.9.1
6, set global environment variables, in order to use the global node command
ln -s /usr/src/node-v10.13.0/bin/node /usr/local/bin/node
ln -s /usr/src/node-v10.13.0/bin/npm /usr/local/bin/npm
7, to see if successfully set
node -v
npm -v
8, install pm2
pm2
used to start the program and restart when you need very useful module, you can view the running status of the service at any time
npm -g install pm2
9, set the global variable
ln -s /usr/src/node-v10.13.0/bin/pm2 /usr/local/bin/
Then you can use pm2
commands
Install mysql
1, looking for community source installed tmp
in
cd /tmp
wget http://repo.mysql.com/mysql-community-release-el7-5.noarch.rpm
rpm -ivh mysql-community-release-el7-5.noarch.rpm
2, by mounting yum
yum install mysql mysql-server mysql-devel -y
3, start mysql
systemctl start mysql.service
4, set user and password
通过yum安装的是没有用户名和密码的,所以得设置
mysqladmin -u root password admin
User name root
, password is admin
5, after a good set can log
mysql -uroot -padmin
View database
show databases;
Since then, the database configuration is completed
Xftp Upload Code
1. Open the downloaded Xftp
2, click the New
appears
the name of their own to take a project name. Host, Ali fill public cloud servers IP
, protocol selection SFTP
, port usage 22
, user name root
and password for the purchase of Ali cloud the time to remember your password. Finally, click OK.
3. Double-click on the icon below to enter root
folder
shown: the left is the local computer, right for the server folder
we own node项目
by right pass into the transmission home/自定义文件夹/
, of course, database files have passed up together in order to initialize
4,服务代码传到服务器上后要进入服务器 node 根目录通过 putty 进行 npm install 安装相关依赖
Start node applications
After uploading the code, go back to putty, into the project directory, start the application using the pm2
cd /home/jqq
pm2 start server.js --name test
Later --name
you can not write, rename mean
when appeared the following table shows the successful launch of the
- By
pm2 list
viewing running applications - By
pm2 stop test
stopping the application - By
pm2 delete test
deleting applications - By
pm2 log app
viewing the application log
Here node to start is complete
Configure mysql
To avoid recognition failure case, the case of the configuration
1, the configuration file is opened
vi /etc/my.cnf
Press the i
edit key, as shown in [mysqld]
after the addition lower_case_table_names=1
, press esc
the key, and then enter the :wq
save and exit
2, rebootmysql
systemctl restart mysqld.service
3, the database connection
mysql -uroot -padmin
4, create a test database
CREATE DATABASE test DEFAULT CHARACTER SET utf8;
By show databases;
viewing the database has been in existence
4, import data
- Then the previous step, with the first exit key combination ctrl + c mysql console, and then enter the following command to import data in the linux environment
mysql -u root -padmin --default-character-set=utf8 test < /home/jqq/web.sql
5, the authentication data
mysql -uroot -padmin
use test;
show tables;
select count(*) from product;
6, configure logon rights
grant all privileges on `test`.* to 'root'@'%' identified by 'admin' with grant option;
mysql> FLUSH PRIVILEGES;
test为数据库,root为用户,admin为密码,下面命令为让配置生效
Such data is set to complete can be started
Third, the installation configuration tomcat
1, the installation
yum
is not on tomcat
the source, you can go to the official website to download the latest by the Xftp
spread tmp
, the download and use the following decompression, by mv
command to move the folder
cd /tmp
wget http://mirrors.tuna.tsinghua.edu.cn/apache/tomcat/tomcat-7/v7.0.92/bin/apache-tomcat-7.0.92.tar.gz
tar xzf apache-tomcat-7.0.92.tar.gz
mv apache-tomcat-7.0.92 /usr/local/tomcat7
2, start tomcat
/usr/local/tomcat7/bin/startup.sh
3. Verify
netstat -anp|grep 8080
4, open port security group
5, then the router in a configuration vue, finished package upload
6, by Xftp the vue packaged files to tomcat, as: I created a new folder in the webapps so that future access path will be more of a secondary path jqqzz, of course, we can put the root directory does not have to create a secondary path
7, in the jqqzz
project create a new folder WEB-INF
, and then inside the new file web.xml
to edit the file, insert the following into the file, the processing 404
returns to index.html
the page, and the process history
mode
<?xml version="1.0" encoding="ISO-8859-1"?>
<web-app xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
version="3.0"
metadata-complete="true">
<display-name>webapp</display-name>
<description>
webapp
</description>
<error-page>
<error-code>404</error-code>
<location>/index.html</location>
</error-page>
</web-app>
Such access ip:8080/jqqzz
can enter it into your own project
注意:在某些时候,一些命令操作文件的时候会没有权限导致失败,这时使用一下命令给予文件或文件夹权限,777为所有用户拥有最高权限,R表示允许其目录下的子目录的文件及文件夹
chmod 777 文件夹或文件名
chmod 777 *.文件类型
All this work is all done