拉取php7.4-fpm
docker pull php:7.4-fpm
建立nginx和php配置文件
mkdir -p ~/lnmp/nginx/www ~/lnmp/nginx/logs ~/lnmp/nginx/conf
启动php7.4容器
docker run --name myphp74 -v ~/lnmp/nginx/www:/www -d php:7.4-fpm
安装nginx镜像
docker pull nginx
配置nginx文件
- 1 创建文件夹
mkdir ~/lnmp/nginx/conf/conf.d - 2.创建配置文件
~/lnmp/nginx/conf/conf.d/test-php.conf - 3 插入内容
server {
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;
}
location ~ \.php$ {
fastcgi_pass php:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
include fastcgi_params;
}
}
运行nginx
docker run --name php74-nginx -p 8091:80 -d -v ~/lnmp/nginx/www:/usr/share/nginx/html:ro -v ~/lnmp/nginx/conf/conf.d:/etc/nginx/conf.d:ro --link myphp74:php -d nginx
网友评论