openshift4.3에서 laravel+MariaDB하기

소개



마지막까지 기본적인 Laravel을 작동시킬 수 있었지만
역시 DB 없으면 이야기가 되지 않습니다.

그래서 마지막 환경에 MariaDB를 추가합니다!

마지막 이야기는 여기
openshift4.3에서 laravel

전제
 - CODEREADY CONTAINERS 1.6이 기동되고 있는 것
 - PHP 프로젝트에서 Laravel이 제대로 작동하고 있음

MariaDB 추가



Project에 MariaDB를 추가하겠습니다.
+Add에서 From Catalog를 선택하고 필터에서 MariaDB를 입력합니다.





MariaDB를 선택하면 지시에 따라 계정 정보와 DB 정보를 입력합니다.
입력이 끝나면 "Create"합니다.





여기의 Database Service Name이 소위 DBHostName입니다.



여기까지 오면 Topology 화면으로 돌아갑니다.
그러면 PHP 옆에 마리아DB의 Contener가 진좌하고 있습니다 (웃음)
Build가 끝나고 진한 파란색이 될 때까지 기다립니다.





Laravel과 MariaDB 연결



htps : // 기트 b. 이 m/i mp555/ぁらゔㅇl5.8-s2 있어. 기 t
.s2i 의 소스를 일부 수정합니다. 그렇다고 해도 environment 그냥 OK처럼 하고 있습니다.
그것을 PHP 소스로 푸시하면 PHP Application을 다시 빌드합니다.
  • DB_CONNECTION=mysql
  • DB_HOST="Database Service Name"
  • DB_PORT=3306
  • DB_DATABASE="MariaDB Database Name"
  • DB_USERNAME="MariaDB Connection Username"
  • DB_PASSWORD="MariaDB Connection Password"

  • .s2i/environment
    DOCUMENTROOT=/public
    SHORT_OPEN_TAG=ON
    APP_LOG=errorlog
    
    DB_CONNECTION=mysql
    DB_HOST=mariadb
    DB_PORT=3306
    DB_DATABASE=sampledb
    DB_USERNAME=php
    DB_PASSWORD=php@1234
    

    PHP Application 재구성



    Topology 화면에서 PHP를 클릭하고 Start Build를 클릭하면 다시 빌드됩니다.




    이 화면 그대로 기다리고 있어도 괜찮습니다 만, 걱정이므로 Log 전망합니다 (웃음)
    #2의 View Logs에서



    php artisan migrate 확인



    빌드가 완료되면 포드를 교체합니다.
    교체된 Pod의 View Logs를 클릭합니다.
    setup laravel 그런데 Migrate 되고 있네요.
    먼저 Env를 표시하는 것은 완전히 취미입니다.
    Build시와 Deploy시에 환경 변수가 바뀌므로 디버그용이 됩니다.
    *--------------------------------------------------------------------------[ENV]
    APP_DATA=/opt/app-root/src
    APP_LOG=errorlog
    APP_PORT=tcp://172.30.142.243:8080
    APP_PORT_8080_TCP=tcp://172.30.142.243:8080
    APP_PORT_8080_TCP_ADDR=172.30.142.243
    APP_PORT_8080_TCP_PORT=8080
    APP_PORT_8080_TCP_PROTO=tcp
    APP_PORT_8443_TCP=tcp://172.30.142.243:8443
    APP_PORT_8443_TCP_ADDR=172.30.142.243
    APP_PORT_8443_TCP_PORT=8443
    APP_PORT_8443_TCP_PROTO=tcp
    APP_ROOT=/opt/app-root
    APP_SERVICE_HOST=172.30.142.243
    APP_SERVICE_PORT=8080
    APP_SERVICE_PORT_8080_TCP=8080
    APP_SERVICE_PORT_8443_TCP=8443
    BASH=/bin/bash
    BASHOPTS=cmdhist:extquote:force_fignore:hostcomplete:interactive_comments:progcomp:promptvars:sourcepath
    BASH_ALIASES=()
    BASH_ARGC=()
    BASH_ARGV=()
    BASH_CMDS=()
    BASH_LINENO=([0]="0")
    BASH_SOURCE=([0]="/tmp/scripts/run")
    BASH_VERSINFO=([0]="4" [1]="2" [2]="46" [3]="2" [4]="release" [5]="x86_64-redhat-linux-gnu")
    BASH_VERSION='4.2.46(2)-release'
    DB_CONNECTION=mysql
    DB_DATABASE=sampledb
    DB_HOST=mariadb
    DB_PASSWORD=php@1234
    DB_PORT=3306
    DB_USERNAME=php
    DESCRIPTION='PHP 7.2 available as container is a base platform for building and running various PHP 7.2 applications and frameworks. PHP is an HTML-embedded scripting language. PHP attempts to make it easy for developers to write dynamically generated web pages. PHP also offers built-in database integration for several commercial and non-commercial database management systems, so writing a database-enabled webpage with PHP is fairly simple. The most common use of PHP coding is probably as a replacement for CGI scripts.'
    DIRSTACK=()
    DOCUMENTROOT=/public
    EUID=1000540000
    GROUPS=()
    HOME=/opt/app-root/src
    HOSTNAME=app-74f6889874-ds9zx
    HOSTTYPE=x86_64
    HTTPD_CONFIGURATION_PATH=/opt/app-root/etc/conf.d
    HTTPD_DATA_ORIG_PATH=/opt/rh/httpd24/root/var/www
    HTTPD_DATA_PATH=/var/www
    HTTPD_MAIN_CONF_D_PATH=/etc/httpd/conf.d
    HTTPD_MAIN_CONF_PATH=/etc/httpd/conf
    HTTPD_VAR_PATH=/opt/rh/httpd24/root/var
    HTTPD_VAR_RUN=/var/run/httpd
    IFS=$' \t\n'
    KUBERNETES_PORT=tcp://172.30.0.1:443
    KUBERNETES_PORT_443_TCP=tcp://172.30.0.1:443
    KUBERNETES_PORT_443_TCP_ADDR=172.30.0.1
    KUBERNETES_PORT_443_TCP_PORT=443
    KUBERNETES_PORT_443_TCP_PROTO=tcp
    KUBERNETES_SERVICE_HOST=172.30.0.1
    KUBERNETES_SERVICE_PORT=443
    KUBERNETES_SERVICE_PORT_HTTPS=443
    LD_LIBRARY_PATH=/opt/rh/rh-nodejs10/root/usr/lib64:/opt/rh/httpd24/root/usr/lib64:/opt/rh/rh-php72/root/usr/lib64
    LIBRARY_PATH=/opt/rh/httpd24/root/usr/lib64
    MACHTYPE=x86_64-redhat-linux-gnu
    MANPATH=/opt/rh/rh-nodejs10/root/usr/share/man:/opt/rh/httpd24/root/usr/share/man:/opt/rh/rh-php72/root/usr/share/man:
    MARIADB_PORT=tcp://172.30.91.107:3306
    MARIADB_PORT_3306_TCP=tcp://172.30.91.107:3306
    MARIADB_PORT_3306_TCP_ADDR=172.30.91.107
    MARIADB_PORT_3306_TCP_PORT=3306
    MARIADB_PORT_3306_TCP_PROTO=tcp
    MARIADB_SERVICE_HOST=172.30.91.107
    MARIADB_SERVICE_PORT=3306
    MARIADB_SERVICE_PORT_MARIADB=3306
    NAME=php
    NODEJS_SCL=rh-nodejs10
    OPENSHIFT_BUILD_COMMIT=37742889f0427c78eed1855da5bb128a0b7f041f
    OPENSHIFT_BUILD_NAME=app-3
    OPENSHIFT_BUILD_NAMESPACE=laravel
    OPENSHIFT_BUILD_SOURCE=https://gitlab.com/imp555/laravel5.8-s2i.git
    OPTERR=1
    OPTIND=1
    OSTYPE=linux-gnu
    PATH=/opt/rh/rh-nodejs10/root/usr/bin:/opt/rh/httpd24/root/usr/bin:/opt/rh/httpd24/root/usr/sbin:/opt/rh/rh-php72/root/usr/bin:/opt/rh/rh-php72/root/usr/sbin:/opt/app-root/src/bin:/opt/app-root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/rh/rh-php72/root/usr/bin
    PHP_CONTAINER_SCRIPTS_PATH=/usr/share/container-scripts/php/
    PHP_DEFAULT_INCLUDE_PATH=/opt/rh/rh-php72/root/usr/share/pear
    PHP_HTTPD_CONF_FILE=rh-php72-php.conf
    PHP_SYSCONF_PATH=/etc/opt/rh/rh-php72
    PHP_VERSION=7.2
    PHP_VER_SHORT=72
    PIPESTATUS=([0]="0")
    PKG_CONFIG_PATH=/opt/rh/httpd24/root/usr/lib64/pkgconfig
    PLATFORM=el7
    PPID=0
    PS4='+ '
    PWD=/opt/app-root/src
    PYTHONPATH=/opt/rh/rh-nodejs10/root/usr/lib/python2.7/site-packages
    SCL_ENABLED=rh-php72
    SHELL=/sbin/nologin
    SHELLOPTS=braceexpand:errexit:hashall:interactive-comments
    SHLVL=2
    SHORT_OPEN_TAG=ON
    STI_SCRIPTS_PATH=/usr/libexec/s2i
    STI_SCRIPTS_URL=image:///usr/libexec/s2i
    SUMMARY='Platform for building and running PHP 7.2 applications'
    TERM=xterm
    UID=1000540000
    X_SCLS='rh-nodejs10 httpd24 rh-php72 '
    _='*--------------------------------------------------------------------------[ENV]'
    container=oci
    *----------------------------------------------------------------[setup laravel]
    Migrating database 'php artisan migrate --force'...
    Migration table created successfully.
    Migrating: 2014_10_12_000000_create_users_table
    Migrated:  2014_10_12_000000_create_users_table (0.36 seconds)
    Migrating: 2014_10_12_100000_create_password_resets_table
    Migrated:  2014_10_12_100000_create_password_resets_table (0.27 seconds)
    Create the symbolic link 'php artisan storage:link'...
    The [public/storage] directory has been linked.
    *--------------------------------------------------------------[exec run script]
    => sourcing 20-copy-config.sh ...
    ---> 12:18:02     Processing additional arbitrary httpd configuration provided by s2i ...
    => sourcing 00-documentroot.conf ...
    => sourcing 50-mpm-tuning.conf ...
    => sourcing 40-ssl-certs.sh ...
    AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 10.128.0.53. Set the 'ServerName' directive globally to suppress this message
    [Sun Mar 08 12:18:04.150285 2020] [ssl:warn] [pid 1] AH01909: 10.128.0.53:8443:0 server certificate does NOT include an ID which matches the server name
    [Sun Mar 08 12:18:04.332619 2020] [ssl:warn] [pid 1] AH01909: 10.128.0.53:8443:0 server certificate does NOT include an ID which matches the server name
    [Sun Mar 08 12:18:04.333001 2020] [http2:warn] [pid 1] AH10034: The mpm module (prefork.c) is not supported by mod_http2. The mpm determines how things are processed in your server. HTTP/2 has more demands in this regard and the currently selected mpm will just not do. This is an advisory warning. Your server will continue to work, but the HTTP/2 protocol will be inactive.
    [Sun Mar 08 12:18:04.335446 2020] [lbmethod_heartbeat:notice] [pid 1] AH02282: No slotmem from mod_heartmonitor
    [Sun Mar 08 12:18:04.565113 2020] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.34 (Red Hat) OpenSSL/1.0.2k-fips configured -- resuming normal operations
    [Sun Mar 08 12:18:04.565309 2020] [core:notice] [pid 1] AH00094: Command line: 'httpd -D FOREGROUND'
    

    이것으로 개발할 수 있는 환경이 갖추어졌습니다!

    좋은 웹페이지 즐겨찾기