Deploy the program on the Alibaba Cloud server and directly access it with a domain name

Generally, only the IP address of the public network is used to buy a server, which is similar to 10.205.25.32. If you want to use a domain name (such as www.baidu.com) to visit your website directly, you can buy another domain name directly from Alibaba Cloud and bind the domain name resolution to the IP address.

Here is how to resolve the domain name and bind the public IP

1. Domain name:

     域名分为一级,二级,三级域名,如www.baidu.com,baidu为一级域名,www为二级域名,
     此网址没有三级域名,而比如mail.www.baidu.com中,mail为三级域名。

About domain name resolution:

1. First purchase the domain name, then enter the console
Insert picture description here
2. Click resolve

Insert picture description here
3. Then click Add Record

Insert picture description hereInsert picture description here

Select A for the record type. The host record allows you to write your own second-level domain name or third-level domain name. The resolution line selects the default. The record value is the ip you want to bind. The TTL is selected for 10 minutes, and click OK to bind.

2. Server environment construction

So how do you install the environment and deploy the program for the server you just bought? Generally, the server bought is like a new computer, there is no extra software in it, and there is no program environment or database, so we need to install it ourselves.

    我是做java的,用mysql数据库,这里讲的是部署java程序。首先准备好jdk,mysql,tomcat,打包
    上传到服务器,再解压,如果服务器没有压缩软件,网上下载即可。一次安装jdk,配置环境变量,安装
    mysql,tomcat,将自己的程序传到tomcat中的webapp中。

    到这里准备工作完成,这时启动tomat的话,在本地输入localhost:8080是可以打开程序的,但用公网ip
    或者域名就无法访问了,所以我们要开始配置tomcat。打开server.xml,将<Engine name="Catalina" 
    defaultHost="localhost">,<Host name="localhost"  appBase="webapps"
     unpackWARs="true" autoDeploy="true">两项的localhost换成你的域名或者IP名(其实写IP就行,
     输入域名自动回找到绑定的IP地址),开始不建议修改端口,tomcat默认端口为8080,想在外网访问程序,
     需要输入域名和端口号才行,如果不写端口号,必须将配置中的端口设置为80端口,但80端口的域名必须
     备案,否则无法正常访问。最后在host中添加<Context path="" docBase="C:\file\apache-tomcat
     -7.0.70\webapps\coolsite" reloadable="false" caseSensitive="false" debug="0"></Context>,
     在docBase中输入你的项目路径。配置好后启动tomcat。

Here you will find that the external network still cannot access your program. The reason is that security groups must be configured in Alibaba Cloud. Enter the Alibaba Cloud Management Console -> Cloud Server ECS -> Network and Security -> Security Group, then your server list will be displayed, click "Configure Rules" in the lower right corner of the server you want to modify, and the list of rules will be displayed.

Insert picture description here
We need to click "Add Security Group Rule", add the incoming direction, and add ports 8080 and 80. At this time, if you visit the website again, it will open smoothly. If the domain name resolution is successful, you can directly use the domain name plus port 8080 to access, and after the domain name is successfully registered, you can directly use the domain name to access.

Guess you like

Origin blog.csdn.net/weixin_43945983/article/details/109692658