各工具所扮演的角色

ansible:

配合packer生成安装有apache的基础镜像

packer:

生成amazon AMI

terraform:

以packer生成的镜像为基础,布署web服务器

下面我要放各种配置文件上来了,先来个目录树,省的凌乱。。。

  1. packer/
  2. ├── bastion.json
  3. ├── playbook.yml
  4. └── roles
  5. └── httpd
  6. └── tasks
  7. └── main.yml

bastion.json(这个是packer要用到的文件)

  1. [root@ip-172-31-42-166 packer]# cat bastion.json
  2. {
  3. "variables": {
  4. "aws_access_key": "",
  5. "aws_secret_key": "",
  6. "aws_region": "us-west-2"
  7. },
  8. "provisioners": [
  9. {
  10. "type": "ansible",
  11. "playbook_file": "./playbook.yml",
  12. "ansible_env_vars": [
  13. "ANSIBLE_HOST_KEY_CHECKING=False",
  14. "ANSIBLE_SSH_ARGS='-o ForwardAgent=yes -o ControlMaster=auto -o ControlPersist=60s'",
  15. "ANSIBLE_NOCOLOR=True"
  16. ]
  17.  
  18. }
  19. ],
  20. "builders": [{
  21. "type": "amazon-ebs",
  22. "access_key": "{{user `aws_access_key`}}",
  23. "secret_key": "{{user `aws_secret_key`}}",
  24. "region": "{{user `aws_region` }}",
  25. "source_ami": "ami-0031f978",
  26. "instance_type": "t2.micro",
  27. "ssh_username": "root",
  28. "ami_name": "packer-bastion {{timestamp | clean_ami_name}}"
  29. }]
  30. }

下面是ansible的playbook

  1. [root@ip-172-31-42-166 packer]# cat playbook.yml
  2. ---
  3. - hosts: all
  4. remote_user: sysop
  5. become: yes
  6. vars:
  7. AWS_ACCESS_KEY_ID: '{{ AWS_ACCESS_KEY_ID }}'
  8. AWS_SECRET_ACCESS_KEY: '{{ AWS_SECRET_ACCESS_KEY }}'
  9. filename: '{{ filename }}'
  10. rolename: '{{ rolename }}'
  11. project: '{{ project }}'
  12. release: '{{ release }}'
  13. envname: '{{ envname }}'
  14. processList: '{{ processList}}'
  15. roles:
  16. - httpd
  17. [root@ip-172-31-42-166 packer]# ls
  18. bastion.json playbook.yml roles
  19. [root@ip-172-31-42-166 packer]# cat playbook.yml
  20. ---
  21. - hosts: all
  22. remote_user: sysop
  23. become: yes
  24. vars:
  25. AWS_ACCESS_KEY_ID: '{{ AWS_ACCESS_KEY_ID }}'
  26. AWS_SECRET_ACCESS_KEY: '{{ AWS_SECRET_ACCESS_KEY }}'
  27. filename: '{{ filename }}'
  28. rolename: '{{ rolename }}'
  29. project: '{{ project }}'
  30. release: '{{ release }}'
  31. envname: '{{ envname }}'
  32. processList: '{{ processList}}'
  33. roles:
  34. - httpd

下面是http的roles文件

  1. [root@ip-172-31-42-166 packer]# cat roles/httpd/tasks/main.yml
  2. - name: install the latest version of Apache
  3. yum:
  4. name: httpd
  5. state: latest

好了配置文件就这么多。

生成amazon AMI

  1. cd packer/
  2. packer build bastion.json

来看看aws的控制台,ami已经生成了

下面基于terraform来启动web server

先把配置文件放上,注意看注释

  1. [root@ip-172-31-42-166 data]# cat terraform_workspace/main.tf
  2. provider "aws" {
  3. region = "us-west-2"
  4. }
  5.  
  6. resource "aws_instance" "example" {
  7. ami = "ami-9842dbe0"
  8. instance_type = "t2.micro"
  9. vpc_security_group_ids = ["${aws_security_group.instance.id}"] #在这里我们引用了下面创建的安全组,没有顺序关系,terraform会自动生成顺序和依赖,使用terraform graph可以查看。
  10.  
  11. user_data = <<-EOF
  12. #!/bin/bash
  13. /etc/init.d/httpd start
  14. chkconfig httpd on
  15. EOF
  16.  
  17. tags {
  18. Name = "apache"
  19. }
  20. }
  21.  
  22. resource "aws_security_group" "instance" {
  23. name = "terraform-example-instance" #在这个resource里我们新建了安全组,需要在上面引用,否则无效
  24.  
  25. ingress {
  26. from_port = 80 #web线上服务器一般不开80端口,打开小于1024的端口要使用root权限,这是不安全的,一般都是前线的负载均衡器开80,然后映射到后面的高端口上。
  27. to_port = 80
  28. protocol = "tcp"
  29. cidr_blocks = ["0.0.0.0/0"]
  30. }
  31. }

我们来访问一下试试:

  1. curl http://<EC2_INSTANCE_PUBLIC_IP>:80
  2. #成功了,显示了好大一堆,不放上来了

布署可配置的web服务器

什么是可配置的呢?我感脚就是引入变量。。。。。

所以上面的配置文件也可以写成这样式的:

  1. [root@ip-172-31-42-166 terraform_workspace]# cat main.tf
  2. provider "aws" {
  3. region = "us-west-2"
  4. }
  5.  
  6. variable "server_port" {
  7. description = "define a variable server_port"
  8. default = 80
  9. }
  10.  
  11. resource "aws_instance" "example" {
  12. ami = "ami-9842dbe0"
  13. instance_type = "t2.micro"
  14. vpc_security_group_ids = ["${aws_security_group.instance.id}"]
  15.  
  16. user_data = <<-EOF
  17. #!/bin/bash
  18. /etc/init.d/httpd start
  19. chkconfig httpd on
  20. EOF
  21.  
  22. tags {
  23. Name = "apache"
  24. }
  25. }
  26.  
  27. resource "aws_security_group" "instance" {
  28. name = "terraform-example-instance"
  29.  
  30. ingress {
  31. from_port = "${var.server_port}"
  32. to_port = "${var.server_port}"
  33. protocol = "tcp"
  34. cidr_blocks = ["0.0.0.0/0"]
  35. }
  36. }

当然这变量还可以是一个列表,像这样:

  1. variable "list_example" {
  2. description = "An example of a list in Terraform"
  3. type = "list"
  4. default = [1, 2, 3]
  5. }

或者是一组映射,像这样:

  1. variable "map_example" {
  2. description = "An example of a map in Terraform"
  3. type = "map"
  4.  
  5. default = {
  6. key1 = "value1"
  7. key2 = "value2"
  8. key3 = "value3"
  9. }
  10. }

布署web服务器集群

在aws中,auto scaling group可以控制服务器的启停,实现集群操作

要创建asg的第一步就是创建启动配置,长这样的:

  1. resource "aws_launch_configuration" "example" {
  2. image_id = "ami-9842dbe0"
  3. instance_type = "t2.micro"
  4. security_groups = ["${aws_security_group.instance.id}"]
  5.  
  6. user_data = <<-EOF
  7. #!/bin/bash
  8. /etc/init.d/httpd start
  9. chkconfig httpd on
  10. EOF
  11.  
  12. lifecycle {
  13. create_before_destroy = true #在干掉一个机器之前,先启动一个机器 ,注意这里设置为true了,在安全组里也得设置成true,因为他们相互依赖的。
  14. }
  15. }

所以安全组长这样子:

  1. resource "aws_security_group" "instance" {
  2. name = "terraform-example-instance"
  3.  
  4. ingress {
  5. from_port = "${var.server_port}"
  6. to_port = "${var.server_port}"
  7. protocol = "tcp"
  8. cidr_blocks = ["0.0.0.0/0"]
  9. }
  10. lifecycle {
  11. create_before_destroy = true
  12. }
  13. }

好了,下面就可以写安全组的source了:

  1. resource "aws_autoscaling_group" "example" {
  2. launch_configuration = "${aws_launch_configuration.example.id}"

    # The same availability zone as our instances
  3. availability_zones = ["${split(",", var.availability_zones)}"]
  4.  
  5. min_size = 2
  6. max_size = 3
  7.  
  8. tag {
  9. key = "Name"
  10. value = "terraform-asg-example"
  11. propagate_at_launch = true
  12. }
  13. }

组合在一起,上个完整的配置文件:

  1. provider "aws" {
  2. region = "us-west-2"
  3. }
  4.  
  5. variable "server_port" {
  6. description = "define a variable server_port"
  7. default = 80
  8. }
  9.  
  10. variable "availability_zones" {
  11. default = "us-west-2a,us-west-2b,us-west-2c"
  12. description = "List of availability zones, use AWS CLI to find your "
  13. }
  14.  
  15. resource "aws_instance" "example" {
  16. ami = "ami-9842dbe0"
  17. instance_type = "t2.micro"
  18. vpc_security_group_ids = ["${aws_security_group.instance.id}"]
  19.  
  20. user_data = <<-EOF
  21. #!/bin/bash
  22. /etc/init.d/httpd start
  23. chkconfig httpd on
  24. EOF
  25.  
  26. tags {
  27. Name = "apache"
  28. }
  29. }
  30.  
  31. resource "aws_security_group" "instance" {
  32. name = "terraform-example-instance"
  33.  
  34. ingress {
  35. from_port = "${var.server_port}"
  36. to_port = "${var.server_port}"
  37. protocol = "tcp"
  38. cidr_blocks = ["0.0.0.0/0"]
  39. }
  40. lifecycle {
  41. create_before_destroy = true
  42. }
  43. }
  44.  
  45. resource "aws_launch_configuration" "example" {
  46. image_id = "ami-9842dbe0"
  47. instance_type = "t2.micro"
  48. security_groups = ["${aws_security_group.instance.id}"]
  49.  
  50. user_data = <<-EOF
  51. #!/bin/bash
  52. /etc/init.d/httpd start
  53. chkconfig httpd on
  54. EOF
  55.  
  56. lifecycle {
  57. create_before_destroy = true
  58. }
  59. }
  60.  
  61. resource "aws_autoscaling_group" "example" {
  62. launch_configuration = "${aws_launch_configuration.example.id}"
  63. #availability_zones = ["${data.aws_availability_zones.all.names}"]
  64. availability_zones = ["${split(",", var.availability_zones)}"]
  65.  
  66. min_size = 2
  67. max_size = 3
  68.  
  69. tag {
  70. key = "Name"
  71. value = "terraform-asg-example"
  72. propagate_at_launch = true
  73. }
  74. }

在aws控制台上可以看到,新启动了两台机器。

现在我们已经有多台webserver在工作了,我们加个负载均衡器上去玩一下麻:

布署负载均衡器

关于负载均衡器,使用aws_elb resource进行配置:

  1. resource "aws_elb" "example" {
  2. name = "terraform-asg-example"
  3. availability_zones = ["${data.aws_availability_zones.all.names}"]
  4. security_groups = ["${aws_security_group.elb.id}"]
  5.  
  6. listener {
  7. lb_port = 80
  8. lb_protocol = "http"
  9. instance_port = "${var.server_port}"
  10. instance_protocol = "http"
  11. }
  12.  
  13. health_check {
  14. healthy_threshold = 2
  15. unhealthy_threshold = 2
  16. timeout = 3
  17. interval = 30
  18. target = "HTTP:${var.server_port}/"
  19. }
  20. }

还要配置相应的安全组:

  1. resource "aws_security_group" "elb" {
  2. name = "terraform-example-elb"
  3.  
  4. ingress {
  5. from_port = 80
  6. to_port = 80
  7. protocol = "tcp"
  8. cidr_blocks = ["0.0.0.0/0"]
  9. }
  10.  
  11. egress {
  12. from_port = 0
  13. to_port = 0
  14. protocol = "-1"
  15. cidr_blocks = ["0.0.0.0/0"]
  16. }
  17. }

下面来个整体的配置文件吧,如果一个看着乱,可以拆分成多个:

  1. provider "aws" {
  2. region = "us-west-2"
  3. }
  4.  
  5. variable "server_port" {
  6. description = "define a variable server_port"
  7. default = 80
  8. }
  9.  
  10. variable "availability_zones" {
  11. default = "us-west-2a,us-west-2b,us-west-2c"
  12. description = "List of availability zones, use AWS CLI to find your "
  13. }
  14.  
  15. resource "aws_instance" "example" {
  16. ami = "ami-9842dbe0"
  17. instance_type = "t2.micro"
  18. vpc_security_group_ids = ["${aws_security_group.instance.id}"]
  19.  
  20. user_data = <<-EOF
  21. #!/bin/bash
  22. /etc/init.d/httpd start
  23. chkconfig httpd on
  24. EOF
  25.  
  26. tags {
  27. Name = "apache"
  28. }
  29. }
  30.  
  31. resource "aws_security_group" "instance" {
  32. name = "terraform-example-instance"
  33.  
  34. ingress {
  35. from_port = "${var.server_port}"
  36. to_port = "${var.server_port}"
  37. protocol = "tcp"
  38. cidr_blocks = ["0.0.0.0/0"]
  39. }
  40. lifecycle {
  41. create_before_destroy = true
  42. }
  43. }
  44.  
  45. resource "aws_security_group" "elb" {
  46. name = "terraform-example-elb"
  47.  
  48. ingress {
  49. from_port = 80
  50. to_port = 80
  51. protocol = "tcp"
  52. cidr_blocks = ["0.0.0.0/0"]
  53. }
  54.  
  55. egress {
  56. from_port = 0
  57. to_port = 0
  58. protocol = "-1"
  59. cidr_blocks = ["0.0.0.0/0"]
  60. }
  61. }
  62.  
  63. resource "aws_launch_configuration" "example" {
  64. image_id = "ami-9842dbe0"
  65. instance_type = "t2.micro"
  66. security_groups = ["${aws_security_group.instance.id}"]
  67.  
  68. user_data = <<-EOF
  69. #!/bin/bash
  70. /etc/init.d/httpd start
  71. chkconfig httpd on
  72. EOF
  73.  
  74. lifecycle {
  75. create_before_destroy = true
  76. }
  77. }
  78.  
  79. resource "aws_autoscaling_group" "example" {
  80. launch_configuration = "${aws_launch_configuration.example.id}"
  81. availability_zones = ["${split(",", var.availability_zones)}"]
  82.  
  83. load_balancers = ["${aws_elb.example.name}"]
  84. health_check_type = "ELB"
  85.  
  86. min_size = 2
  87. max_size = 3
  88.  
  89. tag {
  90. key = "Name"
  91. value = "terraform-asg-example"
  92. propagate_at_launch = true
  93. }
  94. }
  95.  
  96. resource "aws_elb" "example" {
  97. name = "terraform-asg-example"
  98. availability_zones = ["${split(",", var.availability_zones)}"]
  99. security_groups = ["${aws_security_group.elb.id}"]
  100.  
  101. listener {
  102. lb_port = 80
  103. lb_protocol = "http"
  104. instance_port = "${var.server_port}"
  105. instance_protocol = "http"
  106. }
  107.  
  108. health_check {
  109. healthy_threshold = 2
  110. unhealthy_threshold = 2
  111. timeout = 3
  112. interval = 30
  113. target = "HTTP:${var.server_port}/"
  114. }
  115. }
  116.  
  117. output "elb_dns_name" {
  118. value = "${aws_elb.example.dns_name}"
  119. }
  120. [root@ip-172-31-42-166 terraform_workspace]# ls
  121. main.tf main.tf.bak terraform.tfstate terraform.tfstate.backup
  122. [root@ip-172-31-42-166 terraform_workspace]# cat main.tf
  123. provider "aws" {
  124. region = "us-west-2"
  125. }
  126.  
  127. variable "server_port" {
  128. description = "define a variable server_port"
  129. default = 80
  130. }
  131.  
  132. variable "availability_zones" {
  133. default = "us-west-2a,us-west-2b,us-west-2c"
  134. description = "List of availability zones, use AWS CLI to find your "
  135. }
  136.  
  137. resource "aws_instance" "example" {
  138. ami = "ami-9842dbe0"
  139. instance_type = "t2.micro"
  140. vpc_security_group_ids = ["${aws_security_group.instance.id}"]
  141.  
  142. user_data = <<-EOF
  143. #!/bin/bash
  144. /etc/init.d/httpd start
  145. chkconfig httpd on
  146. EOF
  147.  
  148. tags {
  149. Name = "apache"
  150. }
  151. }
  152.  
  153. resource "aws_security_group" "instance" {
  154. name = "terraform-example-instance"
  155.  
  156. ingress {
  157. from_port = "${var.server_port}"
  158. to_port = "${var.server_port}"
  159. protocol = "tcp"
  160. cidr_blocks = ["0.0.0.0/0"]
  161. }
  162. lifecycle {
  163. create_before_destroy = true
  164. }
  165. }
  166.  
  167. resource "aws_security_group" "elb" {
  168. name = "terraform-example-elb"
  169.  
  170. ingress {
  171. from_port = 80
  172. to_port = 80
  173. protocol = "tcp"
  174. cidr_blocks = ["0.0.0.0/0"]
  175. }
  176.  
  177. egress {
  178. from_port = 0
  179. to_port = 0
  180. protocol = "-1"
  181. cidr_blocks = ["0.0.0.0/0"]
  182. }
  183. }
  184.  
  185. resource "aws_launch_configuration" "example" {
  186. image_id = "ami-9842dbe0"
  187. instance_type = "t2.micro"
  188. security_groups = ["${aws_security_group.instance.id}"]
  189.  
  190. user_data = <<-EOF
  191. #!/bin/bash
  192. /etc/init.d/httpd start
  193. chkconfig httpd on
  194. EOF
  195.  
  196. lifecycle {
  197. create_before_destroy = true
  198. }
  199. }
  200.  
  201. resource "aws_autoscaling_group" "example" {
  202. launch_configuration = "${aws_launch_configuration.example.id}"
  203. availability_zones = ["${split(",", var.availability_zones)}"]
  204.  
  205. load_balancers = ["${aws_elb.example.name}"]
  206. health_check_type = "ELB"
  207.  
  208. min_size = 2
  209. max_size = 3
  210.  
  211. tag {
  212. key = "Name"
  213. value = "terraform-asg-example"
  214. propagate_at_launch = true
  215. }
  216. }
  217.  
  218. resource "aws_elb" "example" {
  219. name = "terraform-asg-example"
  220. availability_zones = ["${split(",", var.availability_zones)}"]
  221. security_groups = ["${aws_security_group.elb.id}"]
  222.  
  223. listener {
  224. lb_port = 80
  225. lb_protocol = "http"
  226. instance_port = "${var.server_port}"
  227. instance_protocol = "http"
  228. }
  229.  
  230. health_check {
  231. healthy_threshold = 2
  232. unhealthy_threshold = 2
  233. timeout = 3
  234. interval = 30
  235. target = "HTTP:${var.server_port}/"
  236. }
  237. }
  238.  
  239. output "elb_dns_name" {
  240. value = "${aws_elb.example.dns_name}"
  241. }
  242. [root@ip-172-31-42-166 terraform_workspace]# ls
  243. main.tf main.tf.bak terraform.tfstate terraform.tfstate.backup
  244. [root@ip-172-31-42-166 terraform_workspace]# cat main.tf
  245. provider "aws" {
  246. region = "us-west-2"
  247. }
  248.  
  249. variable "server_port" {
  250. description = "define a variable server_port"
  251. default = 80
  252. }
  253.  
  254. variable "availability_zones" {
  255. default = "us-west-2a,us-west-2b,us-west-2c"
  256. description = "List of availability zones, use AWS CLI to find your "
  257. }
  258.  
  259. resource "aws_instance" "example" {
  260. ami = "ami-9842dbe0"
  261. instance_type = "t2.micro"
  262. vpc_security_group_ids = ["${aws_security_group.instance.id}"]
  263.  
  264. user_data = <<-EOF
  265. #!/bin/bash
  266. /etc/init.d/httpd start
  267. chkconfig httpd on
  268. EOF
  269.  
  270. tags {
  271. Name = "apache"
  272. }
  273. }
  274.  
  275. resource "aws_security_group" "instance" {
  276. name = "terraform-example-instance"
  277.  
  278. ingress {
  279. from_port = "${var.server_port}"
  280. to_port = "${var.server_port}"
  281. protocol = "tcp"
  282. cidr_blocks = ["0.0.0.0/0"]
  283. }
  284. lifecycle {
  285. create_before_destroy = true
  286. }
  287. }
  288.  
  289. resource "aws_security_group" "elb" {
  290. name = "terraform-example-elb"
  291.  
  292. ingress {
  293. from_port = 80
  294. to_port = 80
  295. protocol = "tcp"
  296. cidr_blocks = ["0.0.0.0/0"]
  297. }
  298.  
  299. egress {
  300. from_port = 0
  301. to_port = 0
  302. protocol = "-1"
  303. cidr_blocks = ["0.0.0.0/0"]
  304. }
  305. }
  306.  
  307. resource "aws_launch_configuration" "example" {
  308. image_id = "ami-9842dbe0"
  309. instance_type = "t2.micro"
  310. security_groups = ["${aws_security_group.instance.id}"]
  311.  
  312. user_data = <<-EOF
  313. #!/bin/bash
  314. /etc/init.d/httpd start
  315. chkconfig httpd on
  316. EOF
  317.  
  318. lifecycle {
  319. create_before_destroy = true
  320. }
  321. }
  322.  
  323. resource "aws_autoscaling_group" "example" {
  324. launch_configuration = "${aws_launch_configuration.example.id}"
  325. availability_zones = ["${split(",", var.availability_zones)}"]
  326.  
  327. load_balancers = ["${aws_elb.example.name}"]
  328. health_check_type = "ELB"
  329.  
  330. min_size = 2
  331. max_size = 3
  332.  
  333. tag {
  334. key = "Name"
  335. value = "terraform-asg-example"
  336. propagate_at_launch = true
  337. }
  338. }
  339.  
  340. resource "aws_elb" "example" {
  341. name = "terraform-asg-example"
  342. availability_zones = ["${split(",", var.availability_zones)}"]
  343. security_groups = ["${aws_security_group.elb.id}"]
  344.  
  345. listener {
  346. lb_port = 80
  347. lb_protocol = "http"
  348. instance_port = "${var.server_port}"
  349. instance_protocol = "http"
  350. }
  351.  
  352. health_check {
  353. healthy_threshold = 2
  354. unhealthy_threshold = 2
  355. timeout = 3
  356. interval = 30
  357. target = "HTTP:${var.server_port}/"
  358. }
  359. }
  360.  
  361. output "elb_dns_name" {
  362. value = "${aws_elb.example.dns_name}"
  363. }

注意:

配置完成的时候出了点问题,elb使用http方式检测webserver状态错误,但是tcp方式是可能,看下图;

它默认去找/index.html文件了,但是我装的apache路径默认不是这个,所以检测一定是失败的。

为了节省资源,我们可以把aws刚才创建的资源都干掉,只要留着配置文件随时可以烣复:

  1. terraform destroy

that`all thank you~

ansible+packer+terraform在aws上布署web服务器的更多相关文章

  1. 在公网上布署Web Api的时候,不能调用,返回404

    在internet上布署web API做的站点时,发现不能调用web api的任何action, 返回404. 经过很多的努力,也找不到原因,环境是win server 2008, IIS 75. n ...

  2. 通过Jenkins在IIS上布署站点

    当需要在多台服务器的IIS上布署站点时,如果纯粹靠人工手动完成此任务的话,过于低效,而借助Jenkins之类的自动化工具,则可以极大提升工作效率. 以下便是Jenkins Pipeline所使用的脚本 ...

  3. Windows server 2008 布署FTP服务器实例(适用于阿里云)!

    Windows server 2008 布署FTP服务器实例(适用于阿里云). 1.打开管理.配置-用户-新建用户,如:ftp_user,并设置password.选择永只是期和password不能更改 ...

  4. 在 Azure VM 上安装 LEMP Web 服务器

    本文逐步讲解如何在 Azure 中的 Ubuntu VM 上部署 NGINX Web 服务器.MySQL 和 PHP(LEMP 堆栈). LEMP 堆栈可以替代常用的 LAMP 堆栈,可安装在 Azu ...

  5. 在 Azure VM 上安装 LAMP Web 服务器

    本文逐步讲解如何在 Azure 中的 Ubuntu VM 上部署 Apache Web 服务器.MySQL 和 PHP(LAMP 堆栈). 如果想要部署 NGINX Web 服务器,请参阅 LEMP ...

  6. Jexus是一款Linux平台上的高性能WEB服务器和负载均衡网关

    什么是Jexus Jexus是一款Linux平台上的高性能WEB服务器和负载均衡网关,以支持ASP.NET.ASP.NET CORE.PHP为特色,同时具备反向代理.入侵检测等重要功能.可以这样说,J ...

  7. 如何在Ubuntu 16.04上安装Apache Web服务器

    转载自:https://www.howtoing.com/how-to-install-the-apache-web-server-on-ubuntu-16-04 介绍 Apache HTTP服务器是 ...

  8. 如何在Ubuntu 18.04上安装Apache Web服务器

    一. apt库安装 1.在终端输入更新检查命令,sudo apt-get update 2. 在更新完成后(如果不想检查更新,也可直接输入此步)输入:sudo apt-get install apac ...

  9. NodeJs+http+fs+request+cheerio 采集,保存数据,并在网页上展示(构建web服务器)

    目的: 数据采集 写入本地文件备份 构建web服务器 将文件读取到网页中进行展示 目录结构: package.json文件中的内容与上一篇一样:NodeJs+Request+Cheerio 采集数据 ...

随机推荐

  1. 学习JAVA的几大优处

    首先:简单:我们都知道Java是目前使用较为广泛的网络编程语言之一.他容易学而且很好用,如果你学习过C++语言,你会觉得C++和 Java很像,因为Java中许多基本语句的语法和C++一样,像常用的循 ...

  2. Vue解析四之注册变量

    判断监听的变量,如果undefined可以用$set来注册一个变量. 另外click可以是表达式,不一定必须是一个方法.

  3. 【Linux】 用户管理

    Linux用户管理 ■ 查看用户整体情况 cat /etc/passwd可以查看用户的一些基本信息.用finger <user>似乎更加方便 查看某一个特定的用户的话就可以 grep &l ...

  4. java排序算法(四):冒泡排序

    java排序算法(四):冒泡排序 冒泡排序是计算机的一种排序方法,它的时间复杂度是o(n^2),虽然不及堆排序.快速排序o(nlogn,底数为2).但是有两个优点 1.编程复杂度很低.很容易写出代码 ...

  5. 使用责任链模式消除if分支实践

    之前接手过一个车辆监控的工具,接受第三方推送过来的车辆状态数据然后入库.车辆状态一共有8种之多,每种状态都需要做不同 处理操作.刚接手这份代码时,针对此处处理,是庞大的if-else结构,if-els ...

  6. SQL中的DML、DDL以及DCL

    DML(data manipulation language)是数据操纵语言:它们是SELECT.UPDATE.INSERT.DELETE,就象它的名字一样,这4条命令是用来对数据库里的数据进行操作的 ...

  7. JavaScript(第三十一天)【JSON】

    前两章我们探讨了XML的结构化数据,但开发人员还是觉得这种微型的数据结构还是过于烦琐.冗长.为了解决这个问题,JSON的结构化数据出现了.JSON是JavaScript的一个严格的子集,利用JavaS ...

  8. JavaScript(第三十天)【XPath】

    XPath是一种节点查找手段,对比之前使用标准DOM去查找XML中的节点方式,大大降低了查找难度,方便开发者使用.但是,DOM3级以前的标准并没有就XPath做出规范:直到DOM3在首次推荐到标准规范 ...

  9. beta冲刺7-咸鱼

    前言:最后一篇惹.明天就是正式交差了.有点慌-- 昨天的未完成: 用户试用+测评 输入部分的正则式判定 今天的工作: 登陆界面修改 我的社团显示效果优化 部分信息注册后锁定无法修改 其他部分功能优化 ...

  10. 项目Alpha冲刺Day1

    一.会议照片 二.项目进展 1.今日安排 讨论完成项目的详细设计,并完成数据库的设计,学习powerDesigner的使用 2.问题困难 powerDesigner导出sql语句因为问题无法导入,特别 ...