2024年12月

首先在linux执行下面命令,开启rewrite模块:

sudo a2enmod rewrite

然后编辑apache2 站点配置文件:
sudo vi /etc/apache2/sites-enabled/000-default.conf

添加以下内容:

<Directory /var/www/html>
        Options FollowSymLinks
        AllowOverride All
        Require all granted
</Directory>


docker镜像php-8.2-fpm的工作目录为:/var/www/html

创建本地目录~/nginx/html,用于保存php网页文件。
创建本地目录~/nginx/conf,用于保存nginx配置文件。
docker run -d --name php -v ~/nginx/html:/var/www/html php-8.2-fpm

将nginx容器配置文件复制到本地
docker run -d --name tmpnginx nginx:latest
docker cp tmpnginx:/etc/nginx/conf.d/. ~/nginx/conf
docker rm tmpnginx -f

docker run -d --name nginx -p 80:80 -v ~/nginx/conf:/etc/nginx/conf.d -v ~/nginx/html:/usr/share/nginx/html --link php nginx:latest

编辑本地nginx配置文件:

2024-12-05T03:31:30.png