CentOS 7 ã® Apache (+PHP) ãããã·ã§ã«ãçµç±ã㦠sfdx ã³ãã³ããå®è¡ãã
Docker ã« CentOS + Apache + PHP
Dockerfile ãä½ã
CentOS ã¤ã³ã¹ãã¼ã«ã¨ PHP ã¤ã³ã¹ãã¼ã«ã¾ã§èªåå
FROM centos:7 RUN yum update -y && yum clean all # Repository # EPEL RUN yum install -y epel-release # remi RUN yum -y install http://rpms.famillecollet.com/enterprise/remi-release-7.rpm # installs RUN yum install -y httpd RUN yum -y install --enablerepo=remi,remi-php81 php php-devel php-mbstring php-pdo php-xml php-gd php-fpm php-mysqlnd php-opcache php-pecl-zip libzip5 EXPOSE 80 ENTRYPOINT ["/usr/sbin/httpd", "-DFOREGROUND"]
èµ·å
ã³ã³ãã¤ã«ã¨ã³ã³ããä½æ
> docker build --tag develop:1.0 . > docker run -ti --publish 8080:80 --detach --name develop develop:1.0
http://localhost:8080 ã§è¦ããã¯ã
ã³ã³ããçªå·ã確èªãã¦
> docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES bcd685553188 develop:1.0 "/usr/sbin/httpd -DFâ¦" 2 minutes ago Up 2 minutes 0.0.0.0:8080->80/tcp develop
ãã°ã¤ã³
> docker exec -it bcd685553188 bash [root@bcd685553188 /]#
Vim ãçªã£è¾¼ãã§ã確èªç¨ç»é¢ä½æ
# yum install vim -y # cd /var/www/html # vim index.php
å 容ã¯
<? phpinfo(); ?>
ããï¼åºãªãâ¦ã¦ãHTTPå¿çãã¾ãã¾ã½ã¼ã¹ããã
ã¢ã¸ã¥ã¼ã«ã¯ /etc/httpd/conf.d
ã¨ã /etc/httpd/modules
ã«å
¥ã£ã¦ãããã httpd.conf
ããã£ã¦
LoadModule php7_module modules/libphp7.so AddHandler php7-script .php DirectoryIndex index.php
ã³ã³ããåèµ·åãã¦åã¢ã¯ã»ã¹ãããå¤åãªãâ¦ï¼
ãããã㦠php.ini
ãï¼ã¨ããã£ããã¢ã¿ãª
short_open_tag = Off
ãã¡ã¼ãåå ã¯â¦ã£ã¦ãã¨ã§ On
ã§æ¸ãæãã¦åèµ·åã
表示ãããã
PHP ãã sfdx ã³ãã³ãã³ã¼ã«ãã
nodejs ã¤ã³ã¹ãã¼ã«
ãã®è¾º ããã¤ã³ã¹ãã¼ã«ã³ãã³ããå¼ã£å¼µã
# curl -fsSL https://rpm.nodesource.com/setup_18.x | bash - # yum install -y nodejs
ããã¨
Error: Package: 2:nodejs-18.13.0-1nodesource.x86_64 (nodesource) Requires: libstdc++.so.6(GLIBCXX_3.4.20)(64bit) Error: Package: 2:nodejs-18.13.0-1nodesource.x86_64 (nodesource) Requires: libc.so.6(GLIBC_2.28)(64bit) Error: Package: 2:nodejs-18.13.0-1nodesource.x86_64 (nodesource) Requires: libstdc++.so.6(CXXABI_1.3.9)(64bit) Error: Package: 2:nodejs-18.13.0-1nodesource.x86_64 (nodesource) Requires: libstdc++.so.6(GLIBCXX_3.4.21)(64bit) Error: Package: 2:nodejs-18.13.0-1nodesource.x86_64 (nodesource) Requires: libm.so.6(GLIBC_2.27)(64bit)
â¦ããã§â¦
# yum install -y glibc libstdc++
ã§ãç¶æ³å¤ãããâ¦ã©ããè¦æ±ã©ã¤ãã©ãªãã¼ã¸ã§ã³ãåããªãããã§â¦ãã
yum install yum install https://rpm.nodesource.com/pub_16.x/el/7/x86_64/nodejs-16.17.0-1nodesource.x86_64.rpm
ãããããªããã 16 å ¥ãããâ¦
sfdx å ¥ãã
æ©ãããããªãâ¦ã
# npm install sfdx-cli --global # sfdx --version sfdx-cli/7.185.0 linux-x64 node-v16.17.0
ã¤ã³ã¹ãã¼ã«ãããå ã¯
# ls /usr/lib/node_modules/ corepack npm sfdx-cli
ã¤ã¾ãç´ããããã§ããã¯ã
# /usr/lib/node_modules/sfdx-cli/bin/run --version sfdx-cli/7.185.0 linux-x64 node-v16.17.0
php ãã sfdx ãå¼ãã§ã¿ã
apache(+PHP) ãã exec
ã³ãã³ããå®è¡ããã¨ããPath ã¨ããã®ä»è«¸ã
空ã£ã½ãªã®ã§ããã¹è¨å®ãè¡ãã·ã§ã«ã³ãã³ããä½æãã¦ããã
NPM_PACKAGES="/usr/lib/node_modules" echo "export PATH="\""\$PATH:$NPM_PACKAGES/bin"\"" npm config set prefix $NPM_PACKAGES" | tee '/etc/profile.d/node-path.sh'
å®è¡çµæã¨ç¢ºèªã
# NPM_PACKAGES="/usr/lib/node_modules" # echo "export PATH="\""\$PATH:$NPM_PACKAGES/bin"\"" > npm config set prefix $NPM_PACKAGES" | tee '/etc/profile.d/node-path.sh' export PATH="$PATH:/usr/lib/node_modules/bin" npm config set prefix /usr/lib/node_modules # cat /etc/profile.d/node-path.sh export PATH="$PATH:/usr/lib/node_modules/bin" npm config set prefix /usr/lib/node_modules
/etc/profile.d
ã¯éãã°ã¤ã³ã·ã§ã«ã§ãèªã¿è¾¼ã¾ããã
apache ã¦ã¼ã¶ããå¼ã¹ãããã«ã¾ãã¯æå®(権éå§è²ã¾ã§ã¯ãããããç¥ãããã©ãããå°ç¨ãªã®ã§ä¸å¿â¦)
# chown apache:apache /etc/profile.d/node-path.sh # chmod +x /etc/profile.d/node-path.sh
ãããã /var/www/example.sh
ãä½æ â»æ¨©éã¯æ°ãã¤ãã¦
#!/bin/bash /etc/profile.d/node-path.sh sfdx --version exit 0
ï¼/etc/profile.d/node-path.sh
ã¯æ¸ããªãã¦ãèªã¿è¾¼ã¾ããã¨ã¯æãããä¸å¿â¦ï¼
ã§ãindex.php
ãä¸è¨ã§æ¸ãæãã¾ãã
<? $cmd = '/bin/bash /var/www/example.sh'; $output=null; $retval=null; exec($cmd, $output, $retval); echo "Returned with status $retval and output:\n"; print_r($output); ?>
ããã¦ç»é¢ã¢ã¯ã»ã¹ããã¨ãç¡äºã«ä¸è¨ã表示ããã¾ããã
Returned with status 0 and output: Array ( [0] => sfdx-cli/7.185.0 linux-x64 node-v16.17.0 )