kubernetes集群中怎么部署php應(yīng)用,相信很多沒(méi)有經(jīng)驗(yàn)的人對(duì)此束手無(wú)策,為此本文總結(jié)了問(wèn)題出現(xiàn)的原因和解決方法,通過(guò)這篇文章希望你能解決這個(gè)問(wèn)題。
創(chuàng)新互聯(lián)是專業(yè)的南京網(wǎng)站建設(shè)公司,南京接單;提供做網(wǎng)站、成都網(wǎng)站制作,網(wǎng)頁(yè)設(shè)計(jì),網(wǎng)站設(shè)計(jì),建網(wǎng)站,PHP網(wǎng)站建設(shè)等專業(yè)做網(wǎng)站服務(wù);采用PHP框架,可快速的進(jìn)行南京網(wǎng)站開(kāi)發(fā)網(wǎng)頁(yè)制作和功能擴(kuò)展;專業(yè)做搜索引擎喜愛(ài)的網(wǎng)站,專業(yè)的做網(wǎng)站團(tuán)隊(duì),希望更多企業(yè)前來(lái)合作!
一、通過(guò)dockerfile創(chuàng)建php鏡像文件
# cat dockerfile FROM docker.io/openshift/base-centos7:latest MAINTAINER ylw "ylw@fjhb.cn" RUN yum makecache RUN yum -y install php-fpm php php-gd php-MySQL php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php-xmlrpc RUN sed -i 's/listen = 127.0.0.1:9000/listen = 0.0.0.0:9000/' /etc/php-fpm.d/www.conf RUN sed -i 's/listen.allowed_clients = 127.0.0.1/;listen.allowed_clients = 127.0.0.1/' /etc/php-fpm.d/www.conf EXPOSE 9000 CMD ["/sbin/php-fpm"] # docker build -t registry.fjhb.cn/php:0.1 . # docker push registry.fjhb.cn/php:0.1
二、通過(guò)yaml文件創(chuàng)建ReplicationController和service
# cat php-rc.yaml apiVersion: v1 kind: ReplicationController metadata: name: php-server labels: name: php-server spec: replicas: 2 selector: name: php-server template: metadata: labels: name: php-server spec: containers: - name: php-server image: registry.fjhb.cn/php:0.1 volumeMounts: - mountPath: /usr/share/nginx/html name: nginx-data ports: - containerPort: 9000 volumes: - name: nginx-data persistentVolumeClaim: claimName: nfs-data # cat php-svc.yaml apiVersion: v1 kind: Service metadata: name: php-server labels: name: php-server spec: ports: - port: 9000 protocol: TCP targetPort: 9000 selector: name: php-server # kubectl create -f php-rc.yaml # kubectl create -f php-svc.yaml
三、修改nginx配置支持php
# cat /home/nginx/conf.d/test.conf server { listen 80; server_name test.fjhb.cn; access_log /etc/nginx/test.fjhb.cn.accesslog main; location / { root /usr/share/nginx/html; index index.html index.htm; } location ~ \.php$ { root /usr/share/nginx/html; fastcgi_pass php-server:9000; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; } location ~ /\.ht { deny all; } }
網(wǎng)頁(yè)訪問(wèn)phpinfo頁(yè)面測(cè)試
四、下載Discuz應(yīng)用部署,測(cè)試php和mysql主從的連通性
下載地址:http://www.discuz.net/thread-3796882-1-1.html
# mkdir /home/bbs # cd /home/bbs # unzip Discuz_X3.3_SC_UTF8.zip # mv upload/* ./
通過(guò)訪問(wèn)網(wǎng)頁(yè)進(jìn)行部署
看完上述內(nèi)容,你們掌握kubernetes集群中怎么部署php應(yīng)用的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!