buy a range of things
In fact, it is to spend a lot of money to buy a block, server, domain name, cloud analysis, and spend a lot of money. . .
1. Rent a server
Baidu search Aliyun
Enter the official website home page, click to log in
Enter the login page, you can use your email to log in or register
Enter the registration page and fill in the registration information
After successful login, go to the homepage, click Cloud Service ECS , click to buy recommendation or purchase configuration
Choose the product according to the actual situation, it may be out of stock, then you need to change the purchase conditions
If it is a new user, real-name authentication is required before purchasing, and the order can only be placed after completing the authentication according to the prompts.
2. Buy a domain name
Click on Domain/ Domain List
Click on Domain Registration
query domain name
The list will show whether the domain name has been registered, and there is a button to add to the list after the domain name that has not been registered.
After adding to the list, you can go to checkout
The basic version of cloud analysis is available for purchase. After you have selected it, click to buy it now.
Click Parse to enter the parsing page, if you don't know how to use it, click on the novice guide settings
Click Modify Now to set website resolution, and associate the domain name with the IP.
Once set, you will see
3. Filing
Click on the record, this is so troublesome, there are so many things to do in my record. .
Go to the record page
Click to log in to the filing system to enter the login page (this is the filing system, separate)
Build an Alibaba Cloud server environment
When I connect to the server remotely, I use SecureCRT and filezilla, one is for uploading files, and the other is for connection.
1. Use SecureCRT to connect centos.
Note that you may not be able to log in for the first time after you just bought the server. At this time, you only need to restart the console.
Then you need to enter the password, if there is no password, go to the console to change the password
Second, install JDK.
There are two sets of Java JDK, one is Oracle's JDK, and the other is OpenJDK. I chose OpenJDK as the development environment for Java. I use SecurityCRT to operate CenOS6.5 on the cloud server for installation and configuration.
2.1. View available packages
CentOS 6.X and 5.X come with OpenJDK runtime environment (openjdk), we use yum to view the list of open-jdk packages available under CenOS, execute the command: yum search java | grep -i –color JDK
2.2, installation
After viewing all the available installation packages, we choose the one we need to install. I chose Java8. Execute the command: yum install java-1.8.0-openjdk java-1.8.0-openjdk-devel
Note : You can also use javac as a test command. Some people on the Internet say that you need to set the java environment variable. In fact, you can do it here. You don't need to go to etc/profile to set the java environment.
Third, install tomcat.
Centos can actually use the simplest yum install tomcat. Here I will introduce my method.
3.1. Prepare resources
3.1.1, filezilla login
After logging in, just drag it to the right.
We need to prepare the compressed package of Tomcat8 first. I first downloaded Tomcat8 locally, and then used FileZilla to transfer it to the remote server.
3.2, decompression
Use the tar command to decompress the Tomcat archive. Execute the command: tar -zxvf apache-tomcat-8.0.0.RC3.tar.gz
3.3. Mobile
After decompression, we need to move the decompressed directory to the /usr/local directory. Execute the command: mv apache-tomcat-8.0.0 /usr/local
3.4. Rename
For the convenience of memory and future use, we use the mv command to rename the folder to tomcat8. Execute the command: mv apache-tomcat-8.0.0 tomcat8
3.5, placement JAVA-HOME
In fact, this step is not necessary, because you can directly go to the bin directory and start it.
Edit the /usr/local/tomcat/bin/catalina.sh file and configure the JAVA-HOME variable so that Tomcat can search the JDK directory and work with it.
3.6, start the service
Now, let's start tomcat and try it out. Use the cd command to switch to the /usr/local/tomcat8/bin/ directory, and then execute the command: ./startup.sh
3.6, open ports
After starting the service, we also need to open port 8080. Note: HTTP protocol uses port 80 by default, while Tomcat uses port 8080 by default.
3.7. Test
After the above configuration is complete, check the operation of Tomcat. Execute the command: ps -ef | grep tomcat
Then, open the browser and test it. For local machine testing, enter http://localhost:8080 in the address bar ; if it is a remote machine, enter http://remote server IP:8080 to view the results.
3. Install mysql
This is what took me the longest time, because there is a problem ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock
If you are lucky enough to spray this problem, then click in to see my solution
3.1, install mysql
We use yum to install mysql, execute the command yum install mysql-server . If it is not installed on the machine, it will be installed automatically, and Complete will indicate successful installation. If it is already installed, the following will occur:
3.2, view the installation
We can use the rpm command to check the installation of mysql: execute the command rpm -qa | grep mysql*
3.3, start the service
After the installation is complete, let's try to start the mysql service: execute the command service mysqld start
Note: it is mysqld, not mysql
3.4, test mysql
The mysql service has been started, so let's test it, whether it can run correctly? After starting, let's try to operate in mysql. Execute the command: mysql
Note: The \q command means to close the connection and exit mysql
Fourth, configure mysql
After the correct installation, we need to perform some tests on mysql to facilitate our future work.
4.1. Self-start at boot
我们首先来设置 mysql 开机自启。为什么要设置呢?因为每次关机重启后,mysql 服务都会被停止,处于 stop 状态,这时要使用 mysql,就得执行 service mysqld start 命令,比较繁琐,所以设置一下开机自启,可以减少麻烦。
我们利用 chkconfig 命令来设置 mysql 开机自启:执行命令 chkconfig mysqld on
通过 chkconfig –list 命令可以看到各服务的情况,从中可以看到 mysql 的情况:运行级别为2、3、4、5的情况下都是on(开启)的状态
[各状态的解释]
等级0表示:表示关机
等级1表示:单用户模式
等级2表示:无网络连接的多用户命令行模式
等级3表示:有网络连接的多用户命令行模式
等级4表示:不可用
等级5表示:带图形界面的多用户模式
等级6表示:重新启动
4.2、开启 3306 端口
对于 mysql,我们知道一般都是使用 3306 端口。在我们 Java 程序的数据库连接中,可以看到 jdbc:mysql://localhost:3306/dbname 的语句。因此,在 Linux 下,我们需要开放 3306 端口,以便本机和外部访问 mysql。执行命令:
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
4.3、修改密码
一般而言,我们都会启动密码认证。因此我们给用户设置一下密码。进入 mysql,执行命令:update user set password=password(‘密码’) where user=’用户名’; 以此来给用户设置密码
4.4、配置远程登录
有一种需要,叫远程登录mysql。因此,我们也配置一下 mysql 的远程登录。该设置,同样是需要先进入 mysql 数据库,然后再执行命令 grant all privileges on . to ‘root’@’%’ identified by ‘root’ with grant option;
命令详解:
# 将所有权限赋予给 root 用户,允许其进行远程登录
grant all privileges on *.* to 'root'@'%' identified by 'root' with grant option;
参数解释:
① all privileges:赋予所有的权限给指定用户,也可以替换为赋予某一具体的权限
② *.*:所赋予的权限是针对全部数据库的全部表。若指定某一具体数据库的具体表,如:thinkphp_user
③ root:表示给root用户授权
④'%':表示不限制连接的 IP。若想只允许某特定的 IP 进行远程登录,可以改为具体 IP。
⑤ by 'root':root 用户的密码
设置好远程登录后,我们测试一下是否可以远程登录。在本地机器执行远程登录命令如下:
# 连接时需要验证密码
mysql -h 远程机器IP地址 -P 3306 -u 用户名 -p thinkphp
# 在登录的时候直接写上密码,p 和密码不能分开
mysql -h 远程机器IP地址 -P 3306 -u 用户名 -p密码 thinkphp
五、部署javaweb项目
我们要部署 Java Web 项目,那就至少得将项目上传到云服务器。其实过程很简单,基本上也就是下面三个步骤:
① 打包上传:将项目打包成 war 文件,然后利用 FileZilla 传到远程服务器
② 部署:使用 cp 或 mv 命令,将 war 文件移动到 Tomcat 目录下的 webapps 下
③ 重启 Tomcat,访问我们的项目
5.1、上传项目war包
5.2、移动到tomcat的webapps目录中
在这个过程中,我们需要注意。因为一般而已,作为一个 Web 项目,我们肯定是有数据库的使用的。那么数据库部分怎么办呢?其实,只需要将我们已有的数据库转储为 sql 文件,然后将 sql 文件上传到云服务器上执行即可。以 mysql 为例,如下操作:
5.3、Mysql 案例
① 转储为 sql 脚本,并上传:先在本地将我们项目使用的数据库转为 sql 文件,上传到云服务器上
② 执行 sql:然后进入 mysql 中执行该 sql 文件
发现执行的时候有错。原因是我们此时的 mysql 中没有 thinkphp 这个数据库。我们查看下当前的数据库,执行命令 show databases;
发现确实没有 thinkphp 这个数据库,因此我们创建一个,执行命令 create database thinkphp;
再次执行
③View the results
The complete deployment process here is here, I hope it will help you.