이제 aws를 시작할 때가 되지 않았나 #2 ~ CodeStar 코드를 Deploy로 수정~

17275 단어 PHPLaravelAWS

입문


aws를 시작할 시간이 얼마 안 남았죠~ 일단 터치를 해봤어요~에서 소개한 것처럼 aws의 바다에서 발버둥치고 있다(웃음)
CodeStar 환경이 준비되었으니 코드를 편집하고Commit를 시도하여 Deploy로 스트리밍할 수 있는지 확인하십시오.
그 다음에 DB의migrate를 해보고 싶어요.
결과적으로 보면
- 코드Commit에서 배포까지 가능
- DB migrate는 NG에요.
모범 사례를 찾습니다.

코드 편집에서 배치까지


Cloud9(IDE)을 사용하여 코드를 수정하고 Git Commit를 수행하여 Deploy까지의 프로세스를 확인했습니다.
CodeStar에서 항목을 선택하고 Cloud9을 시작합니다.
이따가 Git에서 밀어서 확인해 볼게요.
이번에는 WelcomePage의 제목을 간단히 수정합니다.
수정이라지만 "!!!"그냥 뒤에서 (웃음)

AWS에 대한 Git Commit
ec2-user:~/environment $ cd php-laravel/
ec2-user:~/environment/php-laravel (master) $ git add .
ec2-user:~/environment/php-laravel (master) $ git commit -m 'change Title'
[master 42bc467] change Title
 Committer: EC2 Default User <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 1 insertion(+), 1 deletion(-)
ec2-user:~/environment/php-laravel (master) $ git push origin master
Counting objects: 5, done.
Compressing objects: 100% (5/5), done.
Writing objects: 100% (5/5), 435 bytes | 435.00 KiB/s, done.
Total 5 (delta 4), reused 0 (delta 0)
To https://git-codecommit.us-east-2.amazonaws.com/v1/repos/php-laravel
   a0c0157..42bc467  master -> master
ec2-user:~/environment/php-laravel (master) $ 
이렇게 되면 파이프라인 화면에서 Deploy로 무단으로 뛰어가는 모습을 확인할 수 있습니다.

실제 응용 프로그램을 보려면 CodeStar 대시보드에서 응용 프로그램 끝점을 클릭합니다.

못생겼지만 제목이 바뀌었어요(웃음)

이렇게 개발한 거 아는데...
지난번에 생산 환경과 현지 환경의 편차를 확인했기 때문에 어떻게 실제적으로 사용합니까
상상도 못했어요 (^^;

데이터베이스 연결


환경 확인


CodeStar에서 프로젝트를 작성하면 실행할 인스턴스와 Cloud9(IDE)의 인스턴스가 생성됩니다.
관심 있는 것은 실행의 실례 측면이기 때문에 EC2 대시보드 화면에서 TeraTerm으로 실례'php-laravel-WebApp'의'공용 DNS(IPv4)'에 연결합니다.
※ 참고로 지난 보도에서 항목명은'laravel'이었지만 몇 차례 삭제에 실패하여'php-laravel'로 변경되었습니다.
관련 자원이 사라지지 않아 난처합니다. (웃음소리)

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
[ec2-user@ip-172-31-29-127 ~]$ cd /var/www/phplaravel/
[ec2-user@ip-172-31-29-127 phplaravel]$ ls
app        composer.json  database     package.json  resources   storage
artisan    composer.lock  gulpfile.js  phpunit.xml   routes      tests
bootstrap  config         index.php    public        server.php  vendor
[ec2-user@ip-172-31-29-127 phplaravel]$ php artisan migrate


  [Illuminate\Database\QueryException]
  could not find driver (SQL: select * from information_schema.tables where t
  able_schema = homestead and table_name = migrations)



  [PDOException]
  could not find driver

음...could not find driver

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
[ec2-user@ip-172-31-29-127 ~]$ cd /var/www/phplaravel/
[ec2-user@ip-172-31-29-127 phplaravel]$ ls -alF
total 220
drwxr-xr-x 12 ec2-user ec2-user   4096 Feb  9 00:01 ./
drwxr-xr-x  8 root     root       4096 Feb  8 19:11 ../
drwxr-xr-x  6 ec2-user ec2-user   4096 Feb  9 00:01 app/
-rw-r--r--  1 ec2-user ec2-user   1646 Feb  9 00:01 artisan
drwxr-xr-x  3 ec2-user ec2-user   4096 Feb  9 00:01 bootstrap/
-rw-r--r--  1 ec2-user ec2-user   1283 Feb  9 00:01 composer.json
-rw-r--r--  1 ec2-user ec2-user 130327 Feb  9 00:00 composer.lock
drwxr-xr-x  2 ec2-user ec2-user   4096 Feb  9 00:01 config/
drwxr-xr-x  5 ec2-user ec2-user   4096 Feb  9 00:01 database/
-rw-r--r--  1 ec2-user ec2-user    543 Feb  9 00:01 .env
-rw-r--r--  1 ec2-user ec2-user    543 Feb  9 00:00 .env.example
-rw-r--r--  1 ec2-user ec2-user     61 Feb  9 00:01 .gitattributes
-rw-r--r--  1 ec2-user ec2-user     80 Feb  9 00:01 .gitignore
-rw-r--r--  1 ec2-user ec2-user    558 Feb  9 00:01 gulpfile.js
-rw-r--r--  1 ec2-user ec2-user   1776 Feb  9 00:01 index.php
-rw-r--r--  1 ec2-user ec2-user    390 Feb  9 00:00 package.json
-rw-r--r--  1 ec2-user ec2-user    930 Feb  9 00:01 phpunit.xml
drwxr-xr-x  5 ec2-user ec2-user   4096 Feb  9 00:01 public/
drwxr-xr-x  5 ec2-user ec2-user   4096 Feb  9 00:01 resources/
drwxr-xr-x  2 ec2-user ec2-user   4096 Feb  9 00:01 routes/
-rw-r--r--  1 ec2-user ec2-user    563 Feb  9 00:01 server.php
drwxrwxr-x  5 ec2-user apache     4096 Feb  9 00:01 storage/
drwxr-xr-x  2 ec2-user ec2-user   4096 Feb  9 00:01 tests/
drwxr-xr-x 32 ec2-user ec2-user   4096 Feb  9 00:01 vendor/
[ec2-user@ip-172-31-29-127 phplaravel]$ more .env
APP_ENV=local
APP_KEY=base64:CHANGEMECHANGEMECHANGEMECHANGEMECHANGEMECHA=
APP_DEBUG=false
APP_LOG_LEVEL=error
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=
[ec2-user@ip-172-31-29-127 phplaravel]$
".env"를 들여다보면 로컬 호스트의 "mysql"라고 쓰여 있습니다.
근데 mysql가 안 들어와서...

       __|  __|_  )
       _|  (     /   Amazon Linux AMI
      ___|\___|___|

https://aws.amazon.com/amazon-linux-ami/2018.03-release-notes/
[ec2-user@ip-172-31-29-127 ~]$ rpm -qa | grep mysql
[ec2-user@ip-172-31-29-127 ~]$ 

추가 설치


없으면 설치만 할 수 있기 때문에 먼저 PDO의 mysql를 설치했습니다.
$ sudo yum install -y php73-mysqlnd그래서 PDO의 예외가 바뀌었어요.[PDOException]
SQLSTATE[HY000] [2002] Connection refused
DB_DATABASE、DB_USERNAME、DB_PASSWORD가 다르기 때문에 정답입니다(웃음).
[ec2-user@ip-172-31-29-127 phplaravel]$ sudo yum list *mysql*
Loaded plugins: priorities, update-motd, upgrade-helper
Available Packages
MySQL-python26.x86_64                          1.2.3-11.14.amzn1    amzn-main
MySQL-python27.x86_64                          1.2.3-11.14.amzn1    amzn-main
apr-util-mysql.x86_64                          1.5.4-6.18.amzn1     amzn-main
collectd-mysql.x86_64                          5.8.0-2.19.amzn1     amzn-main
dovecot-mysql.x86_64                           1:2.2.10-5.17.amzn1  amzn-main
exim-mysql.x86_64                              4.92-1.25.amzn1      amzn-updates
freeradius-mysql.x86_64                        2.2.6-7.16.amzn1     amzn-main
libdbi-dbd-mysql.x86_64                        0.8.3-5.1.5.amzn1    amzn-main
lighttpd-mod_authn_mysql.x86_64                1.4.53-1.36.amzn1    amzn-updates
lighttpd-mod_mysql_vhost.x86_64                1.4.53-1.36.amzn1    amzn-updates
mod_auth_mysql.x86_64                          1:3.0.0-18.10.amzn1  amzn-main
mysql.noarch                                   5.5-1.6.amzn1        amzn-main
mysql-bench.noarch                             5.5-1.6.amzn1        amzn-main
mysql-common.noarch                            5.5-1.6.amzn1        amzn-main
mysql-config.x86_64                            5.5.62-1.23.amzn1    amzn-updates
mysql-connector-java.noarch                    1:5.1.12-2.10.amzn1  amzn-main
mysql-connector-odbc.x86_64                    5.1.11-1.12.amzn1    amzn-main
mysql-devel.noarch                             5.5-1.6.amzn1        amzn-main
mysql-embedded.noarch                          5.5-1.6.amzn1        amzn-main
mysql-embedded-devel.noarch                    5.5-1.6.amzn1        amzn-main
mysql-libs.noarch                              5.5-1.6.amzn1        amzn-main
mysql-server.noarch                            5.5-1.6.amzn1        amzn-main
mysql-test.noarch                              5.5-1.6.amzn1        amzn-main
mysql51.x86_64                                 5.1.73-8.72.amzn1    amzn-main
mysql51-bench.x86_64                           5.1.73-8.72.amzn1    amzn-main
mysql51-common.x86_64                          5.1.73-8.72.amzn1    amzn-main
mysql51-devel.x86_64                           5.1.73-8.72.amzn1    amzn-main
mysql51-embedded.x86_64                        5.1.73-8.72.amzn1    amzn-main
mysql51-embedded-devel.x86_64                  5.1.73-8.72.amzn1    amzn-main
mysql51-libs.i686                              5.1.73-8.72.amzn1    amzn-main
mysql51-libs.x86_64                            5.1.73-8.72.amzn1    amzn-main
mysql51-server.x86_64                          5.1.73-8.72.amzn1    amzn-main
mysql51-test.x86_64                            5.1.73-8.72.amzn1    amzn-main
mysql55.x86_64                                 5.5.62-1.23.amzn1    amzn-updates
mysql55-bench.x86_64                           5.5.62-1.23.amzn1    amzn-updates
mysql55-devel.x86_64                           5.5.62-1.23.amzn1    amzn-updates
mysql55-embedded.x86_64                        5.5.62-1.23.amzn1    amzn-updates
mysql55-embedded-devel.x86_64                  5.5.62-1.23.amzn1    amzn-updates
mysql55-libs.i686                              5.5.62-1.23.amzn1    amzn-updates
mysql55-libs.x86_64                            5.5.62-1.23.amzn1    amzn-updates
mysql55-server.x86_64                          5.5.62-1.23.amzn1    amzn-updates
mysql55-test.x86_64                            5.5.62-1.23.amzn1    amzn-updates
mysql56.x86_64                                 5.6.46-1.35.amzn1    amzn-updates
mysql56-bench.x86_64                           5.6.46-1.35.amzn1    amzn-updates
mysql56-common.i686                            5.6.46-1.35.amzn1    amzn-updates
mysql56-common.x86_64                          5.6.46-1.35.amzn1    amzn-updates
mysql56-devel.x86_64                           5.6.46-1.35.amzn1    amzn-updates
mysql56-embedded.x86_64                        5.6.46-1.35.amzn1    amzn-updates
mysql56-embedded-devel.x86_64                  5.6.46-1.35.amzn1    amzn-updates
mysql56-errmsg.x86_64                          5.6.46-1.35.amzn1    amzn-updates
mysql56-libs.i686                              5.6.46-1.35.amzn1    amzn-updates
mysql56-libs.x86_64                            5.6.46-1.35.amzn1    amzn-updates
mysql56-server.x86_64                          5.6.46-1.35.amzn1    amzn-updates
mysql56-test.x86_64                            5.6.46-1.35.amzn1    amzn-updates
mysql57.x86_64                                 5.7.28-1.14.amzn1    amzn-updates
mysql57-common.i686                            5.7.28-1.14.amzn1    amzn-updates
mysql57-common.x86_64                          5.7.28-1.14.amzn1    amzn-updates
mysql57-devel.x86_64                           5.7.28-1.14.amzn1    amzn-updates
mysql57-embedded.x86_64                        5.7.28-1.14.amzn1    amzn-updates
mysql57-embedded-devel.x86_64                  5.7.28-1.14.amzn1    amzn-updates
mysql57-errmsg.x86_64                          5.7.28-1.14.amzn1    amzn-updates
mysql57-libs.i686                              5.7.28-1.14.amzn1    amzn-updates
mysql57-libs.x86_64                            5.7.28-1.14.amzn1    amzn-updates
mysql57-server.x86_64                          5.7.28-1.14.amzn1    amzn-updates
mysql57-test.x86_64                            5.7.28-1.14.amzn1    amzn-updates
nagios-plugins-mysql.x86_64                    1.4.16-5.8.amzn1     amzn-main
perl-DBD-MySQL.x86_64                          4.023-5.17.amzn1     amzn-main
perl-DBD-MySQL55.x86_64                        4.023-5.23.amzn1     amzn-main
perl-DBD-MySQL56.x86_64                        4.023-5.21.amzn1     amzn-main
perl-DateTime-Format-MySQL.noarch              0.04-18.2.amzn1      amzn-main
perl-Time-Piece-MySQL.noarch                   0.05-20.2.amzn1      amzn-main
php-ZendFramework-Db-Adapter-Mysqli.noarch     1.12.20-1.12.amzn1   amzn-main
php-ZendFramework-Db-Adapter-Pdo-Mysql.noarch  1.12.20-1.12.amzn1   amzn-main
php-mysql.x86_64                               5.3.29-1.8.amzn1     amzn-main
php-mysqlnd.x86_64                             5.3.29-1.8.amzn1     amzn-main
php54-mysql.x86_64                             5.4.45-1.75.amzn1    amzn-main
php54-mysqlnd.x86_64                           5.4.45-1.75.amzn1    amzn-main
php55-mysqlnd.x86_64                           5.5.38-2.119.amzn1   amzn-main
php56-mysqlnd.x86_64                           5.6.40-1.143.amzn1   amzn-updates
php70-mysqlnd.x86_64                           7.0.33-1.32.amzn1    amzn-updates
php71-mysqlnd.x86_64                           7.1.33-1.43.amzn1    amzn-updates
php72-mysqlnd.x86_64                           7.2.26-1.19.amzn1    amzn-updates
php73-mysqlnd.x86_64                           7.3.13-1.22.amzn1    amzn-updates
rsyslog-mysql.x86_64                           5.8.10-9.26.amzn1    amzn-main
ruby-mysql.x86_64                              2.8.2-1.11.amzn1     amzn-main

[ec2-user@ip-172-31-29-127 phplaravel]$ sudo yum install -y php73-mysqlnd
Loaded plugins: priorities, update-motd, upgrade-helper
Resolving Dependencies
--> Running transaction check
---> Package php73-mysqlnd.x86_64 0:7.3.13-1.22.amzn1 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package            Arch        Version                 Repository         Size
================================================================================
Installing:
 php73-mysqlnd      x86_64      7.3.13-1.22.amzn1       amzn-updates      336 k

Transaction Summary
================================================================================
Install  1 Package

Total download size: 336 k
Installed size: 812 k
Downloading packages:
php73-mysqlnd-7.3.13-1.22.amzn1.x86_64.rpm                 | 336 kB   00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Installing : php73-mysqlnd-7.3.13-1.22.amzn1.x86_64                       1/1
  Verifying  : php73-mysqlnd-7.3.13-1.22.amzn1.x86_64                       1/1

Installed:
  php73-mysqlnd.x86_64 0:7.3.13-1.22.amzn1

Complete!

[ec2-user@ip-172-31-29-127 phplaravel]$ php artisan migrate


  [Illuminate\Database\QueryException]
  SQLSTATE[HY000] [2002] Connection refused (SQL: select * from information_s
  chema.tables where table_schema = homestead and table_name = migrations)



  [PDOException]
  SQLSTATE[HY000] [2002] Connection refused


[ec2-user@ip-172-31-29-127 phplaravel]$
RDS(DB 서버)와 연결할 준비가 되어 있어서 다시 포착하기 시작했어요(웃음)

좋은 웹페이지 즐겨찾기