PHP(PHP: Hypertext Preprocessor)即“超文本預處理器”,是在服務器端執(zhí)行的腳本語言,尤其適用于Web開發(fā)并可嵌入HTML中。PHP語法學習了C語言,吸納Java和Perl多個語言的特色發(fā)展出自己的特色語法,并根據(jù)它們的長項持續(xù)改進提升自己,例如java的面向對象編程,該語言當初創(chuàng)建的主要目標是讓開發(fā)人員快速編寫出優(yōu)質的web網(wǎng)站。PHP同時支持面向對象和面向過程的開發(fā),使用上非常靈活。
一.docker拉取nginx和php鏡像
docker pull nginx:latest(最新版本)
docker pull php:7.4-fpm phpphp7.4版本的fpm
docker images查看已安裝的鏡像
?二.創(chuàng)建容器
1.創(chuàng)建nginx文件夾存放等會php文件要掛載的目錄,創(chuàng)建在/docker/nginx/www/myphp目錄的
mkdir -p /docker/nginx/www/myphp
2.創(chuàng)建容器:名為myphp
docker run --name myphp -v /docker/nginx/www/myphp:/www/myphp -d c5fdabeef32a
3.查看運行的容器,docker ps查看
4.創(chuàng)建conf? ?conf.d目錄 mkdir -p /docker/nginx/conf/conf.d。
5.創(chuàng)建自己的conf文件,自己命名
vim myphp.conf
erver {
listen 80;
server_name localhost; #修改成自己的域名
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
#反向代理到php-fpm
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/myphp/$fastcgi_script_name;
include fastcgi_params;
}
}
6.創(chuàng)建運行nginx的容器與PHP之間關聯(lián)
docker run --name nginx1 -p 8088:80 -d \
-v /docker/nginx/www:/usr/share/nginx/html \
-v /docker/nginx/conf/conf.d:/etc/nginx/conf.d \
--link myphp:php nginx
三.測試
在/docker/nginx/www/myphp文件夾中創(chuàng)建一個index.php文章來源:http://www.zghlxwxcb.cn/news/detail-745396.html
拜?。?!文章來源地址http://www.zghlxwxcb.cn/news/detail-745396.html
到了這里,關于docker搭建php的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!