docker下安装使用maccms_v10系统
# 下载maccms v10源码
解压到maccms10/www下
# 创建docker compose目录结构
maccms10
├── docker-compose.yml
├── nginx
│ ├── conf.d
│ │ └── default.conf
│ └── log
│ ├── access.log
│ └── error.log
├── php
│ ├── conf.d
│ │ └── php.ini
│ ├── php.ini-development
│ └── php.ini-production
└── www
├── addons
├── admin.php
├── api.php
├── application
├── crossdomain.xml
├── extend
├── index.php
├── install.php
├── LICENSE
├── README.md
├── robots.txt
├── runtime
├── static
├── template
├── thinkphp
├── upload
├── vendor
└── \350\257\264\346\230\216\346\226\207\346\241\243
由于mysql数据库使用现有的所以不再创建
这里我启动了一个nginx和php,这个nignx只为php服务,外部还有一个全局nginx在代理到这个nginx上面(如果也是我这种方式,这里的ports也可以不用映射)
maccms10/docker-compose.yml
version: '3.7'
services:
maccms-nginx:
image: nginx:alpine
container_name: maccms-nginx
restart: always
# ports:
# - 8081:80
# - 8444:443
environment:
- TZ=Asia/Shanghai
depends_on:
- maccms10
volumes:
- /data/docker/awei/maccms10/nginx/conf.d/default.conf:/etc/nginx/conf.d/default.conf
- /data/docker/awei/maccms10/nginx/log:/var/log/nginx
- /data/docker/awei/maccms10/www:/usr/share/nginx/www
networks:
- proxy
maccms10:
image: php:7.2.34-fpm
container_name: maccms10
restart: always
# ports:
# - 9000:9000
environment:
- TZ=Asia/Shanghai
volumes:
- /data/docker/awei/maccms10/www:/usr/share/nginx/www
- /data/docker/awei/maccms10/php/conf.d/php.ini:/usr/local/etc/php/php.ini
networks:
- proxy
networks:
proxy:
external: true
内部nginx:maccms10/nginx/conf.d/default.conf
server {
listen 80 default_server;
server_name localhost;
root /usr/share/nginx/www;
location / {
index index.html index.htm index.php;
}
# nginx下除了首页其他都是404怎么办?修改一下伪静态规则,一般都可以解决了。 如果修改了后台文件入口admin.php,则改为对应的文件名。
if (!-e $request_filename) {
rewrite ^/index.php(.*)$ /index.php?s=$1 last;
rewrite ^/admin.php(.*)$ /admin.php?s=$1 last;
rewrite ^/api.php(.*)$ /api.php?s=$1 last;
# rewrite ^(.*)$ /index.php?s=$1 last;
break;
}
location ~ \.php$ {
fastcgi_pass maccms10:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
php/conf.d/php.ini是从php.ini-development复制而来,这里可以看这篇博客docker搭建nginx+php环境的两种方式
外部nginx:maccms.bstu.cn.conf
server {
listen 443 ssl;
server_name maccms.bstu.cn;
# ssl on;
ssl_certificate "/root/.acme.sh/bstu.cn/cert.pem";
ssl_certificate_key "/root/.acme.sh/bstu.cn/key.pem";
ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'AES128+EECDH:AES128+EDH:!aNULL';
ssl_prefer_server_ciphers on;
charset utf-8;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary off;
gzip_disable "MSIE [1-6]\.";
location / {
proxy_pass http://maccms-nginx:80;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
# 开始搭建
1.启动
docker compose up -d
这时候应该能正常进入install.php安装页面,进入第二页时会报pdo_mysql、zip以及部分文件无读写权限
2.修改权限
chmod 777 -R runtime
chmod 777 -R application
chmod 777 -R upload
# 由于导入播放器需要static文件夹下某些文件的保存文件权限,所以static也给一下读写
chmod 777 -R static
3.修改php.ini
php/conf.d/php.ini 文件中找到;extension=pdo_mysql这一行,将前面的分号去掉并保存
4.使用docker exec进入php进行php扩展的安装
docker exec -it maccms10 bash
# 更新源
apt update
# 安装pdo_mysql
docker-php-ext-install pdo pdo_mysql
# 安装zip扩展所需的依赖扩展
apt-get update && apt-get install -y zlib1g-dev && apt-get install -y libzip-dev
# 安装并启动zip扩展
docker-php-ext-install zip
# 安装并启动gd扩展
# 安装库
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
# 创建并初始化 /usr/src/php目录
docker-php-source extract
# gd源码文件夹
cd /usr/src/php/ext/gd
# php>=7.4准备编译配置
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2
# php<7.4编译配置
docker-php-ext-configure gd --with-webp=/usr/include/webp --with-jpeg=/usr/include --with-freetype=/usr/include/freetype2/
# 安装gd 扩展
docker-php-ext-install gd
# 验证GD
php --ri gd
5.重启容器
docker compose restart
6.回到浏览器刷新页面,这时候所有问题都解决了,进行下一步安装
^_^成为第一个评论的人吧!
评论
昵称
邮箱 (回复通知)
站点
内容 (支持Markdown语法)