Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to deploy php applications in kubernetes Cluster

Shulou Source: shulou.com Published: 2022-06-01 16:14:50 09月22日 Update

It is believed that many inexperienced people don't know what to do about how to deploy php applications in kubernetes cluster. Therefore, this paper summarizes the causes and solutions of the problem. Through this article, I hope you can solve this problem.

First, create a php image file through dockerfile

# cat dockerfileFROM docker.io/openshift/base-centos7:latestMAINTAINER ylw "ylw@fjhb.cn" RUN yum makecacheRUN yum-y install php-fpm php php-gd php-mysql php-mbstring php-xml php-mcrypt php-imap php-odbc php-pear php-xmlrpcRUN sed-I 's/listen = 127.0.0.1:9000/listen = 0.0.0.0 RUN yum makecacheRUN yum 9000max' / etc/php-fpm.d/www.confRUN sed-I 's/listen.allowed_clients = 127.0.0.1 / Listen.allowed_clients = 127.0.0.1 listen.allowed_clients'/ etc/php-fpm.d/www.confEXPOSE 9000CMD ["/ sbin/php-fpm"] # docker build-t registry.fjhb.cn/php:0.1. # docker push registry.fjhb.cn/php:0.1

Second, create ReplicationController and service through yaml files

# cat php-rc.yamlapiVersion: v1kind: ReplicationControllermetadata: name: php-server labels: name: php-serverspec: replicas: 2 selector: name: php-server template: metadata: labels: name: php-serverspec: 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.yamlapiVersion: v1kind: Servicemetadata: name: php-server labels: name: php-serverspec: ports:-port: 9000 protocol: TCP targetPort: 9000 selector:name: php-server# kubectl create-f php-rc.yaml# kubectl create-f php-svc.yaml

3. Modify nginx configuration to support php

# cat / home/nginx/conf.d/test.confserver {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;}}

Web page access phpinfo page test

Download Discuz application deployment and test the connectivity of php and mysql master and slave

Download address: http://www.discuz.net/thread-3796882-1-1.html

# mkdir / home/bbs# cd / home/bbs# unzip Discuz_X3.3_SC_UTF8.zip# mv upload/*. /

Deploy by visiting a web page

After reading the above, have you mastered how to deploy php applications in kubernetes clusters? If you want to learn more skills or want to know more about it, you are welcome to follow the industry information channel, thank you for reading!

Tags: Applications clusters content files methods more web pages problems tests at a loss to this end master-slave reason address this skills articles experience industry information Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Redmi Microsoft Huawei Xiaomi