永字八法

host ip获取rds的ip
sudo yum -y install mariadb
mysql --version
mysql -h ip -u admin -p
show databases; 
====
sudo yum repolist
sudo yum -y update
sudo yum -y install httpd php mariadb php-mysql 
sudo sed -i 's/Listen 80/Listen 8001/' /etc/httpd/conf/httpd.conf
cat /etc/httpd/conf/httpd.conf
sudo id ec2-user
sudo tail /etc/group
[ec2-user@ip-172-17-0-211 ~]$ sudo usermod -a -G apache ec2-user
[ec2-user@ip-172-17-0-211 ~]$ sudo tail /etc/group
[ec2-user@ip-172-17-0-211 ~]$ sudo id ec2-user
[ec2-user@ip-172-17-0-211 ~]$ sudo chown -R ec2-user:apache /var/www
[ec2-user@ip-172-17-0-211 ~]$ ll /var/www
total 0
drwxr-xr-x 2 ec2-user apache 6 Dec 30 21:40 cgi-bin
drwxr-xr-x 2 ec2-user apache 6 Dec 30 21:40 html
wget https://tomtrain.s3.cn-northwest-1.amazonaws.com.cn/bookstore2.zip
[ec2-user@ip-172-17-0-211 ~]$ unzip bookstore2.zip
Archive:  bookstore2.zip
   creating: test/
  inflating: test/books.sql
   creating: test/css/
  inflating: test/css/base.css
   creating: test/efsimags/
  inflating: test/efsimags/2.jpg
   creating: test/img/
  inflating: test/img/1.png
  inflating: test/index.php
[ec2-user@ip-172-17-0-211 ~]$ cp -r test/* /var/www/html/
[ec2-user@ip-172-17-0-211 ~]$ sudo systemctl start httpd
[ec2-user@ip-172-17-0-211 ~]$ sudo systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[ec2-user@ip-172-17-0-211 ~]$ sudo systemctl status httpd
● httpd.service - The Apache HTTP Server
   Loaded: loaded (/usr/lib/systemd/system/httpd.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2022-03-20 07:11:11 UTC; 1min 6s ago
     Docs: man:httpd.service(8)
 Main PID: 829 (httpd)
   Status: "Total requests: 0; Idle/Busy workers 100/0;Requests/sec: 0; Bytes served/sec:   0 B/sec"
   CGroup: /system.slice/httpd.service
           ├─829 /usr/sbin/httpd -DFOREGROUND
           ├─830 /usr/sbin/httpd -DFOREGROUND
           ├─831 /usr/sbin/httpd -DFOREGROUND
           ├─832 /usr/sbin/httpd -DFOREGROUND
           ├─833 /usr/sbin/httpd -DFOREGROUND
           └─834 /usr/sbin/httpd -DFOREGROUND
Mar 20 07:11:10 ip-172-17-0-211.cn-northwest-1.compute.internal systemd[1]: S...
Mar 20 07:11:11 ip-172-17-0-211.cn-northwest-1.compute.internal systemd[1]: S...
Hint: Some lines were ellipsized, use -l to show in full.
[ec2-user@ip-172-17-0-211 ~]$ ss -l -t -n
State    Recv-Q   Send-Q     Local Address:Port     Peer Address:Port  Process
LISTEN   0        128              0.0.0.0:111           0.0.0.0:*
LISTEN   0        128              0.0.0.0:22            0.0.0.0:*
LISTEN   0        100            127.0.0.1:25            0.0.0.0:*
LISTEN   0        128                 [::]:111              [::]:*
LISTEN   0        128                 [::]:22               [::]:*
LISTEN   0        511                    *:8001                *:*
[ec2-user@ip-172-17-0-211 ~]$ curl localhost:8001
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>测试页面</title>
    <link type="text/css" rel="stylesheet" href="./css/base.css"/>
</head>
<body>
Hostname:
ip-172-17-0-211.cn-northwest-1.compute.internal</p>
<img src="./img/1.png"/>
<img src="./efsimags/2.jpg"/>
<table>
    <tr><th>序号</th><th>书名</th><th>作者</th><th>定价</th></tr>
    </table>
</body>
</html>
安全组app添加入站规则tcp8001
[ec2-user@ip-172-17-0-211 ~]$ mysql -h 172.17.4.8 -u admin -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MySQL connection id is 57
Server version: 5.7.37-log Source distribution
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [(none)]>
MySQL [(none)]> create database bookstore;
Query OK, 1 row affected (0.01 sec)
MySQL [(none)]> use bookstore;
Database changed
MySQL [bookstore]>
MySQL [bookstore]> DROP TABLE IF EXISTS `books`;
Query OK, 0 rows affected, 1 warning (0.01 sec)
MySQL [bookstore]> CREATE TABLE `books` (
    ->   `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
    ->   `name` varchar(255) NOT NULL,
    ->   `price` decimal(10,2) NOT NULL,
    ->   `author` varchar(100) NOT NULL,
    ->   PRIMARY KEY (`id`)
    -> ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4;
Query OK, 0 rows affected (0.05 sec)
MySQL [bookstore]> BEGIN;
Query OK, 0 rows affected (0.00 sec)
MySQL [bookstore]> INSERT INTO `books` VALUES (1, 'PHP项目实践', 56.00, '明');
Query OK, 1 row affected (0.00 sec)
MySQL [bookstore]> INSERT INTO `books` VALUES (2, 'Java基础', 88.00, '强');
Query OK, 1 row affected (0.00 sec)
MySQL [bookstore]> INSERT INTO `books` VALUES (3, 'Python数据分析', 66.00, '飞');
Query OK, 1 row affected (0.00 sec)
MySQL [bookstore]> COMMIT;
Query OK, 0 rows affected (0.01 sec)
MySQL [bookstore]>
MySQL [bookstore]> SET FOREIGN_KEY_CHECKS = 1;
Query OK, 0 rows affected (0.00 sec)
MySQL [bookstore]> select * from books;
+----+--------------------+-------+--------+
| id | name               | price | author |
+----+--------------------+-------+--------+
|  1 | PHP项目实践        | 56.00 | 明     |
|  2 | Java基础           | 88.00 | 强     |
|  3 | Python数据分析     | 66.00 | 飞     |
+----+--------------------+-------+--------+
3 rows in set (0.00 sec)
[ec2-user@ip-172-17-0-211 ~]$ vim /var/www/html/index.php
<?php
define('HOST','172.17.4.8');
define('USER','admin');
define('PASS','12345678');
define('DBNAME','bookstore');
[ec2-user@ip-172-17-0-211 ~]$ sudo systemctl restart httpd
[ec2-user@ip-172-17-0-211 ~]$ curl localhost:8001
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>测试页面</title>
    <link type="text/css" rel="stylesheet" href="./css/base.css"/>
</head>
<body>
Hostname:
ip-172-17-0-211.cn-northwest-1.compute.internal</p>
<img src="./img/1.png"/>
<img src="./efsimags/2.jpg"/>
<table>
    <tr><th>序号</th><th>书名</th><th>作者</th><th>定价</th></tr>
    <tr><td>1</td><td>PHP项目实践</td><td>明</td><td>56.00</td></tr><tr><td>2</td><td>Java基础</td><td>强</td><td>88.00</td></tr><tr><td>3</td><td>Python数据分析</td><td>飞</td><td>66.00</td></tr></table>
</body>
</html>
[ec2-user@ip-172-17-0-211 ~]$
===
MySQL [bookstore]> source /var/www/html/books.sql
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 0 rows affected, 1 warning (0.01 sec)
Query OK, 0 rows affected (0.02 sec)
Query OK, 0 rows affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 1 row affected (0.00 sec)
Query OK, 0 rows affected (0.01 sec)
Query OK, 0 rows affected (0.00 sec)
MySQL [bookstore]> select * from books;
+----+--------------------+-------+--------+
| id | name               | price | author |
+----+--------------------+-------+--------+
|  1 | PHP项目实践        | 56.00 | 明     |
|  2 | Java基础           | 88.00 | 强     |
|  3 | Python数据分析     | 66.00 | 飞     |
+----+--------------------+-------+--------+
3 rows in set (0.00 sec)

 只做到单点部署,未完待续…

posted @ 2022-04-29 08:55  rootoor  阅读(107)  评论(0)    收藏  举报