0%

服务器安装笔记

2017年7月16日 下午4:01

效率 = 效率的如何评估+好的休息 + 事先安排+随机应变

数据库远程链接失败

1
2
3
localhost:.ssh czh$ mysql -h 18.89.199.142 -u root -p
Enter password:
ERROR 2003 (HY000): Can't connect to MySQL server on '18.89.199.142' (60)

链接服务器配置数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44

localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Sun Jun 4 19:14:42 2017 from 221.205.188.117
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/mysql/my.cnf
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/mysql/my.cnf
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/mysql/my.cnf
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/mysql/conf.d
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/mysql/mysql.conf.d
ubuntu@VM-219-69-ubuntu:~$ cd /etc
ubuntu@VM-219-69-ubuntu:/etc$ cd mysql
ubuntu@VM-219-69-ubuntu:/etc/mysql$ ls
conf.d debian.cnf my.cnf.fallback mysql.conf.d
debian-start my.cnf mysql.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/mysql.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/conf.d
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/my.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/my.cnf.fallback
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/debian.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql$ sudo vim /etc/mysql/my.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql$ cd /etc/mysql/conf.d/
ubuntu@VM-219-69-ubuntu:/etc/mysql/conf.d$ ls
mysql.cnf mysqldump.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/conf.d$ sudo vim /etc/mysql/mysql.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/conf.d$ sudo vim mysql.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/conf.d$ sudo vim mysqldump.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/conf.d$ cd ..
ubuntu@VM-219-69-ubuntu:/etc/mysql$ cd mysql.conf.d
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ ls
mysqld.cnf mysqld_safe_syslog.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ cd mysqld.cnf
-bash: cd: mysqld.cnf: Not a directory
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ sudo vim mysqld.cnf
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ sudo restart mysql
sudo: restart: command not found
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ sudo /etc/init.d/mysql restart
[ ok ] Restarting mysql (via systemctl): mysql.service.
ubuntu@VM-219-69-ubuntu:/etc/mysql/mysql.conf.d$ exit;
logout

远程链接数据库失败

1
2
3
4
Connection to 118.89.199.142 closed.
localhost:.ssh czh$ mysql -h 118.89.199.142 -u root -p
Enter password:
ERROR 1130 (HY000): Host '221.205.188.117' is not allowed to connect to this MySQL server

连接服务器进入数据库

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Sun Jun 4 19:29:11 2017 from 221.205.188.117


ubuntu@VM-219-69-ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.00 sec)

mysql> exi;t
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'exi' at line 1
->
-> exit;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 't

exit' at line 1
mysql> exit;
Bye

ubuntu@VM-219-69-ubuntu:~$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 6
Server version: 5.7.18-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2017, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '012468czh.' WITH GRANT OPTION
-> ;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '012468czh' WITH GRANT OPTION;
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
mysql> set global validate_password_policy=0;
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY '012468czh.' WITH GRANT OPTION;
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> exit;
Bye
ubuntu@VM-219-69-ubuntu:~$ exit;
logout

远程连接数据库失败

1
2
3
4
Connection to 118.89.199.142 closed.
localhost:.ssh czh$ mysql -h 118.89.199.142 -u root -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'221.205.188.117' (using password: YES)

连接数据库成功

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125


mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| sys |
+--------------------+
4 rows in set (0.05 sec)

mysql> create database report;
Query OK, 1 row affected (0.04 sec)

mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| report |
| sys |
+--------------------+
5 rows in set (0.03 sec)

mysql> use report;
Database changed
mysql> source /Users/czh/Downloads/report.sql ;
Query OK, 0 rows affected (0.04 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.04 sec)

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.04 sec)

Query OK, 0 rows affected (0.07 sec)

Query OK, 7 rows affected (0.04 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.07 sec)

Query OK, 7 rows affected (0.03 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.04 sec)

Query OK, 0 rows affected (0.07 sec)

Query OK, 10 rows affected (0.04 sec)
Records: 10 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.05 sec)

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.06 sec)

Query OK, 1 row affected (0.04 sec)

Query OK, 0 rows affected (0.05 sec)

Query OK, 7 rows affected (0.03 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.11 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.07 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.09 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.08 sec)
Records: 0 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.06 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 10 rows affected (0.05 sec)
Records: 10 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.06 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 1 row affected (0.05 sec)
Records: 1 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 7 rows affected (0.05 sec)
Records: 7 Duplicates: 0 Warnings: 0

Query OK, 0 rows affected (0.03 sec)

Query OK, 0 rows affected (0.04 sec)

Query OK, 0 rows affected (0.04 sec)

mysql>

——————————————————

登陆服务器配置项目

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Last login: Mon Jun  5 13:23:16 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ cd /var/www/html
ubuntu@VM-219-69-ubuntu:/var/www/html$ ls
index.nginx-debian.html info.php report
ubuntu@VM-219-69-ubuntu:/var/www/html$ chmod 777 report
ubuntu@VM-219-69-ubuntu:/var/www/html$ cd report
ubuntu@VM-219-69-ubuntu:/var/www/html/report$ ls
Application README.md Untitled-1.html index.php
Public ThinkPHP composer.json target.xls
ubuntu@VM-219-69-ubuntu:/var/www/html/report$ cd Application
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ ls
Admin Common Home README.md Runtime index.html
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ cd Runtime
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application/Runtime$ cd..
cd..: command not found
##
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application/Runtime$ cd ..
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ sudo rm Runtime
rm: cannot remove 'Runtime': Is a directory
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ sudo rm -r Runtime
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ ls
Admin Common Home README.md index.html
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ ls
Admin Common Home README.md index.html
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ ls
Admin Common Home README.md index.html
ubuntu@VM-219-69-ubuntu:/var/www/html/report/Application$ cd ..
ubuntu@VM-219-69-ubuntu:/var/www/html/report$ chmod 777 Application
ubuntu@VM-219-69-ubuntu:/var/www/html/report$ exit;
logout
Connection to 118.89.199.142 closed.

连接服务器配置nigix

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 13:45:00 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/nginx/sites-available/default
ubuntu@VM-219-69-ubuntu:~$ cd /etc/nginx/sites-available/
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-available$ ls
default
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-available$ exit;
logout
Connection to 118.89.199.142 closed.

远程下载

1
2
3
4
5
6
localhost:.ssh czh$ scp ubuntu@118.89.199.142:/etc/nginx/sites-available/default/Users/czh/Desktop/
usage: scp [-12346BCpqrv] [-c cipher] [-F ssh_config] [-i identity_file]
[-l limit] [-o ssh_option] [-P port] [-S program]
[[user@]host1:]file1 ... [[user@]host2:]file2
localhost:.ssh czh$ scp ubuntu@118.89.199.142:/etc/nginx/sites-available/default /Users/czh/Desktop/
default 100% 2092 57.5KB/s 00:00

登陆服务器配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 16:46:55 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ cd /etc/nginx/sites-available/
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-available$ sudo rm default
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-available$ ls
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-available$ exit;
logout
Connection to 118.89.199.142 closed.

上传文件到服务器

1
2
3
4
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available/
scp: /etc/nginx/sites-available//default: Permission denied
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
scp: /etc/nginx/sites-available/default: Permission denied

连接服务器进行配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 16:56:37 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo chmod 777 /etc/nginx/sites-available
ubuntu@VM-219-69-ubuntu:~$ exit;
logout
Connection to 118.89.199.142 closed.
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
default 100% 1292 35.1KB/s 00:00

登陆服务器重启nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com


server {
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 17:02:15 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo systemctl reload nginx
ubuntu@VM-219-69-ubuntu:~$ exit;
logout
Connection to 118.89.199.142 closed.

上传文件到服务器

1
2
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
default 100% 1287 27.9KB/s 00:00

登陆服务器进行nginx配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 17:03:27 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ubuntu@VM-219-69-ubuntu:~$ sudo systemctl reload nginx
ubuntu@VM-219-69-ubuntu:~$ sudo vim /etc/nginx/sites-available/default
ubuntu@VM-219-69-ubuntu:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ubuntu@VM-219-69-ubuntu:~$ sudo systemctl reload nginx
ubuntu@VM-219-69-ubuntu:~$ exit;
logout
Connection to 118.89.199.142 closed.

上传文件到服务器

1
2
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
default 100% 2092 56.6KB/s 00:00

连接服务器配置nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 17:08:04 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
ubuntu@VM-219-69-ubuntu:~$ sudo systemctl reload nginx
ubuntu@VM-219-69-ubuntu:~$ exit;
logout
Connection to 118.89.199.142 closed.

上传文件到服务器

1
2
localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
default 100% 984 18.9KB/s 00:00

连接服务器配置nginx

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 17:14:25 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$ sudo nginx -t
nginx: [emerg] unknown directive "..." in /etc/nginx/sites-enabled/default:3
nginx: configuration file /etc/nginx/nginx.conf test failed
ubuntu@VM-219-69-ubuntu:~$ cd /etc/nginx/sites-enabled/
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-enabled$ ls
default
ubuntu@VM-219-69-ubuntu:/etc/nginx/sites-enabled$ exit;
logout
Connection to 118.89.199.142 closed.

上传文件并配置nginx

1
2
3
4
5
6
7
8
9
10
11
12

localhost:.ssh czh$ scp /Users/czh/Desktop/default ubuntu@118.89.199.142:/etc/nginx/sites-available
default 100% 1324 34.6KB/s 00:00
localhost:.ssh czh$ ssh -i shanghai ubuntu@118.89.199.142
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-53-generic x86_64)

* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage

Last login: Mon Jun 5 17:18:00 2017 from 221.205.47.210
ubuntu@VM-219-69-ubuntu:~$g